Skip to content

Commit bb22ac0

Browse files
add prysk test for pprint
1 parent 65f14ef commit bb22ac0

File tree

4 files changed

+61
-6
lines changed

4 files changed

+61
-6
lines changed

.github/workflows/report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ jobs:
5151
poetry run coverage report -- --format markdown >> $GITHUB_STEP_SUMMARY
5252
echo -e "\n\n# Static Code Analysis\n" >> $GITHUB_STEP_SUMMARY
5353
cat .lint.txt >> $GITHUB_STEP_SUMMARY
54-
poetry run tbx security pretty-print --format markdown .security.json >> $GITHUB_STEP_SUMMARY
54+
poetry run tbx security pretty-print .security.json >> $GITHUB_STEP_SUMMARY

exasol/toolbox/tools/security.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,9 @@ def issues_to_markdown(issues: Iterable[Issue]) -> str:
126126
template = cleandoc("""
127127
{header}{rows}
128128
""")
129+
129130
def _header():
130-
header = ""
131-
markdown_str = ""
132-
markdown_str += "# Security\n\n"
131+
header = "# Security\n\n"
133132
header += "|File|Cve|Cwe|Details|\n"
134133
header += "|---|:-:|:-:|---|\n"
135134
return header
@@ -140,7 +139,7 @@ def _row(issue):
140139
row += issue.cwe + "|"
141140
for element in issue.references:
142141
row += element + " ,<br>"
143-
row += row[:-5] + "|"
142+
row = row[:-5] + "|"
144143
return row
145144

146145
return template.format(
@@ -310,7 +309,6 @@ class PPrintFormats(str, Enum):
310309

311310
@CLI.command(name="pretty-print")
312311
def json_issue_to_markdown(
313-
format: PPrintFormats = typer.Option(default="", help="output format",),
314312
json_file: typer.FileText = typer.Argument(default="", mode="r", help="json file with issues to convert"),
315313
) -> None:
316314
content = json_file.read()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Create test input
2+
3+
$ cat > .security.json <<EOF
4+
> {
5+
> "result":[
6+
> ]
7+
> }
8+
> EOF
9+
10+
Run test case
11+
12+
$ tbx security pretty-print .security.json
13+
# Security
14+
15+
|File|Cve|Cwe|Details|
16+
|---|:-:|:-:|---|
17+
18+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Create test input
2+
3+
$ cat > .security.json <<EOF
4+
> {
5+
> "results":[
6+
> {
7+
> "code": "555 subprocess.check_call(\n556 config.smv_postbuild_command, cwd=current_cwd, shell=True\n557 )\n558 if config.smv_postbuild_export_pattern != \"\":\n559 matches = find_matching_files_and_dirs(\n",
8+
> "col_offset": 16,
9+
> "end_col_offset": 17,
10+
> "filename": "/home/jami/Git/python-toolbox/exasol/toolbox/sphinx/multiversion/main.py",
11+
> "issue_confidence": "HIGH",
12+
> "issue_cwe": {
13+
> "id": 78,
14+
> "link": "https://cwe.mitre.org/data/definitions/78.html"
15+
> },
16+
> "issue_severity": "HIGH",
17+
> "issue_text": "subprocess call with shell=True identified, security issue.",
18+
> "line_number": 556,
19+
> "line_range": [
20+
> 555,
21+
> 556,
22+
> 557
23+
> ],
24+
> "more_info": "https://bandit.readthedocs.io/en/1.7.10/plugins/b602_subprocess_popen_with_shell_equals_true.html",
25+
> "test_id": "B602",
26+
> "test_name": "subprocess_popen_with_shell_equals_true"
27+
> }
28+
> ]
29+
> }
30+
> EOF
31+
32+
Run test case
33+
34+
$ tbx security pretty-print .security.json
35+
# Security
36+
37+
|File|Cve|Cwe|Details|
38+
|---|:-:|:-:|---|
39+
|exasol/toolbox/sphinx/multiversion/main.py:556:16:||78|https://bandit.readthedocs.io/en/1.7.10/plugins/b602_subprocess_popen_with_shell_equals_true.html ,<br>https://cwe.mitre.org/data/definitions/78.html |

0 commit comments

Comments
 (0)