File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,9 @@ func (h gomodMergeHook) Hook(blob *types.BlobInfo) error {
32
32
if file == types .GoMod && lessThanGo117 (app ) {
33
33
// e.g. /app/go.mod => /app/go.sum
34
34
gosumFile := filepath .Join (dir , types .GoSum )
35
- gosum := findGoSum (gosumFile , blob .Applications )
36
- mergeGoSum (& app , gosum )
35
+ if gosum := findGoSum (gosumFile , blob .Applications ); gosum != nil {
36
+ mergeGoSum (& app , gosum )
37
+ }
37
38
}
38
39
}
39
40
apps = append (apps , app )
Original file line number Diff line number Diff line change @@ -154,6 +154,45 @@ func Test_gomodMergeHook_Hook(t *testing.T) {
154
154
},
155
155
},
156
156
},
157
+ {
158
+ name : "Go 1.16 and go.sum is not found" ,
159
+ blob : & types.BlobInfo {
160
+ Applications : []types.Application {
161
+ {
162
+ Type : types .GoModule ,
163
+ FilePath : "/app/go.mod" ,
164
+ Libraries : []types.Package {
165
+ {
166
+ Name : "github.com/aquasecurity/go-dep-parser" ,
167
+ Version : "v0.0.0-20220412145205-d0501f906d90" ,
168
+ },
169
+ {
170
+ Name : "github.com/aws/aws-sdk-go" ,
171
+ Version : "v1.43.31" ,
172
+ },
173
+ },
174
+ },
175
+ },
176
+ },
177
+ want : & types.BlobInfo {
178
+ Applications : []types.Application {
179
+ {
180
+ Type : types .GoModule ,
181
+ FilePath : "/app/go.mod" ,
182
+ Libraries : []types.Package {
183
+ {
184
+ Name : "github.com/aquasecurity/go-dep-parser" ,
185
+ Version : "v0.0.0-20220412145205-d0501f906d90" ,
186
+ },
187
+ {
188
+ Name : "github.com/aws/aws-sdk-go" ,
189
+ Version : "v1.43.31" ,
190
+ },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ },
157
196
}
158
197
for _ , tt := range tests {
159
198
t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments