Skip to content
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

Add a mock config-TSM sub-attester #39

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add a mock config-TSM sub-attester #39

wants to merge 3 commits into from

Conversation

cowbon
Copy link
Collaborator

@cowbon cowbon commented Mar 11, 2025

Fix #26

cowbon added 3 commits March 10, 2025 23:50
Endpoint chares now gathers the output of GetEvidence() from each
sub-attesters, combines them into a CMW collection, and wrap it as an
EAT in its response. If there are multiple supported format available
from a sub-attesters, ratsd core picks the first available format from
GetSupportedFormats()

Signed-off-by: Ian Chin Wang <[email protected]>
Add MockTSM attester as the wrapper of the faketsm from
google/go-configfs-tsm repo to enable mock mode

Signed-off-by: Ian Chin Wang <[email protected]>
Copy link
Contributor

@thomas-fossati thomas-fossati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Find a couple of tiny comments inline.

)

const (
mediaType = "application/vnd.veraison.mock-tsm+json"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the “usual” configfs-tsm media type.

The “provider” field in the JSON will be set to “fake” (or whatever) :-)


outEncoded, err := out.ToJSON()
if err != nil {
errMsg := fmt.Errorf("failed to get mock TSM report: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errMsg := fmt.Errorf("failed to get mock TSM report: %v", err)
errMsg := fmt.Errorf("failed to JSON encode mock TSM report: %v", err)

return getEvidenceError(errMsg)
}

if in.ContentType == mediaType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid nesting long pieces of logic. Please invert the condition and fail early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement a mock configfs-tsm plugin
2 participants