Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add leniancy to the version matching for debian to account for versio… #328

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion scan/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,19 +592,28 @@ func (o *debian) parseChangelog(changelog string,
cveRe := regexp.MustCompile(`(CVE-\d{4}-\d{4,})`)
stopRe := regexp.MustCompile(fmt.Sprintf(`\(%s\)`, regexp.QuoteMeta(versionOrLater)))
stopLineFound := false
leniantStopLineFound := false
versionOrLaterLeniant := versionOrLater
if i := strings.IndexRune(versionOrLaterLeniant, '+'); i >= 0 {
versionOrLaterLeniant = versionOrLaterLeniant[:i]
}
leniantRe := regexp.MustCompile(fmt.Sprintf(`\(%s\)`, regexp.QuoteMeta(versionOrLaterLeniant)))
lines := strings.Split(changelog, "\n")
for _, line := range lines {
if matche := stopRe.MatchString(line); matche {
// o.log.Debugf("Found the stop line: %s", line)
stopLineFound = true
break
} else if matchel := leniantRe.MatchString(line); matchel {
leniantStopLineFound = true
break
} else if matches := cveRe.FindAllString(line, -1); 0 < len(matches) {
for _, m := range matches {
cveIDs = util.AppendIfMissing(cveIDs, m)
}
}
}
if !stopLineFound {
if !stopLineFound && !leniantStopLineFound {
return []string{}, fmt.Errorf(
"Failed to scan CVE IDs. The version is not in changelog. name: %s, version: %s",
packName,
Expand Down