-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
from .json import JSONFormatter, PrettyJSONFormatter | ||
from .simple_stdout import SimpleFormatter | ||
from .tabular import TabularFormatter | ||
from .sonarqube import SonarQubeFormatter | ||
|
||
FORMAT_RESOLVER = { | ||
"simple": SimpleFormatter(), | ||
"json": JSONFormatter(), | ||
"json-pretty": PrettyJSONFormatter(), | ||
"table": TabularFormatter(), | ||
"sonar": SonarQubeFormatter(), | ||
} | ||
|
||
__all__ = [JSONFormatter, PrettyJSONFormatter, SimpleFormatter, TabularFormatter] | ||
__all__ = [JSONFormatter, PrettyJSONFormatter, SimpleFormatter, TabularFormatter, SonarQubeFormatter] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from mythx_cli.formatter.json import JSONFormatter | ||
from mythx_models.response import DetectedIssuesResponse, AnalysisInputResponse | ||
from mythx_models.response.issue import Severity, SourceType | ||
import json | ||
|
||
|
||
class SonarQubeFormatter(JSONFormatter): | ||
@staticmethod | ||
def format_detected_issues(resp: DetectedIssuesResponse, inp: AnalysisInputResponse) -> str: | ||
new_reports = [] | ||
for report in resp.issue_reports: | ||
for issue in report: | ||
new_issue = {} | ||
for loc in issue.decoded_locations: | ||
for raw_loc in issue.locations: | ||
if raw_loc.source_type != SourceType.SOLIDITY_FILE: | ||
continue | ||
new_issue["onInputFile"] = raw_loc.source_list[raw_loc.source_map.components[0].file_id] | ||
new_issue["atLineNr"] = loc.start_line | ||
|
||
new_issue.update({ | ||
"linterName": "mythx", | ||
"forRule": issue.swc_id, | ||
"ruleType": issue.severity.name, | ||
"remediationEffortMinutes": 0, | ||
"severity": "vulnerability" if issue.severity == Severity.HIGH else issue.severity.name, | ||
"message": issue.description_long, | ||
}) | ||
new_reports.append(new_issue) | ||
|
||
return json.dumps(new_reports) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"linterName": "mythx", | ||
"forRule": "SWC-110", | ||
"ruleType": "LOW", | ||
"remediationEffortMinutes": 0, | ||
"atLineNr": 1, | ||
"onInputFile": "/home/spoons/diligence/mythx-qa/land/contracts/estate/EstateStorage.sol", | ||
"severity": "LOW", | ||
"message": "It is possible to trigger an exception (opcode 0xfe). Exceptions can be caused by type errors, division by zero, out-of-bounds array access, or assert violations. Note that explicit `assert()` should only be used to check invariants. Use `require()` for regular input checking." | ||
}, | ||
{ | ||
"linterName": "mythx", | ||
"forRule": "", | ||
"ruleType": "LOW", | ||
"remediationEffortMinutes": 0, | ||
"severity": "LOW", | ||
"message": "Warning: Free mode only detects certain types of smart contract vulnerabilities. Your contract may still be unsafe. Upgrade to MythX Pro to unlock the ability to test for even more vulnerabilities, perform deeper security analysis, and more. https://mythx.io/plans" | ||
} | ||
] |