forked from ioggstream/bandit-report-artifacts
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from par-tec/ioggstream-20
Fix: #20. Refactor test directories
- Loading branch information
Showing
12 changed files
with
58 additions
and
41 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,23 @@ | ||
{ | ||
"name": "Semgrep Comments", | ||
"head_sha": "stuff", | ||
"completed_at": "2023-11-09T15:29:33.821590Z", | ||
"conclusion": "failure", | ||
"output": { | ||
"title": "Semgrep: ", | ||
"summary": "Semgrep statistics: {\n \"Total_errors\": 1,\n \"Semgrep_Version\": \"1.34.0\",\n \"paths_scanned\": 36\n}", | ||
"text": "<add --verbose for a list of skipped paths>", | ||
"annotations": [ | ||
{ | ||
"path": ".github/workflows/test.yml", | ||
"start_line": 31, | ||
"end_line": 31, | ||
"start_column": 114, | ||
"end_column": 117, | ||
"annotation_level": "warning", | ||
"title": "Syntax error", | ||
"message": " When parsing a snippet as Bash for metavariable-pattern in rule 'yaml.github-actions.security.curl-eval.curl-eval'" | ||
} | ||
] | ||
} | ||
} |
File renamed without changes.
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,16 +1,24 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from parse_scripts import checkov | ||
from parse_scripts.util import json_load | ||
|
||
TEST_DIR = Path(__file__).parent | ||
JSON_DIR = TEST_DIR / "json" | ||
DATA_DIR = TEST_DIR / "data" | ||
|
||
|
||
def test_parse(): | ||
expected_comments = json_load(DATA_DIR / "checkov_input.json") | ||
data = json_load(JSON_DIR / "checkov.json") | ||
@pytest.mark.parametrize( | ||
"infile,expected", | ||
[ | ||
(f, f.with_suffix(".annotations.json")) | ||
for f in DATA_DIR.glob("checkov-[0-9][0-9].json") | ||
], | ||
) | ||
def test_parse(infile, expected): | ||
expected_comments = json_load(expected) | ||
data = json_load(infile) | ||
actual_comments = checkov.checkov_results(log=data, github_sha="stuff") | ||
actual_comments["completed_at"] = "00:00" | ||
assert expected_comments == actual_comments |
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,37 +1,23 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
import parse_scripts.semgrep | ||
from parse_scripts.util import json_load | ||
|
||
DATA_DIR = Path(__file__).parent / "json" | ||
|
||
expected_results = { | ||
"name": "Semgrep Comments", | ||
"head_sha": "stuff", | ||
"completed_at": "2023-11-09T15:29:33.821590Z", | ||
"conclusion": "failure", | ||
"output": { | ||
"title": "Semgrep: ", | ||
"summary": 'Semgrep statistics: {\n "Total_errors": 1,\n "Semgrep_Version": "1.34.0",\n "paths_scanned": 36\n}', | ||
"text": "<add --verbose for a list of skipped paths>", | ||
"annotations": [ | ||
{ | ||
"path": ".github/workflows/test.yml", | ||
"start_line": 31, | ||
"end_line": 31, | ||
"start_column": 114, | ||
"end_column": 117, | ||
"annotation_level": "warning", | ||
"title": "Syntax error", | ||
"message": " When parsing a snippet as Bash for metavariable-pattern in rule 'yaml.github-actions.security.curl-eval.curl-eval'", | ||
} | ||
], | ||
}, | ||
} | ||
DATA_DIR = Path(__file__).parent / "data" | ||
|
||
|
||
def test_parse_data(): | ||
data = json_load(DATA_DIR / "semgrep.json") | ||
@pytest.mark.parametrize( | ||
"infile,expected", | ||
[ | ||
(f, f.with_suffix(".annotations.json")) | ||
for f in DATA_DIR.glob("semgrep-[0-9][0-9].json") | ||
], | ||
) | ||
def test_parse_data(infile, expected): | ||
data = json_load(infile) | ||
expected_results = json_load(expected) | ||
actual_results = parse_scripts.semgrep.parse_data(data, "stuff") | ||
actual_results["completed_at"] = "2023-11-09T15:29:33.821590Z" | ||
assert expected_results == actual_results |