mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 06:16:08 -04:00
config: dynamic attestation configuration through S3 backed API (#1808)
This commit is contained in:
parent
25211dc154
commit
0a6e5ec02e
92 changed files with 1020 additions and 302 deletions
91
hack/configapi/main.go
Normal file
91
hack/configapi/main.go
Normal file
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
Copyright (c) Edgeless Systems GmbH
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/internal/api/configapi"
|
||||
"github.com/edgelesssys/constellation/v2/internal/kms/uri"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const (
|
||||
awsRegion = "eu-central-1"
|
||||
awsBucket = "cdn-constellation-backend"
|
||||
invalidDefault = 0
|
||||
)
|
||||
|
||||
var (
|
||||
// AWS S3 credentials.
|
||||
awsAccessKeyID string
|
||||
awsAccessKey string
|
||||
|
||||
// Azure SEV-SNP version numbers.
|
||||
bootloaderVersion uint8
|
||||
teeVersion uint8
|
||||
snpVersion uint8
|
||||
microcodeVersion uint8
|
||||
)
|
||||
|
||||
func handleError(err error) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
myCmd := &cobra.Command{
|
||||
Use: "upload a set of versions specific to the azure-sev-snp attestation variant to the config api",
|
||||
Short: "upload a set of versions specific to the azure-sev-snp attestation variant to the config api",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
ctx := context.Background()
|
||||
cfg := uri.AWSS3Config{
|
||||
Bucket: awsBucket,
|
||||
AccessKeyID: awsAccessKeyID,
|
||||
AccessKey: awsAccessKey,
|
||||
Region: awsRegion,
|
||||
}
|
||||
sut, err := configapi.NewAttestationVersionRepo(ctx, cfg)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
versions := configapi.AzureSEVSNPVersion{
|
||||
Bootloader: bootloaderVersion,
|
||||
TEE: teeVersion,
|
||||
SNP: snpVersion,
|
||||
Microcode: microcodeVersion,
|
||||
}
|
||||
|
||||
if err := sut.UploadAzureSEVSNP(ctx, versions, time.Now()); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
fmt.Println("Successfully uploaded version numbers", versions)
|
||||
}
|
||||
},
|
||||
}
|
||||
myCmd.PersistentFlags().Uint8VarP(&bootloaderVersion, "bootloader-version", "b", invalidDefault, "Bootloader version number")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("bootloader-version"))
|
||||
|
||||
myCmd.PersistentFlags().Uint8VarP(&teeVersion, "tee-version", "t", invalidDefault, "TEE version number")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("tee-version"))
|
||||
|
||||
myCmd.PersistentFlags().Uint8VarP(&snpVersion, "snp-version", "s", invalidDefault, "SNP version number")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("snp-version"))
|
||||
|
||||
myCmd.PersistentFlags().Uint8VarP(µcodeVersion, "microcode-version", "m", invalidDefault, "Microcode version number")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("microcode-version"))
|
||||
|
||||
myCmd.PersistentFlags().StringVar(&awsAccessKeyID, "key-id", "", "ID of the Access key to use for AWS tests. Required for AWS KMS and storage test.")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("key-id"))
|
||||
|
||||
myCmd.PersistentFlags().StringVar(&awsAccessKey, "key", "", "Access key to use for AWS tests. Required for AWS KMS and storage test.")
|
||||
handleError(myCmd.MarkPersistentFlagRequired("key"))
|
||||
handleError(myCmd.Execute())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue