-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rust): fix panic when 'dependencies' field is not used in cargo.t…
…oml (#3997)
- Loading branch information
1 parent
c8283ce
commit a119ef8
Showing
4 changed files
with
51 additions
and
2 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 |
---|---|---|
|
@@ -92,6 +92,27 @@ func Test_cargoAnalyzer_Analyze(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
name: "Cargo.toml doesn't include `Dependencies` field", | ||
dir: "testdata/toml-only-workspace-deps", | ||
want: &analyzer.AnalysisResult{ | ||
Applications: []types.Application{ | ||
{ | ||
Type: types.Cargo, | ||
FilePath: "Cargo.lock", | ||
Libraries: []types.Package{ | ||
{ | ||
ID: "[email protected]", | ||
Name: "memchr", | ||
Version: "2.5.0", | ||
Indirect: false, | ||
Locations: []types.Location{{StartLine: 11, EndLine: 15}}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "no Cargo.toml", | ||
dir: "testdata/no-cargo-toml", | ||
|
15 changes: 15 additions & 0 deletions
15
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-only-workspace-deps/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
pkg/fanal/analyzer/language/rust/cargo/testdata/toml-only-workspace-deps/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,9 @@ | ||
[package] | ||
name = "app" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[workspace.dependencies] | ||
memchr = "2.5" |