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

Refactor mobsf parser for v4 reports #11056

Merged
merged 33 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a537b2c
Refactor mobsf parser for v4 reports
Oct 12, 2024
61e1b97
Refactor mobsf parser for v4 reports
Oct 12, 2024
1f98a0e
Refactor mobsf parser for v4 reports
Oct 12, 2024
45c33c3
Refactor mobsf parser for v4 reports
Oct 12, 2024
6a8201d
Refactor mobsf parser for v4 reports
Oct 13, 2024
a6bd140
Refactor mobsf parser for v4 reports
Oct 14, 2024
5d0a056
Refactor mobsf parser for v4 reports
Oct 14, 2024
572eb15
Refactor mobsf parser for v4 reports
Oct 15, 2024
1e20516
Refactor mobsf parser for v4 reports
Oct 15, 2024
dce3ee2
Refactor mobsf parser for v4 reports
Oct 15, 2024
aa8d9de
Refactor mobsf parser for v4 reports
Oct 15, 2024
c34958e
Refactor mobsf parser for v4 reports
Oct 16, 2024
3d091f5
Refactor mobsf parser for v4 reports
Oct 16, 2024
8abf29f
Separate old and new mobsf parsers
Oct 27, 2024
dc19a3a
Separate old and new mobsf parsers
Oct 27, 2024
83d22bb
Separate old and new mobsf parsers
Oct 27, 2024
f21b82e
Separate old and new mobsf parsers
Oct 27, 2024
f157d22
Fix settings sha256sum
Oct 29, 2024
e5bdc21
Fix settings sha256sum
Oct 29, 2024
d6b67f4
Fix settings sha256sum
Oct 29, 2024
523f47f
Merge branch 'dev' into fix_parser_for_mobsf4
dmarushkin Oct 29, 2024
02921be
Fix settings sha256sum
Oct 29, 2024
17a97c2
Fix settings sha256sum
Oct 31, 2024
64c3b8e
Fix lost old parser
Nov 2, 2024
eaa5d27
Fix path to sample reports
Nov 2, 2024
241e102
Merge branch 'dev' into fix_parser_for_mobsf4
dmarushkin Nov 7, 2024
f1dea1b
fix md5 again
Nov 7, 2024
35fab29
Some extra fixes after review
Nov 8, 2024
7ad5874
Some extra fixes after review
Nov 8, 2024
ba30820
Some extra fixes after review
Nov 8, 2024
6739285
Merge branch 'dev' into fix_parser_for_mobsf4
dmarushkin Nov 13, 2024
f91193f
Fix md5
Nov 13, 2024
2f614e0
Fix md5
Nov 13, 2024
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
8 changes: 8 additions & 0 deletions docs/content/en/integrations/parsers/file/mobsf_scorecard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: "MobSF Scorecard Scanner"
toc_hide: true
---
Export a JSON file using the API, api/v1/report_json.

### Sample Scan Data
Sample MobSF Scorecard Scanner scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/mobsf_scorecard).
2 changes: 1 addition & 1 deletion dojo/settings/.settings.dist.py.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6b9365d002880ae64ab54da905ede076db5a8661960f8f1e2793b7f4d25ff7e8
97583d4261240a4363d91cb2affffa34df80bd449cc4a5c0ab1ab6cb9b7d0e6a
2 changes: 2 additions & 0 deletions dojo/settings/settings.dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,7 @@ def saml2_attrib_map_format(dict):
"HCLAppScan XML": ["title", "description"],
"KICS Scan": ["file_path", "line", "severity", "description", "title"],
"MobSF Scan": ["title", "description", "severity"],
"MobSF Scorecard Scan": ["title", "description", "severity"],
"OSV Scan": ["title", "description", "severity"],
"Snyk Code Scan": ["vuln_id_from_tool", "file_path"],
"Deepfence Threatmapper Report": ["title", "description", "severity"],
Expand Down Expand Up @@ -1505,6 +1506,7 @@ def saml2_attrib_map_format(dict):
"HCLAppScan XML": DEDUPE_ALGO_HASH_CODE,
"KICS Scan": DEDUPE_ALGO_HASH_CODE,
"MobSF Scan": DEDUPE_ALGO_HASH_CODE,
"MobSF Scorecard Scan": DEDUPE_ALGO_HASH_CODE,
"OSV Scan": DEDUPE_ALGO_HASH_CODE,
"Nosey Parker Scan": DEDUPE_ALGO_UNIQUE_ID_FROM_TOOL_OR_HASH_CODE,
"Bearer CLI": DEDUPE_ALGO_HASH_CODE,
Expand Down
1 change: 1 addition & 0 deletions dojo/tools/mobsf_scorecard/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = "Dmitrii Mariushkin"
106 changes: 106 additions & 0 deletions dojo/tools/mobsf_scorecard/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import json
from datetime import datetime

from dateutil import parser as date_parser

from dojo.models import Finding


class MobSFScorecardParser:

def get_scan_types(self):
return ["MobSF Scorecard Scan"]

def get_label_for_scan_types(self, scan_type):
return "MobSF Scorecard Scan"

def get_description_for_scan_types(self, scan_type):
return "Export a JSON file using the API, api/v1/report_json."

def get_findings(self, filename, test):

tree = filename.read()

try:
data = json.loads(str(tree, "utf-8"))
except:
data = json.loads(tree)

if "timestamp" in data:
try:
find_date = date_parser.parse(data["timestamp"])
except date_parser.ParserError:
find_date = datetime.now()
else:
find_date = datetime.now()

appsec_fields_for_test_desc = [
"file_name",
"hash",
"security_score",
"app_name",
"version_name",
]

main_fields_for_test_desc = [
"app_type",
"package_name",
"bundle_id",
"sdk_name",
"platform",
]

test_description = ""

for field in appsec_fields_for_test_desc:

field_value = str(data.get("appsec", {}).get(field, ""))

if field_value:
test_description = f"{test_description} **{field}:** {field_value}\n"

for field in main_fields_for_test_desc:

field_value = str(data.get(field, ""))

if field_value:
test_description = f"{test_description} **{field}:** {field_value}\n"

test.description = test_description

finding_severities = {
"high": "High",
"warning": "Medium",
"info": "Info",
"secure": "Info",
"hotspot": "Low",
}

dd_findings = {}

for finding_severity in finding_severities.keys():
if finding_severity in data.get("appsec", {}):
for mobsf_finding in data["appsec"][finding_severity]:

section = str(mobsf_finding.get("section", ""))
title = str(mobsf_finding.get("title", ""))
description = str(mobsf_finding.get("description", ""))

unique_key = f"{finding_severity}-{section}-{title}-{description}"

finding = Finding(
title=title,
cwe=919, # Weaknesses in Mobile Applications
test=test,
description=f"**Category:** {section}\n\n{description}",
severity=finding_severities[finding_severity],
references=None,
date=find_date,
static_finding=True,
dynamic_finding=False,
nb_occurences=1,
)

dd_findings[unique_key] = finding

return list(dd_findings.values())
Loading
Loading