-
-
Notifications
You must be signed in to change notification settings - Fork 625
Fixes #4581: Failure to scan cargo #4582
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
Merged
AyanSinhaMahapatra
merged 6 commits into
aboutcode-org:develop
from
omsuneri:resolving-4581
Nov 25, 2025
+168
−8
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
210c91e
fix: prevent 'NoneType' error when scanning single Cargo.toml files
omsuneri 84034f9
fix: use cached parent resource instead of redundant parent() call
omsuneri ee7f8e4
Add regression test for single Cargo.toml file scan
omsuneri b09b68b
refactor: remove unnecessary portion of test file Cargo.toml
omsuneri 5249967
refactor: test with a full --package scan
omsuneri 58e2e2b
refactor: removing header from the ```cargo.toml.expected```
omsuneri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [package] | ||
| name = "constant_time_eq" | ||
| version = "0.4.2" | ||
| edition = "2024" | ||
| authors = ["Cesar Eduardo Barros <cesarb@cesarb.eti.br>"] | ||
| description = "Compares two equal-sized byte strings in constant time." | ||
| documentation = "https://docs.rs/constant_time_eq" | ||
| repository = "https://github.com/cesarb/constant_time_eq" | ||
| readme = "README" | ||
| keywords = ["constant_time"] | ||
| categories = ["cryptography", "no-std"] | ||
| license = "CC0-1.0 OR MIT-0 OR Apache-2.0" | ||
| rust-version = "1.85.0" | ||
|
|
||
| [dev-dependencies] | ||
| criterion = { version = "0.5.1", features = ["cargo_bench_support", "html_reports"] } | ||
| count_instructions = "0.2.0" |
126 changes: 126 additions & 0 deletions
126
tests/packagedcode/data/cargo/cargo_toml/single-file-scan/Cargo.toml.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| { | ||
| "packages": [], | ||
| "dependencies": [], | ||
| "files": [ | ||
| { | ||
| "path": "Cargo.toml", | ||
| "type": "file", | ||
| "package_data": [ | ||
| { | ||
| "type": "cargo", | ||
| "namespace": null, | ||
| "name": "constant_time_eq", | ||
| "version": "0.4.2", | ||
| "qualifiers": {}, | ||
| "subpath": null, | ||
| "primary_language": "Rust", | ||
| "description": "Compares two equal-sized byte strings in constant time.", | ||
| "release_date": null, | ||
| "parties": [ | ||
| { | ||
| "type": "person", | ||
| "role": "author", | ||
| "name": "Cesar Eduardo Barros", | ||
| "email": "cesarb@cesarb.eti.br", | ||
| "url": null | ||
| } | ||
| ], | ||
| "keywords": [ | ||
| "constant_time", | ||
| "cryptography", | ||
| "no-std" | ||
| ], | ||
| "homepage_url": null, | ||
| "download_url": null, | ||
| "size": null, | ||
| "sha1": null, | ||
| "md5": null, | ||
| "sha256": null, | ||
| "sha512": null, | ||
| "bug_tracking_url": null, | ||
| "code_view_url": null, | ||
| "vcs_url": "https://github.com/cesarb/constant_time_eq", | ||
| "copyright": null, | ||
| "holder": null, | ||
| "declared_license_expression": "cc0-1.0 OR mit-0 OR apache-2.0", | ||
| "declared_license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0", | ||
| "license_detections": [ | ||
| { | ||
| "license_expression": "cc0-1.0 OR mit-0 OR apache-2.0", | ||
| "license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0", | ||
| "matches": [ | ||
| { | ||
| "license_expression": "cc0-1.0 OR mit-0 OR apache-2.0", | ||
| "license_expression_spdx": "CC0-1.0 OR MIT-0 OR Apache-2.0", | ||
| "from_file": "Cargo.toml", | ||
| "start_line": 1, | ||
| "end_line": 1, | ||
| "matcher": "1-spdx-id", | ||
| "score": 100.0, | ||
| "matched_length": 10, | ||
| "match_coverage": 100.0, | ||
| "rule_relevance": 100, | ||
| "rule_identifier": "spdx-license-identifier-cc0_1_0_or_mit_0_or_apache_2_0-f44a2ec174eb034bd3c662f728664281e507b20d", | ||
| "rule_url": null, | ||
| "matched_text": "CC0-1.0 OR MIT-0 OR Apache-2.0" | ||
| } | ||
| ], | ||
| "identifier": "cc0_1_0_or_mit_0_or_apache_2_0-3f14dd48-7cd8-cf28-d4e1-3b0174a587ee" | ||
| } | ||
| ], | ||
| "other_license_expression": null, | ||
| "other_license_expression_spdx": null, | ||
| "other_license_detections": [], | ||
| "extracted_license_statement": "CC0-1.0 OR MIT-0 OR Apache-2.0", | ||
| "notice_text": null, | ||
| "source_packages": [], | ||
| "file_references": [], | ||
| "is_private": false, | ||
| "is_virtual": false, | ||
| "extra_data": { | ||
| "documentation_url": "https://docs.rs/constant_time_eq", | ||
| "rust_version": "1.85.0", | ||
| "rust_edition": "2024" | ||
| }, | ||
| "dependencies": [ | ||
| { | ||
| "purl": "pkg:cargo/criterion", | ||
| "extracted_requirement": "0.5.1", | ||
| "scope": "dev-dependencies", | ||
| "is_runtime": false, | ||
| "is_optional": false, | ||
| "is_pinned": false, | ||
| "is_direct": true, | ||
| "resolved_package": {}, | ||
| "extra_data": { | ||
| "version": "0.5.1", | ||
| "features": [ | ||
| "cargo_bench_support", | ||
| "html_reports" | ||
| ] | ||
| } | ||
| }, | ||
| { | ||
| "purl": "pkg:cargo/count_instructions", | ||
| "extracted_requirement": "0.2.0", | ||
| "scope": "dev-dependencies", | ||
| "is_runtime": false, | ||
| "is_optional": false, | ||
| "is_pinned": false, | ||
| "is_direct": true, | ||
| "resolved_package": {}, | ||
| "extra_data": {} | ||
| } | ||
| ], | ||
| "repository_homepage_url": "https://crates.io/crates/constant_time_eq", | ||
| "repository_download_url": "https://crates.io/api/v1/crates/constant_time_eq/0.4.2/download", | ||
| "api_data_url": "https://crates.io/api/v1/crates/constant_time_eq", | ||
| "datasource_id": "cargo_toml", | ||
| "purl": "pkg:cargo/constant_time_eq@0.4.2" | ||
| } | ||
| ], | ||
| "for_packages": [], | ||
| "scan_errors": [] | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 just noticed, we are not returning top-level packages for single-manifest cargo scans, which is not right. This isn't introduced by your changes of course but is a bug which was present already.
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 will fix this in a seperate PR as this requires a bit more looking into use of assembly elsewhere.