Skip to content

Commit

Permalink
Added Exit codes and updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LaKeishaTurnerSlalom committed May 15, 2024
1 parent d28f29a commit 1cedb18
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.python-version

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
6 changes: 6 additions & 0 deletions javascript.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
env:
es6: true
extends:
- eslint:recommended
plugins:
- prettier
4 changes: 3 additions & 1 deletion secureli/modules/core/core_services/scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def _parse_scan_ouput(self, folder_path: Path, output: str = "") -> scan.ScanOut
files = self._find_file_names(failure_output_list=failure_output_list)

for file in files:
failures.append(scan.ScanFailure(id=id, file=file, repo=repo))
failures.append(
scan.ScanFailure(id=id, file=file, repo=repo, exitCode=id)
)

return scan.ScanOutput(failures=failures)

Expand Down
5 changes: 4 additions & 1 deletion secureli/modules/pii_scanner/pii_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ def _generate_scan_failures(
for pii_found_file in pii_found_files:
failures.append(
scan.ScanFailure(
id="pii_scan", file=pii_found_file, repo=SECURELI_GITHUB
id="pii_scan",
file=pii_found_file,
repo=SECURELI_GITHUB,
exitCode="PII_SCAN_ISSUES_DETECTED",
)
)
return failures
Expand Down
7 changes: 7 additions & 0 deletions secureli/modules/shared/models/exit_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@

class ExitCode(Enum):
SCAN_ISSUES_DETECTED = 3
PII_SCAN_ISSUES_DETECTED = 4
TYPE_ERROR = 5
NAME_ERROR = 6
VALIDATION_ERROR = 7
CONFIG_ERROR = 8
DICT_ERROR = 9
MISSING_ERROR = 10
1 change: 1 addition & 0 deletions secureli/modules/shared/models/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ScanFailure(pydantic.BaseModel):
repo: str
id: str
file: str
exitCode: str


class ScanOutput(pydantic.BaseModel):
Expand Down
6 changes: 5 additions & 1 deletion tests/actions/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ def test_that_initialize_repo_install_flow_displays_security_analysis_results(
mock_hooks_scanner.scan_repo.return_value = ScanResult(
successful=False,
output="Detect secrets...Failed",
failures=[ScanFailure(repo="repo", id="id", file="file")],
failures=[
ScanFailure(
repo="repo", id="id", file="file", exitCode="PII_SCAN_ISSUES_DETECTED"
)
],
)
action.verify_install(
test_folder_path,
Expand Down
21 changes: 18 additions & 3 deletions tests/modules/shared/utilities/test_usage_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@

def test_that_convert_failures_to_failure_count_returns_correct_count():
list_of_failure = [
ScanFailure(id="testfailid1", file="testfile1", repo="testrepo1"),
ScanFailure(id="testfailid1", file="testfile2", repo="testrepo1"),
ScanFailure(id="testfailid2", file="testfile1", repo="testrepo1"),
ScanFailure(
id="testfailid1",
file="testfile1",
repo="testrepo1",
exitCode="SCAN_ISSUES_DETECTED",
),
ScanFailure(
id="testfailid1",
file="testfile2",
repo="testrepo1",
exitCode="PII_SCAN_ISSUES_DETECTED",
),
ScanFailure(
id="testfailid2",
file="testfile1",
repo="testrepo1",
exitCode="VALIDATION_ERROR",
),
]

result = utilities.convert_failures_to_failure_count(list_of_failure)
Expand Down
7 changes: 7 additions & 0 deletions typescript.eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends:
- eslint:recommended
- plugin:@typescript-eslint/recommended
- prettier
parser: '@typescript-eslint/parser'
plugins:
- '@typescript-eslint'

0 comments on commit 1cedb18

Please sign in to comment.