-
Notifications
You must be signed in to change notification settings - Fork 75
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
Support Cargo Non-Flat Dependency Graph Using cargo tree #1377
base: master
Are you sure you want to change the base?
Conversation
.../java/com/blackduck/integration/detectable/detectables/cargo/CargoDependencyTransformer.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/blackduck/integration/detectable/detectables/cargo/CargoMetadataParser.java
Outdated
Show resolved
Hide resolved
...rc/main/java/com/blackduck/integration/detectable/detectables/cargo/CargoMetadataParser.java
Outdated
Show resolved
Hide resolved
.../java/com/blackduck/integration/detectable/detectables/cargo/CargoDependencyTransformer.java
Outdated
Show resolved
Hide resolved
.../java/com/blackduck/integration/detectable/detectables/cargo/CargoDependencyTransformer.java
Outdated
Show resolved
Hide resolved
@zahidblackduck I think the code is looking great. The only thing I can currently think of is perhaps for the CLI Detectable class. When we are deciding if things are extractable and are looking for the cargo executable it might make sense to also confirm that the version of cargo we have is capable of running the tree command. Also, once you finish manual testing it would be great to add some junits. |
cargo tree
cargo tree
@@ -23,6 +23,9 @@ | |||
### New features | |||
|
|||
* Support for Conda has been extended to 25.1.1. | |||
Here’s the revised line, following your requested format: |
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.
This feels like a comment that came over from a cut and paste?
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.
Oh, I see. I'll refactor. Thanks for pointing this out.
@@ -23,6 +23,8 @@ | |||
### New features | |||
|
|||
* Support for Conda has been extended to 25.1.1. | |||
* A new detector leveraging `cargo tree` to extract direct and transitive dependencies, improving accuracy over the previous flat-list detection. This build-based detector is triggered for Cargo projects with a `Cargo.toml` file and requires Cargo version **1.44.0+**. Falls back to the existing build-less approach if `cargo tree` is unavailable. |
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.
Suggestion for a few tweaks to add links to further documentation:
* Cargo CLI Detector, leveraging `cargo tree` to extract direct and transitive dependencies, improving accuracy over the previous flat-list detection. This build-based detector is triggered for Cargo projects with a `Cargo.toml` file and requires Cargo version **1.44.0+**. For further information, see [Cargo package manager support](packagemgrs/cargo.md).
* Added property [detect.cargo.path](properties/detectors/cargo.md) to allow user specification of a custom Cargo executable path.
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.
Okay @cpottsbd, I'll update accordingly. Thanks for the nice suggestion.
|
||
[detect_product_short] runs the Cargo detector if it finds either of the following files in your project: | ||
[detect_product_short] now includes two Cargo detectors: |
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.
I would remove the "now's" and "new's" from this information and leave that type of info for the release notes. (Since this part of the documentation lives on past the point where this detector is new.)
i.e.
[detect_product_short] includes two Cargo detectors:
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.
Yes, it seems quite logical.
|
||
* Cargo.toml | ||
* Cargo.lock | ||
* **Cargo CLI Detector** (New) |
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.
* **Cargo CLI Detector**
The Cargo detector extracts the project's name and version from the Cargo.toml file. If it does not find a Cargo.toml file, it will defer to values derived by Git, from the project's directory, or defaults. | ||
## Cargo CLI Detector | ||
|
||
A new cli detector for Cargo projects, which extracts **direct and transitive dependencies** using the `cargo tree` command. This improves the accuracy of dependency detection over the previous flat-list detection. |
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.
Suggestion:
Detector for Cargo projects, extracts **direct and transitive dependencies** using the
cargo treecommand.
A new cli detector for Cargo projects, which extracts **direct and transitive dependencies** using the `cargo tree` command. This improves the accuracy of dependency detection over the previous flat-list detection. | ||
|
||
**Requirements:** | ||
* Cargo version **1.44.0+** is required (as `cargo tree` was introduced in this version). |
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.
Suggestion:
- Cargo version 1.44.0+ is required (as
cargo tree
was introduced in this version).
to - Cargo version 1.44.0+ required to support
cargo tree
.
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.
See notes. Thanks.
The Cargo detector extracts the project's name and version from the Cargo.toml file. If it does not find a Cargo.toml file, it will defer to values derived by Git, from the project's directory, or defaults. | ||
## Cargo CLI Detector | ||
|
||
Detector for Cargo projects, extracts **direct and transitive dependencies** using the `cargo tree` command. |
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.
Sorry, one new thought. ; ) perhaps link to the man page for the cargo tree command here.
i.e.
* Detector for Cargo projects, extracts **direct and transitive dependencies** using the [cargo tree command](https://doc.rust-lang.org/cargo/commands/cargo-tree.html).
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.
Thanks. I've updated with the cargo tree documentation link.
Ticket
IDETECT-4634
Description
This MR introduces a build-based Cargo detector that utilizes the
cargo tree
command to extract direct and transitive dependency relationships, addressing the previous limitation where Cargo dependencies were detected as a flat list.The new implementation ensures backward compatibility by falling back to the existing build-less detector if
cargo tree
is unavailable. Additionally, it introduces support for thedetect.cargo.path
property, allowing users to specify a custom Cargo build tool path.Key Changes:
CargoCliDetectable
Class:cargo tree
to extract hierarchical dependency relationships.CargoDependencyGraphTransformer
to parsecargo tree
output into aDependencyGraph
.cargo tree
is unavailable.detect.cargo.path
to specify the Cargo build tool path.Acceptance Criteria Met:
cargo tree
.Cargo.toml
as the required file.detect.cargo.path
to configure the Cargo executable path.