Skip to content

Commit

Permalink
fix: doesn't save dirVersion if sha1 doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen committed Mar 12, 2024
1 parent b6c2436 commit 5e95a39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pkg/crawler/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/aquasecurity/trivy-java-db/pkg/types"
)

const mavenRepoURL = "https://repo.maven.apache.org/maven2/"
const mavenRepoURL = "https://repo.maven.apache.org/maven2/academy/compose/companion/multi-fab/"

type Crawler struct {
dir string
Expand Down Expand Up @@ -230,10 +230,12 @@ func (c *Crawler) crawlSHA1(ctx context.Context, baseURL string, meta *Metadata,
return !bytes.Equal(v.SHA1, dirVersionSha1)
})

versions = append(versions, Version{
Version: dirVersion,
SHA1: dirVersionSha1,
})
if dirVersionSha1 != nil {
versions = append(versions, Version{
Version: dirVersion,
SHA1: dirVersionSha1,
})
}

foundVersions = append(foundVersions, versions...)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/crawler/testdata/abbot_abbot.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ <h1>abbot/abbot</h1>
<a href="0.12.3/" title="0.12.3/">0.12..../</a> 2005-09-20 05:44 -
<a href="0.13.0/" title="0.13.0/">0.13.0/</a> 2005-09-20 05:44 -
<a href="1.4.0/" title="1.4.0/">1.4.0/</a> 2015-09-22 16:03 -
<a href="1.5.0/" title="1.5.0/">1.5.0/</a> 2015-09-22 16:03 -
<a href="maven-metadata.xml" title="maven-metadata.xml">maven-metadata.xml</a> 2015-09-24 14:18 402
<a href="maven-metadata.xml.md5" title="maven-metadata.xml.md5">maven-metadata.xml.md5</a> 2015-09-24 14:18 32
<a href="maven-metadata.xml.sha1" title="maven-metadata.xml.sha1">maven-metadata.xml.sha1</a> 2015-09-24 14:18 40
Expand Down

0 comments on commit 5e95a39

Please sign in to comment.