Skip to content

Commit

Permalink
fix: decoding null apk metadata pullDependencies (#1614)
Browse files Browse the repository at this point in the history
Signed-off-by: Keith Zantow <kzantow@gmail.com>
  • Loading branch information
kzantow committed Feb 23, 2023
1 parent abfec62 commit 5e8aa4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions syft/pkg/apk_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func (a *spaceDelimitedStringSlice) UnmarshalJSON(data []byte) error {
}
*a = s
return nil
case nil:
return nil
default:
return fmt.Errorf("invalid type for string array: %T", obj)
}
Expand Down
9 changes: 9 additions & 0 deletions syft/pkg/apk_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ func TestApkMetadata_UnmarshalJSON(t *testing.T) {
Files: []ApkFileRecord{{Path: "/usr"}},
},
},
{
name: "null pullDependencies",
input: `{
"pullDependencies": null
}`,
want: ApkMetadata{
Dependencies: nil,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 5e8aa4d

Please sign in to comment.