-
Notifications
You must be signed in to change notification settings - Fork 590
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
False flagging #800
Comments
Nice catch @cpendery - I guess this is another case of the CPE being too losely formed since
Is there another CPE generated that's something like Can you add the CPE generated that's resulting in this bad match? |
@spiffcs here are the cpes. It looks like the last one is the one causing the bad match
|
Based on my analysis of the database, there will never be a case where the vendor and the product have the same name. In addition, viewing the cpe database from NVD shows that the same is true for all cpes in the database. As a result, I think we can safely remove the case where the vendor and product name are identical, which will resolve this false positive. I'll make a PR and link this issue in Syft DB scriptimport sqlite3
import re
import json
con = sqlite3.connect("vulnerability.db")
cur = con.cursor()
cur.execute("SELECT v.id, v.cpes FROM vulnerability as v;")
results = cur.fetchall()
cur.close()
match_regex = re.compile(rf".*:([A-z_]+):([A-z_]+)")
for result_id, cpes_str in results:
if cpes_str == "null":
continuefrom bs4 import BeautifulSoup
soup = BeautifulSoup(html_doc, 'html.parser')
cpes = json.loads(cpes_str)
for cpe in cpes:
matches = match_regex.findall(cpe)
if len(matches) == 2 and matches[0] == matches[1]:
print(cpe, result_id) Dictionary scriptimport xml.etree.ElementTree as ET
import re
match_regex = re.compile(rf".*:([A-z_]+):([A-z_]+)")
with open("official-cpe-dictionary_v2.3.xml", "r", encoding="utf-8") as input_file:
tree = ET.parse(input_file)
root = tree.getroot()
for child in root:
if "cpe-item" in child.tag:
for item in child.items():
if len(item) == 2 and item[0] == "name":
matches = match_regex.findall(item[1])
if len(matches) == 2 and matches[0] == matches[1]:
print(item[1]) |
As @westonsteimel pointed out, the cpe dictionary isn't cumulative, so I missed cases where this does in fact occur, closed the pr as it isn't a fix for the issue and worsens overall accuracy and will look for other potential fixes |
What happened:
Grype is shadowing the Redis databases's vulnerabilities over the pypi redis package
What you expected to happen:
No vulnerabilities should be reported since the package isn't vulnerable.
How to reproduce it (as minimally and precisely as possible):
File
Command
Output
Anything else we need to know?:
Environment:
grype version
:40.0
cat /etc/os-release
or similar):The text was updated successfully, but these errors were encountered: