mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 16:06:36 +01:00
Use reader when scanning for package versions over reading entire binary into memory (#3558)
* use streaming readers Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * replace redis search patterns Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> * address PR feedback Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
@@ -262,12 +262,11 @@ func (c *goBinaryCataloger) findMainModuleVersion(metadata *pkg.GolangBinaryBuil
|
||||
}
|
||||
|
||||
func extractVersionFromContents(reader io.Reader) string {
|
||||
contents, err := io.ReadAll(reader)
|
||||
matchMetadata, err := internal.MatchNamedCaptureGroupsFromReader(semverPattern, reader)
|
||||
if err != nil {
|
||||
log.WithFields("error", err).Trace("unable to read from go binary reader")
|
||||
log.WithFields("error", err).Trace("unable to extract version from go binary reader")
|
||||
return ""
|
||||
}
|
||||
matchMetadata := internal.MatchNamedCaptureGroups(semverPattern, string(contents))
|
||||
|
||||
version, ok := matchMetadata["version"]
|
||||
if ok {
|
||||
|
||||
Reference in New Issue
Block a user