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

feat: Added Exit codes and updated unit tests - DELETE - #547

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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'
Loading