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

RustyHog: improve description and file_path #11433

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
14 changes: 13 additions & 1 deletion docs/content/en/open_source/upgrading/2.42.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ toc_hide: true
weight: -20241202
description: No special instructions.
---
There are no special instructions for upgrading to 2.42.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.42.0) for the contents of the release.

**Hash Code changes**
The Rusty Hog parser has been [updated](https://github.com/DefectDojo/django-DefectDojo/pull/11433) to populate more fields. Some of these fields are part of the hash code calculation. To recalculate the hash code please execute the following command:
valentijnscholten marked this conversation as resolved.
Show resolved Hide resolved

`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Horusec Scan" --hash_code_only`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Qualys Hacker Guardian Scan --hash_code_only"`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Red Hat Satellite --hash_code_only"`

This command has various command line arguments to tweak its behaviour, for example to trigger a run of the deduplication process.
See [dedupe.py](https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/management/commands/dedupe.py) for more information.

Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.42.0) for the contents of the release.

14 changes: 13 additions & 1 deletion docs/content/en/open_source/upgrading/2.43.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,16 @@ description: Disclaimer field renamed/split.

[Pull request #10902](https://github.com/DefectDojo/django-DefectDojo/pull/10902) introduced different kinds of disclaimers within the DefectDojo instance. The original content of the disclaimer was copied to all new fields where it had been used until now (so this change does not require any action on the user's side). However, if users were managing the original disclaimer via API (endpoint `/api/v2/system_settings/1/`, field `disclaimer`), be aware that the fields are now called `disclaimer_notifications` and `disclaimer_reports` (plus there is one additional, previously unused field called `disclaimer_notes`).

But there are no other special instructions for upgrading to 2.43.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.43.0) for the contents of the release.
**Hash Code changes**
The Rusty Hog parser has been [updated](https://github.com/DefectDojo/django-DefectDojo/pull/11433) to populate more fields. Some of these fields are part of the hash code calculation. To recalculate the hash code and deduplicate existing Rusty Hog findings, please execute the following command:

`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Essex Hog Scan (Rusty Hog Scan)" --hash_code_only`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Essex Hog Scan (Choctaw Hog)" --hash_code_only`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Essex Hog Scan (Duroc Hog)" --hash_code_only`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Essex Hog Scan (Gottingen Hog)" --hash_code_only`
`docker compose exec uwsgi /bin/bash -c "python manage.py dedupe.py --parser "Essex Hog Scan (Essex Hog)" --hash_code_only`

This command has various command line arguments to tweak its behaviour, for example to trigger a run of the deduplication process.
See [dedupe.py](https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/management/commands/dedupe.py) for more information.

Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.43.0) for the contents of the release.
26 changes: 18 additions & 8 deletions dojo/tools/rusty_hog/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ def __getitem(self, vulnerabilities, scanner):
found_secret_string = ""
cwe = 200
for vulnerability in vulnerabilities:
description = ""
if vulnerability.get("reason") is not None:
description += "\n**Reason:** {}".format(
vulnerability.get("reason"),
)
if scanner == "Rusty Hog":
break
if scanner == "Choctaw Hog":
"""Choctaw Hog"""
found_secret_string = vulnerability.get("stringsFound")
description = f"**This string was found:** {found_secret_string}"
found_secret_string = str(vulnerability.get("stringsFound") or "")
description += f"**This string was found:** {found_secret_string}"
if vulnerability.get("commit") is not None:
description += "\n**Commit message:** {}".format(
vulnerability.get("commit"),
Expand Down Expand Up @@ -116,8 +121,8 @@ def __getitem(self, vulnerabilities, scanner):
)
elif scanner == "Duroc Hog":
"""Duroc Hog"""
found_secret_string = vulnerability.get("stringsFound")
description = f"**This string was found:** {found_secret_string}"
found_secret_string = str(vulnerability.get("stringsFound") or "")
description += f"**This string was found:** {found_secret_string}"
if vulnerability.get("path") is not None:
description += "\n**Path of Issue:** {}".format(
vulnerability.get("path"),
Expand All @@ -132,8 +137,8 @@ def __getitem(self, vulnerabilities, scanner):
)
elif scanner == "Gottingen Hog":
"""Gottingen Hog"""
found_secret_string = vulnerability.get("stringsFound")
description = f"**This string was found:** {found_secret_string}"
found_secret_string = str(vulnerability.get("stringsFound") or "")
description += f"**This string was found:** {found_secret_string}"
if vulnerability.get("issue_id") is not None:
description += "\n**JIRA Issue ID:** {}".format(
vulnerability.get("issue_id"),
Expand All @@ -147,8 +152,8 @@ def __getitem(self, vulnerabilities, scanner):
vulnerability.get("url"), vulnerability.get("url"),
)
elif scanner == "Essex Hog":
found_secret_string = vulnerability.get("stringsFound")
description = f"**This string was found:** {found_secret_string}"
found_secret_string = str(vulnerability.get("stringsFound") or "")
description += f"**This string was found:** {found_secret_string}"
if vulnerability.get("page_id") is not None:
description += "\n**Confluence URL:** [{}]({})".format(
vulnerability.get("url"), vulnerability.get("url"),
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)
self.assertEqual("['-----BEGIN EC PRIVATE KEY-----']", findings[0].payload)
self.assertEqual("**Reason:** SSH (EC) private key", findings[0].description[:32])

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
Loading