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

cyclonedx_bom: make Cpe constructable #739

Closed
ModestMannfred opened this issue Jul 8, 2024 · 2 comments · Fixed by #758
Closed

cyclonedx_bom: make Cpe constructable #739

ModestMannfred opened this issue Jul 8, 2024 · 2 comments · Fixed by #758

Comments

@ModestMannfred
Copy link

The current implementation of Cpe in https://github.com/CycloneDX/cyclonedx-rust-cargo/blob/main/cyclonedx-bom/src/models/component.rs does not allow access to the member variable and provides no constructors. Some way to construct Cpes in applications which use the bom library should be provided.

eg.:
let cpe = Cpe(cpe_string);

Result:

note: constructor is not visible here due to private fields
   --> /home/scott/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cyclonedx-bom-0.4.3/src/models/component.rs:439:16
    |
439 | pub struct Cpe(pub(crate) String);
    |                ^^^^^^^^^^^^^^^^^ private field

We can implement, if you let us know if you prefer public member variable, a new constructor or conversion from String or &str, etc. Purl, for instance implements both new and FromStr

@ModestMannfred ModestMannfred changed the title cyclonedx_bom: make sCpe constructable cyclonedx_bom: make Cpe constructable Jul 8, 2024
@Shnatsel
Copy link
Contributor

Having both new() and FromStr sounds good to me. I'd be happy to merge a PR with this change.

@ModestMannfred
Copy link
Author

Ok, will do. But I need some time because I'm working on something else right now. Thanks!

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 a pull request may close this issue.

2 participants