Commit bb2455a
fix(cargo): resolve workspace-inherited license in Cargo.toml (#486)
## Summary
- Detect Cargo workspace license inheritance (`license = { workspace =
true }`) via `tomlj`'s `get()` method and resolve from
`workspace.package.license`
- Follows the existing version workspace resolution pattern in
`parseCargoToml()`
- Adds two new test cases: successful resolution and graceful null
fallback
Fixes: [TC-4528](https://redhat.atlassian.net/browse/TC-4528)
Implements: [TC-4531](https://redhat.atlassian.net/browse/TC-4531)
## Test plan
- [x] New test: workspace license inheritance resolves to "Apache-2.0"
- [x] New test: workspace inheritance with no license in workspace
section returns null
- [x] All 4 CargoProviderLicenseTest tests pass (0 failures)
- [x] All 358 tests pass (3 pre-existing GoModulesMainModuleVersionTest
failures unrelated to this change)
- [x] Spotless formatting applied
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[TC-4528]:
https://redhat.atlassian.net/browse/TC-4528?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
[TC-4531]:
https://redhat.atlassian.net/browse/TC-4531?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
## Summary by Sourcery
Handle Cargo workspace-inherited licenses when reading Cargo.toml
manifests.
New Features:
- Support reading licenses inherited from Cargo workspaces via the
package license workspace setting.
Tests:
- Add tests covering successful workspace license inheritance and null
fallback when no workspace license is defined.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 79232da commit bb2455a
4 files changed
Lines changed: 49 additions & 1 deletion
File tree
- src
- main/java/io/github/guacsec/trustifyda/providers
- test
- java/io/github/guacsec/trustifyda/providers
- resources/tst_manifests/cargo/license
- cargo_workspace_license_inheritance_no_license
- cargo_workspace_license_inheritance
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| |||
671 | 674 | | |
672 | 675 | | |
673 | 676 | | |
674 | | - | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
675 | 687 | | |
676 | 688 | | |
677 | 689 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
57 | 73 | | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments