-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rust): Support workspace.members parsing for Cargo.toml analysis (…
…#5285) Signed-off-by: knqyf263 <[email protected]> Co-authored-by: DmitriyLewen <[email protected]> Co-authored-by: knqyf263 <[email protected]>
- Loading branch information
1 parent
4df9363
commit 5924c02
Showing
6 changed files
with
299 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -382,6 +382,132 @@ func Test_cargoAnalyzer_Analyze(t *testing.T) { | |
dir: "testdata/sad", | ||
want: &analyzer.AnalysisResult{}, | ||
}, | ||
{ | ||
name: "workspace members", | ||
dir: "testdata/toml-workspace-members", | ||
want: &analyzer.AnalysisResult{ | ||
Applications: []types.Application{ | ||
{ | ||
Type: types.Cargo, | ||
FilePath: "Cargo.lock", | ||
Libraries: types.Packages{ | ||
{ | ||
ID: "[email protected]", | ||
Name: "aho-corasick", | ||
Version: "1.1.2", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 5, | ||
EndLine: 12, | ||
}, | ||
}, | ||
DependsOn: []string{"[email protected]"}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "gdb-command", | ||
Version: "0.7.6", | ||
Indirect: false, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 14, | ||
EndLine: 22, | ||
}, | ||
}, | ||
DependsOn: []string{ | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "libc", | ||
Version: "0.2.150", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 24, | ||
EndLine: 28, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "memchr", | ||
Version: "2.6.4", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 44, | ||
EndLine: 48, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "regex", | ||
Version: "1.10.2", | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 50, | ||
EndLine: 60, | ||
}, | ||
}, | ||
DependsOn: []string{ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "regex-automata", | ||
Version: "0.4.3", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 62, | ||
EndLine: 71, | ||
}, | ||
}, | ||
DependsOn: []string{ | ||
"[email protected]", | ||
"[email protected]", | ||
"[email protected]", | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "regex-syntax", | ||
Version: "0.8.2", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 73, | ||
EndLine: 77, | ||
}, | ||
}, | ||
}, | ||
{ | ||
ID: "[email protected]", | ||
Name: "wait-timeout", | ||
Version: "0.2.0", | ||
Indirect: true, | ||
Locations: []types.Location{ | ||
{ | ||
StartLine: 79, | ||
EndLine: 86, | ||
}, | ||
}, | ||
DependsOn: []string{"[email protected]"}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
|
86 changes: 86 additions & 0 deletions
86
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-workspace-members/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-workspace-members/Cargo.toml
This file contains 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,10 @@ | ||
[workspace.package] | ||
name = "toml-workspace-members" | ||
version = "0.1.0" | ||
|
||
[workspace] | ||
resolver = "2" | ||
members = ["member", "member2"] | ||
|
||
[workspace.dependencies] | ||
regex = "1" |
7 changes: 7 additions & 0 deletions
7
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-workspace-members/member/Cargo.toml
This file contains 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,7 @@ | ||
[package] | ||
name = "member" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
gdb-command = "0.7" |
7 changes: 7 additions & 0 deletions
7
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-workspace-members/member2/Cargo.toml
This file contains 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,7 @@ | ||
[package] | ||
edition = "2021" | ||
name = "member2" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
regex = { workspace = true} |