Skip to content

Commit 67004a2

Browse files
fix(python): fixed panic when scan .egg archive (fanal#446)
Co-authored-by: Teppei Fukuda <[email protected]>
1 parent 528d07e commit 67004a2

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

analyzer/language/python/packaging/packaging.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ func (a packagingAnalyzer) Analyze(_ context.Context, input analyzer.AnalysisInp
5050
if err != nil {
5151
return nil, xerrors.Errorf("egg analysis error: %w", err)
5252
}
53+
if pkginfoInZip == nil { // Egg archive may not contain required files, then we will get nil. Skip this archives
54+
return nil, nil
55+
}
56+
5357
defer pkginfoInZip.Close()
58+
5459
r = pkginfoInZip
5560
}
5661

analyzer/language/python/packaging/packaging_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func Test_packagingAnalyzer_Analyze(t *testing.T) {
9797
},
9898
},
9999
},
100+
{
101+
name: "egg zip doesn't contain required files",
102+
inputFile: "testdata/no-required-files.egg",
103+
want: nil,
104+
},
100105
}
101106
for _, tt := range tests {
102107
t.Run(tt.name, func(t *testing.T) {
Binary file not shown.

0 commit comments

Comments
 (0)