-
-
Notifications
You must be signed in to change notification settings - Fork 45
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 spec version to bom #767
Conversation
Signed-off-by: m-brophy <mbrophy@redhat.com>
Signed-off-by: m-brophy <mbrophy@redhat.com>
Why not make |
Note: this is a semver-breaking change since it adds a new public field to a struct without |
To do this I think I'd have to remove the implementation of the method from the Maybe I can just override the code in the trait by providing a new method implementation in the |
I'm not very familiar with this part of the codebase, and I didn't have to use it directly much. So I'm happy to defer to @justahero 's judgment on the code review, and accept whatever exposes the most easy-to-use API for people actually using this crate. |
…ec_version field Signed-off-by: m-brophy <mbrophy@redhat.com>
Hello @m-brophy , thanks for opening the PR. The addition of the My suggestion is to override the impl Validate for Bom {
fn validate(&self) -> ValidationResult {
self.validate_version(self.spec_version)
}
fn validate_version(&self, version: SpecVersion) -> ValidationResult { ... }
} This way, when calling |
Thanks, I've done that now |
@m-brophy , nice you were faster than me. 👍 Yes, that makes use of the spec version in the validate method then. |
We could probably make a serialization function that respects the BOM version field as well, but that can be added later in a semver-compatible way. So I'm OK with publishing a new version as-is. @justahero any objections to tagging v0.8.0 and publishing to crates.io? |
When trying to load CycloneDX files in rust using this library, calling parse_from_json (because we might get files of any spec version input) correctly detects the spec version and parses the json file.
However to validate the parsed bom returned, the
validate
method always validates against the default, v1.3. That means I have to callvalidate_version
and pass in the spec version of the file but there's no method to retrieve that from the parsed bom.This PR adds a spec_version field to the bom model so that the spec_version can be retrieved from the parsed bom and passed into
validate_version
as discussed on slack with @justahero