-
Notifications
You must be signed in to change notification settings - Fork 485
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
Improved attestation inspect #1498
Changes from 2 commits
19d16aa
e68c566
3ce17b0
484823c
9818055
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,9 @@ type index struct { | |
} | ||
|
||
type asset struct { | ||
config *ocispec.Image | ||
sbom *sbomStub | ||
slsa *slsaStub | ||
config *ocispec.Image | ||
sbom *sbomStub | ||
provenance *provenanceStub | ||
} | ||
|
||
type result struct { | ||
|
@@ -255,7 +255,7 @@ func (l *loader) scanConfig(ctx context.Context, fetcher remotes.Fetcher, desc o | |
} | ||
|
||
type sbomStub struct { | ||
SPDX json.RawMessage `json:",omitempty"` | ||
SPDX interface{} `json:",omitempty"` | ||
} | ||
|
||
func (l *loader) scanSBOM(ctx context.Context, fetcher remotes.Fetcher, r *result, refs []digest.Digest, as *asset) error { | ||
|
@@ -275,17 +275,24 @@ func (l *loader) scanSBOM(ctx context.Context, fetcher remotes.Fetcher, r *resul | |
if err != nil { | ||
return err | ||
} | ||
var spdx struct { | ||
Predicate interface{} `json:"predicate"` | ||
} | ||
if err := json.Unmarshal(dt, &spdx); err != nil { | ||
return err | ||
} | ||
as.sbom = &sbomStub{ | ||
SPDX: dt, | ||
SPDX: spdx.Predicate, | ||
} | ||
break | ||
} | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
type slsaStub struct { | ||
Provenance json.RawMessage `json:",omitempty"` | ||
type provenanceStub struct { | ||
SLSA interface{} `json:",omitempty"` | ||
} | ||
Comment on lines
+298
to
300
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provenance > SLSA? I thought it was SLSA > Provenance to keep common denominator first? Like in the future we can have SLSA > VSA. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it makes sense to have Type > Format. We have SBOM > SPDX, so I think it makes sense to have Provenance > SLSA. VSA isn't provenance, so we'd have another "type" for that I think. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense 👍 |
||
|
||
func (l *loader) scanProvenance(ctx context.Context, fetcher remotes.Fetcher, r *result, refs []digest.Digest, as *asset) error { | ||
|
@@ -305,9 +312,16 @@ func (l *loader) scanProvenance(ctx context.Context, fetcher remotes.Fetcher, r | |
if err != nil { | ||
return err | ||
} | ||
as.slsa = &slsaStub{ | ||
Provenance: dt, | ||
var slsa struct { | ||
Predicate interface{} `json:"predicate"` | ||
} | ||
if err := json.Unmarshal(dt, &slsa); err != nil { | ||
return err | ||
} | ||
as.provenance = &provenanceStub{ | ||
SLSA: slsa.Predicate, | ||
} | ||
break | ||
} | ||
} | ||
} | ||
|
@@ -328,16 +342,16 @@ func (r *result) Configs() map[string]*ocispec.Image { | |
return res | ||
} | ||
|
||
func (r *result) SLSA() map[string]slsaStub { | ||
func (r *result) Provenance() map[string]provenanceStub { | ||
if len(r.assets) == 0 { | ||
return nil | ||
} | ||
res := make(map[string]slsaStub) | ||
res := make(map[string]provenanceStub) | ||
for p, a := range r.assets { | ||
if a.slsa == nil { | ||
if a.provenance == nil { | ||
continue | ||
} | ||
res[p] = *a.slsa | ||
res[p] = *a.provenance | ||
} | ||
return res | ||
} | ||
|
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.
Bit concerned that there isn't any way to extract the actual attestation. But I guess we can add some special case/command for that later.