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

Validate Subcommand! #46

Merged
merged 5 commits into from
Feb 3, 2022
Merged

Validate Subcommand! #46

merged 5 commits into from
Feb 3, 2022

Conversation

puerco
Copy link
Member

@puerco puerco commented Jan 29, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR introduces to bom the capability to start validating things. For now, only files attached to the first level of the document are supported and we will be introducing more artifact types and other kinds of validation.

image

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Test for document.ValidateFiles() is coming in a followup shortly

Test is now included

/assign @cpanato

Does this PR introduce a user-facing change?

`bom` can now validate artifacts! We now have a new validate subcommand that can be used to check files attached to the top of the SBOM: `bom validate sbom.spdx file.txt`. No more checksum.txt files! 🎉

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 29, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 29, 2022
cmd/bom/cmd/validate.go Outdated Show resolved Hide resolved
@cpanato
Copy link
Member

cpanato commented Jan 30, 2022

thanks for this feature

@@ -62,6 +62,7 @@ func init() {
rootCmd.AddCommand(generateCmd)
rootCmd.AddCommand(documentCmd)
rootCmd.AddCommand(versionCmd)
AddValidate(rootCmd)
Copy link
Member

Choose a reason for hiding this comment

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

I noticed that this deviates from the pattern of the other commands. Do you plan on refactoring the others to follow this new pattern?

Copy link
Member Author

@puerco puerco Feb 1, 2022

Choose a reason for hiding this comment

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

Yep, I tried to switch to the pattern @justaugustus recommended here: #27 (review)
I will refactor the rest of the CLI to match.

Copy link
Member

Choose a reason for hiding this comment

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

👍 nice

@puerco puerco force-pushed the validate branch 2 times, most recently from 9f6c03c to 6e49272 Compare February 1, 2022 08:04
@puerco
Copy link
Member Author

puerco commented Feb 1, 2022

Ready,foxed the nit and also pushed the new function test. Please take another look when you have time @cpanato

Copy link
Contributor

@justaugustus justaugustus left a comment

Choose a reason for hiding this comment

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

@puerco -- One nit/thing that needs clarification!

Comment on lines +92 to +98
cmd.PersistentFlags().BoolVarP(
&valOpts.exitCode,
"exit-code",
"e",
false,
"when true, bom will exit with exit code 1 if invalid artifacts are found",
)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is maybe extraneous?
Is there a scenario where we'd want a validate command to "fail successfully"?

Copy link
Member Author

@puerco puerco Feb 2, 2022

Choose a reason for hiding this comment

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

Yes! The idea is that you can check the integrity of files you download and use the tool in a script:

bom validate -e sbom.spdx file.zip || echo "Your zipfile is corrupt"

The bom action will use it to verify bom itself:

https://github.com/puerco/bom-installer/blob/1d65808b8b512ca77cf2d73cb844570cfec9f39e/action.yaml#L161

Signed-off-by: Adolfo García Veytia <adolfo.garcia@uservers.net>
@puerco
Copy link
Member Author

puerco commented Feb 2, 2022

Fixed the merge conflicts 🚀

puerco and others added 4 commits February 2, 2022 14:20
FOr the first time we have some validation support in the SBOM,
this commit introduces the first initial rough method to check
files in the SBOM against paths.

Signed-off-by: Adolfo García Veytia <adolfo.garcia@uservers.net>
Signed-off-by: Adolfo García Veytia <adolfo.garcia@uservers.net>
This commit adds a new subcommand to bom `bom validate`

This allows the tool to check a file's integrity against data
contained in an SBOM. For now we only support files but more
types will be implemented soon(tm).

Signed-off-by: Adolfo García Veytia <adolfo.garcia@uservers.net>
Signed-off-by: Puerco <github@pog.eml.mx>
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: puerco, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [puerco,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@saschagrunert
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 3, 2022
@k8s-ci-robot k8s-ci-robot merged commit 08aee21 into kubernetes-sigs:main Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants