Skip to content

Commit

Permalink
RustyHog: improve description and file_path
Browse files Browse the repository at this point in the history
  • Loading branch information
valentijnscholten committed Dec 17, 2024
1 parent 81e650c commit 35ae569
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dojo/tools/rusty_hog/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ def __getitem(self, vulnerabilities, scanner):
found_secret_string = ""
cwe = 200
for vulnerability in vulnerabilities:
description =""

Check failure on line 79 in dojo/tools/rusty_hog/parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (E225)

dojo/tools/rusty_hog/parser.py:79:25: E225 Missing whitespace around operator
if vulnerability.get("Reason") is not None:
description += "\n**Reason:** {}".format(
vulnerability.get("reason"),
)
if scanner == "Rusty Hog":
break
if scanner == "Choctaw Hog":
Expand Down Expand Up @@ -179,10 +184,15 @@ def __getitem(self, vulnerabilities, scanner):
vulnerability.get("issue_id"),
vulnerability.get("location"),
)
if not file_path:
file_path = vulnerability.get("url")
elif scanner == "Essex Hog":
title = "{} found in Confluence Page ID {}".format(
vulnerability.get("reason"), vulnerability.get("page_id"),
)
if not file_path:
file_path = vulnerability.get("url")

# create the finding object
finding = Finding(
title=title,
Expand Down
3 changes: 3 additions & 0 deletions unittests/tools/test_rusty_hog_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def test_parse_file_with_multiple_vuln_has_multiple_finding_essexhog(self):
parser = RustyhogParser()
findings = parser.get_items(testfile, "Essex Hog", Test())
self.assertEqual(3, len(findings))
self.assertEqual("https://confluence.com/pages/viewpage.action?pageId=12345", findings[0]['file_path'])

Check failure on line 113 in unittests/tools/test_rusty_hog_parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (Q000)

unittests/tools/test_rusty_hog_parser.py:113:103: Q000 Single quotes found but double quotes preferred
self.assertEqual("-----BEGIN EC PRIVATE KEY-----", findings[0]['payload'])

Check failure on line 114 in unittests/tools/test_rusty_hog_parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (Q000)

unittests/tools/test_rusty_hog_parser.py:114:76: Q000 Single quotes found but double quotes preferred
self.assertEqual("*Reason:**SSH (EC) private key", findings[0]['description'][:30])

Check failure on line 115 in unittests/tools/test_rusty_hog_parser.py

View workflow job for this annotation

GitHub Actions / ruff-linting

Ruff (Q000)

unittests/tools/test_rusty_hog_parser.py:115:76: Q000 Single quotes found but double quotes preferred

def test_parse_file_with_multiple_vuln_has_multiple_finding_essexhog_content(self):
with open("unittests/scans/rusty_hog/essexhog_many_vulns.json", encoding="utf-8") as testfile:
Expand Down

0 comments on commit 35ae569

Please sign in to comment.