mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
limit update version string length (#61)
This commit is contained in:
parent
1891972748
commit
bfca4d9e62
2 changed files with 11 additions and 0 deletions
|
@ -64,5 +64,9 @@ func fetchLatestApplicationVersion() (*hashiVersion.Version, error) {
|
|||
}
|
||||
|
||||
versionStr := strings.TrimSuffix(string(versionBytes), "\n")
|
||||
if len(versionStr) > 50 {
|
||||
return nil, fmt.Errorf("version too long: %q", versionStr[:50])
|
||||
}
|
||||
|
||||
return hashiVersion.NewVersion(versionStr)
|
||||
}
|
||||
|
|
|
@ -168,6 +168,13 @@ func TestFetchLatestApplicationVersion(t *testing.T) {
|
|||
expected: nil,
|
||||
err: true,
|
||||
},
|
||||
{
|
||||
name: "too long",
|
||||
response: "this is really long this is really long this is really long this is really long this is really long this is really long this is really long this is really long ",
|
||||
code: 200,
|
||||
expected: nil,
|
||||
err: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
Loading…
Reference in a new issue