-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attestation: add name to Validator as unique identifier #1095
base: main
Are you sure you want to change the base?
Conversation
c5805b5
to
dde0de0
Compare
dde0de0
to
e243f98
Compare
Wait for merge of #1082 |
…tor as unique identifier
e243f98
to
98e66b7
Compare
@@ -86,10 +88,11 @@ func (c *Credentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.A | |||
return nil, nil, fmt.Errorf("generating SNP validation options: %w", err) | |||
} | |||
|
|||
for _, opt := range opts { | |||
for i, opt := range opts { | |||
name := "snp-" + strconv.Itoa(i) + "-" + strings.TrimPrefix(opt.VerifyOpts.Product.Name.String(), "SEV_PRODUCT_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name := "snp-" + strconv.Itoa(i) + "-" + strings.TrimPrefix(opt.VerifyOpts.Product.Name.String(), "SEV_PRODUCT_") | |
name := fmt.Sprintf("snp-%d-%s", i, strings.TrimPrefix(opt.VerifyOpts.Product.Name.String(), "SEV_PRODUCT_")) |
@@ -98,9 +101,10 @@ func (c *Credentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.A | |||
log.Error("Could not generate TDX validation options", "error", err) | |||
return nil, nil, fmt.Errorf("generating TDX validation options: %w", err) | |||
} | |||
for _, opt := range tdxOpts { | |||
for i, opt := range tdxOpts { | |||
name := "tdx" + strconv.Itoa(i) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name := "tdx" + strconv.Itoa(i) | |
name := fmt.Sprintf("tdx-%d", i) |
@@ -94,6 +95,7 @@ type Issuer interface { | |||
type Validator interface { | |||
Getter | |||
Validate(attDoc []byte, nonce []byte, peerPublicKey []byte) error | |||
Name() string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More idiomatic might be to implement fmt.Stringer
.
// The joined error should reveal the atls nonce once to maintain readability. Because the error is only revealed if all validators fail, | ||
// we can implicitly include the nonce in the first validator error and the concatenate the other errors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make more sense to first collect the errors with Join
, and then wrap them with a message that contains the nonce before returning from this function.
} | ||
} | ||
|
||
// OID returns the OID of the validator. | ||
// OID returns the root OID for the raw SNP report extension used by the validator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why root
? And, if you are changing the docstring here, please also change it for TDX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. I'd say it's technically a node, but not the root node.
opt.ValidateOpts.HostData = coordinatorPolicyChecksum | ||
name := "snp-" + strconv.Itoa(i) + "-" + strings.TrimPrefix(opt.VerifyOpts.Product.Name.String(), "SEV_PRODUCT_") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Sprintf
as above
@@ -86,10 +88,11 @@ func (c *Credentials) ServerHandshake(rawConn net.Conn) (net.Conn, credentials.A | |||
return nil, nil, fmt.Errorf("generating SNP validation options: %w", err) | |||
} | |||
|
|||
for _, opt := range opts { | |||
for i, opt := range opts { | |||
name := "snp-" + strconv.Itoa(i) + "-" + strings.TrimPrefix(opt.VerifyOpts.Product.Name.String(), "SEV_PRODUCT_") | |||
validator := snp.NewValidatorWithReportSetter(opt.VerifyOpts, opt.ValidateOpts, | |||
logger.NewWithAttrs(logger.NewNamed(c.logger, "validator"), map[string]string{"tee-type": "snp"}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have a name in the constructor, we could remove the attrs here and add them there?
This PR is a follow-up on #1027 and aims to enhance the logging of the different validation processes on the coordinator to reach better readability of the logs.
<attestation>-<reference-values-index>[-<product>]
The index corresponds to the position of the reference value separated by attestation type in manifest.json.