Skip to content

Commit

Permalink
add app nil check (#5274)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Oct 1, 2023
1 parent c5ae9f2 commit 1840584
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/fanal/analyzer/language/dotnet/nuget/nuget.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func (a *nugetLibraryAnalyzer) PostAnalyze(_ context.Context, input analyzer.Pos
return xerrors.Errorf("NuGet parse error: %w", err)
}

// nuget file doesn't contain dependencies
if app == nil {
return nil
}

for i, lib := range app.Libraries {
license, ok := foundLicenses[lib.ID]
if !ok {
Expand Down
16 changes: 16 additions & 0 deletions pkg/fanal/analyzer/language/dotnet/nuget/nuget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,22 @@ func Test_nugetibraryAnalyzer_Analyze(t *testing.T) {
},
},
},
{
name: "happy path lock file without dependencies.",
dir: "testdata/lock-without-deps",
env: map[string]string{
"HOME": "testdata/repository",
},
want: &analyzer.AnalysisResult{},
},
{
name: "sad path",
dir: "testdata/sad",
env: map[string]string{
"HOME": "testdata/repository",
},
want: &analyzer.AnalysisResult{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 1,
"dependencies": {
"net6.0": {}
}
}

0 comments on commit 1840584

Please sign in to comment.