Merge ~alexmurray/ubuntu-cve-tracker:check-cves-ignore-based-on-urlref-regex into ubuntu-cve-tracker:master

Proposed by Alex Murray
Status: Merged
Merged at revision: d33673a1b33549c7012f7933de00c414c3327f73
Proposed branch: ~alexmurray/ubuntu-cve-tracker:check-cves-ignore-based-on-urlref-regex
Merge into: ubuntu-cve-tracker:master
Diff against target: 49 lines (+19/-2)
1 file modified
scripts/check-cves (+19/-2)
Reviewer Review Type Date Requested Status
Marc Deslauriers Approve
Review via email: mp+466119@code.launchpad.net

Commit message

scripts/check-cves: add support for ignoring CVEs based on ref URLs

Wordpress Plugin CVEs seem to be reported by the same CNA so support matching
their URL prefix to ignore these common CVEs.

I have tested this during CVE triage today and it seems to work well and is a
great time saver.

Signed-off-by: Alex Murray <email address hidden>

To post a comment you must log in.
Revision history for this message
Alex Murray (alexmurray) wrote :

Anyone want to take a look at this? The change is small so should be easy to review - I've been using it during CVE triage this week and it has been really useful FWIW.

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

LGTM, ack, thanks!

review: Approve
Revision history for this message
Seth Arnold (seth-arnold) wrote :

Does this 'feel' slow while using it? it looks a bit like it recompiles every regex on every cve, and I'm wondering if it would make sense to explicitly compile these first, or write one complex regex that matches all of these and compile that one, to skip repeated executions. (At least, I didn't quickly spot a python version of https://docs.rs/regex/latest/regex/struct.RegexSet.html that could do this easily for you.)

Revision history for this message
Alex Murray (alexmurray) wrote :

@seth-arnold - I didn't notice any performance impact but I agree that we should ideally be pre-compiling these. Also they should probably be stored in a separate "configuration" file to allow easily adding new ones during the CVE triage process.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/check-cves b/scripts/check-cves
2index c49011c..2cc026d 100755
3--- a/scripts/check-cves
4+++ b/scripts/check-cves
5@@ -118,6 +118,14 @@ IGNORE_STRINGS = [
6 "Oracle Enterprise Manager", "F5 BIG-IP", "Adobe Acrobat and Reader"
7 ]
8
9+IGNORE_URLS = {
10+ "https://patchstack.com/database/vulnerability/.*/wordpress.*": "WordPress Plugin",
11+ "https://www.wordfence.com/threat-intel/vulnerabilities/id/.*?source=cve": "WordPress Plugin",
12+ "https://wpscan.com/vulnerability/.*": "WordPress Plugin",
13+ "https://www.zyxel.com/global/en/support/security-advisories/.*": "Zyxel",
14+ "https://www.manageengine.com/.*": "Zoho ManageEngine",
15+ "https://www.qnap.com/en/security-advisory/.*": "QNAP",
16+}
17
18 def merge_list(list1, list2, intersection=None):
19 """Write the union of list and list2 into list. If intersection is not
20@@ -980,10 +988,19 @@ class CVEHandler(xml.sax.handler.ContentHandler):
21 words = self.get_software_hints_from_cve_description(self.cve_data[cve]['desc'])
22 if action == 'skip':
23 # try and hint if any of the references use a URL that is within
24- # a known packages Homepage from HOMEPAGES_MAP
25+ # a known packages Homepage from HOMEPAGES_MAP or within
26+ # IGNORE_URLS
27 if 'refs' in self.cve_data[cve]:
28 for ref in self.cve_data[cve]['refs']:
29 url = ref[2]
30+ for url_re in IGNORE_URLS:
31+ if re.search(url_re, url):
32+ print(f"Detected URL: {url} matches {url_re}")
33+ action = 'ignore'
34+ reason = IGNORE_URLS[url_re]
35+ break
36+ if action == 'ignore':
37+ break
38 for srcpkg in HOMEPAGES_MAP:
39 for homepage in HOMEPAGES_MAP[srcpkg]:
40 # TODO: do smarter matching than this
41@@ -997,7 +1014,7 @@ class CVEHandler(xml.sax.handler.ContentHandler):
42 # otherwise it will likely confuse the human doing CVE triage to
43 # suggest a package name that doesn't actually exist
44 hints = words & allsrcs
45- if len(hints) > 0:
46+ if len(hints) > 0 and action != "ignore":
47 packages = []
48 for hint in hints:
49 # use preferred name of package instead of the one that matched

Subscribers

People subscribed via source and target branches