slalombuild / secureli

seCureLI is a tool that enables you to experience the delight of building products by helping you get ideas from your head into working software as frictionlessly as possible, in a reliable, secure, scalable, and observable way.
Apache License 2.0
29 stars 3 forks source link

Traceback thrown during secureli pre-commit run #522

Closed icornett closed 1 month ago

icornett commented 2 months ago

Secureli v0.33.0 fails to scan a repository based on the serverless accelerator on Python 3.9 and 3.12 with the following

[seCureLI] [WARN] Skipping 8 file(s): [seCureLI] [WARN] - File at path package-lock.json was too big to scan [seCureLI] [WARN] - File at path docs/logos/serverless-accelerator-logo.ai was too big to scan [seCureLI] [WARN] - no lexer for filename 'wsl.conf' found [seCureLI] [WARN] - no lexer for filename 'init-dynamodb-local.mts' found [seCureLI] [WARN] - no lexer for filename 'start.mts' found [seCureLI] [WARN] - no lexer for filename 'quickdeploy.mts' found [seCureLI] [WARN] - no lexer for filename 'aws-login.mts' found [seCureLI] [WARN] - no lexer for filename 'aws-whoami.mts' found [seCureLI] Detected the following language(s): [seCureLI] - TypeScript: 92% [seCureLI] - Python: 5% [seCureLI] - JavaScript: 2% [seCureLI] seCureLI is installed and up-to-date for the following language(s): TypeScript, Python, and JavaScript [seCureLI] No hooks to update [seCureLI] Error PII scanning .pre-commit-config.yaml: [Errno 2] No such file or directory: '.pre-commit-config.yaml' ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /usr/local/python/3.9.19/lib/python3.9/site-packages/secureli/main.py:152 in scan │ │ │ │ 149 │ Performs an explicit check of the repository to detect security issues without remot │ │ 150 │ """ │ │ 151 │ SecureliConfig.FOLDER_PATH = Path(directory) │ │ ❱ 152 │ container.scan_action().scan_repo( │ │ 153 │ │ folder_path=Path(directory), │ │ 154 │ │ scan_mode=mode, │ │ 155 │ │ always_yes=False, │ │ │ │ ╭───────────────────────── locals ──────────────────────────╮ │ │ │ directory = PosixPath('.') │ │ │ │ files = None │ │ │ │ mode = <ScanMode.STAGED_ONLY: 'staged-only'> │ │ │ │ publish_results = <PublishResultsOption.ALWAYS: 'always'> │ │ │ │ specific_test = None │ │ │ ╰───────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/python/3.9.19/lib/python3.9/site-packages/secureli/actions/scan.py:174 in scan_repo │ │ │ │ 171 │ │ │ ) │ │ 172 │ │ │ │ 173 │ │ # Execute hooks │ │ ❱ 174 │ │ hooks_scan_result = self.hooks_scanner.scan_repo( │ │ 175 │ │ │ folder_path, scan_mode, specific_test, files=files │ │ 176 │ │ ) │ │ 177 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ always_yes = False │ │ │ │ files = None │ │ │ │ folder_path = PosixPath('.') │ │ │ │ now = 1713471210 │ │ │ │ pii_scan_result = ScanResult( │ │ │ │ │ successful=True, │ │ │ │ │ output='check for │ │ │ │ PII.................................................\x1b[42mPas… │ │ │ │ │ failures=[] │ │ │ │ ) │ │ │ │ publish_results_condition = <PublishResultsOption.ALWAYS: 'always'> │ │ │ │ scan_files = None │ │ │ │ scan_mode = <ScanMode.STAGED_ONLY: 'staged-only'> │ │ │ │ secureli_config = SecureliConfig( │ │ │ │ │ languages=['TypeScript', 'Python', 'JavaScript'], │ │ │ │ │ version_installed='2329a7a2d091ff2200f4f2d484ba90f3', │ │ │ │ │ last_hook_update_check=1713471210 │ │ │ │ ) │ │ │ │ self = <secureli.actions.scan.ScanAction object at 0x7f74789af5b0> │ │ │ │ specific_test = None │ │ │ │ verify_result = VerifyResult( │ │ │ │ │ outcome=<VerifyOutcome.UP_TO_DATE: 'up-to-date'>, │ │ │ │ │ config=SecureliConfig( │ │ │ │ │ │ languages=['TypeScript', 'Python', 'JavaScript'], │ │ │ │ │ │ version_installed='2329a7a2d091ff2200f4f2d484ba90f3', │ │ │ │ │ │ last_hook_update_check=0 │ │ │ │ │ ), │ │ │ │ │ analyze_result=None, │ │ │ │ │ file_path=None │ │ │ │ ) │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/python/3.9.19/lib/python3.9/site-packages/secureli/modules/core/core_services/scanner │ │ .py:47 in scan_repo │ │ │ │ 44 │ │ execute_result = self.pre_commit.execute_hooks( │ │ 45 │ │ │ folder_path, all_files, hook_id=specific_test, files=files │ │ 46 │ │ ) │ │ ❱ 47 │ │ parsed_output = self._parse_scan_ouput( │ │ 48 │ │ │ folder_path, output=execute_result.output │ │ 49 │ │ ) │ │ 50 │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ all_files = False │ │ │ │ execute_result = ExecuteResult( │ │ │ │ │ successful=False, │ │ │ │ │ output='[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-esl'+4807 │ │ │ │ ) │ │ │ │ files = None │ │ │ │ folder_path = PosixPath('.') │ │ │ │ scan_mode = <ScanMode.STAGED_ONLY: 'staged-only'> │ │ │ │ self = <secureli.modules.core.core_services.scanner.HooksScannerService object at │ │ │ │ 0x7f74789af400> │ │ │ │ specific_test = None │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /usr/local/python/3.9.19/lib/python3.9/site-packages/secureli/modules/core/core_services/scanner │ │ .py:80 in _parse_scan_ouput │ │ │ │ 77 │ │ # Process each failure │ │ 78 │ │ for failure_index in failure_indexes: │ │ 79 │ │ │ # Remove ANSI encoding and record hook id │ │ ❱ 80 │ │ │ id_with_encoding = output_by_line[failure_index + 1].split(": ")[1] │ │ 81 │ │ │ id = self._remove_ansi_from_string(id_with_encoding) │ │ 82 │ │ │ │ │ 83 │ │ │ # Retrieve repo url for failure │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ failure_index = 52 │ │ │ │ failure_indexes = [28, 48, 52, 57] │ │ │ │ failure_output_list = [ │ │ │ │ │ '\x1b[2m- hook id: check-json\x1b[m', │ │ │ │ │ '\x1b[2m- exit code: 1\x1b[m', │ │ │ │ │ '', │ │ │ │ │ '.devcontainer/devcontainer.json: Failed to json decode (Expecting │ │ │ │ value: line 1 '+18, │ │ │ │ │ '' │ │ │ │ ] │ │ │ │ failures = [ │ │ │ │ │ ScanFailure( │ │ │ │ │ │ repo='https://github.com/pre-commit/mirrors-prettier', │ │ │ │ │ │ id='prettier', │ │ │ │ │ │ file='javascript.eslintrc.yaml' │ │ │ │ │ ) │ │ │ │ ] │ │ │ │ file = 'javascript.eslintrc.yaml' │ │ │ │ files = [] │ │ │ │ folder_path = PosixPath('.') │ │ │ │ id = 'check-json' │ │ │ │ id_with_encoding = 'check-json\x1b[m' │ │ │ │ index = 71 │ │ │ │ line = '' │ │ │ │ output = '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-esl'+4807 │ │ │ │ output_by_line = [ │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-esl'+4, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-esl'+168, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-pre'+6, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-pre'+29, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/pygrep-hook'+2, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/PyCQA/bandit.', │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/psf/black.', │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/mirrors-esl'+47, │ │ │ │ │ '[INFO]\x1b[m Initializing environment for │ │ │ │ https://github.com/pre-commit/pre-commit-'+6, │ │ │ │ │ '[INFO]\x1b[m Installing environment for │ │ │ │ https://github.com/pre-commit/mirrors-eslin'+2, │ │ │ │ │ ... +62 │ │ │ │ ] │ │ │ │ pre_commit_config = PreCommitSettings( │ │ │ │ │ repos=[ │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/mirrors-eslint', │ │ │ │ │ │ │ rev='v9.0.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='eslint', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/mirrors-prettier', │ │ │ │ │ │ │ rev='v4.0.0-alpha.8', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='prettier', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/pygrep-hooks', │ │ │ │ │ │ │ rev='v1.10.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='python-use-type-annotations', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/PyCQA/bandit', │ │ │ │ │ │ │ rev='1.7.8', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='bandit', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/psf/black', │ │ │ │ │ │ │ rev='24.4.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='black', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/mirrors-eslint', │ │ │ │ │ │ │ rev='v9.0.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='eslint', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/mirrors-prettier', │ │ │ │ │ │ │ rev='v4.0.0-alpha.8', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='prettier', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/pre-commit/pre-commit-hooks', │ │ │ │ │ │ │ rev='v4.6.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-added-large-files', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-ast', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-docstring-first', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-executables-have-shebangs', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-shebang-scripts-are-executable', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-merge-conflict', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-toml', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-json', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-xml', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='check-yaml', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ), │ │ │ │ │ │ │ │ ... +7 │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ), │ │ │ │ │ │ PreCommitRepo( │ │ │ │ │ │ │ url='https://github.com/Yelp/detect-secrets', │ │ │ │ │ │ │ rev='v1.4.0', │ │ │ │ │ │ │ hooks=[ │ │ │ │ │ │ │ │ PreCommitHook( │ │ │ │ │ │ │ │ │ id='detect-secrets', │ │ │ │ │ │ │ │ │ arguments=[], │ │ │ │ │ │ │ │ │ additional_args=[], │ │ │ │ │ │ │ │ │ exclude_file_patterns=[] │ │ │ │ │ │ │ │ ) │ │ │ │ │ │ │ ], │ │ │ │ │ │ │ suppressed_hook_ids=[] │ │ │ │ │ │ ) │ │ │ │ │ ], │ │ │ │ │ suppressed_repos=[] │ │ │ │ ) │ │ │ │ repo = 'https://github.com/pre-commit/pre-commit-hooks' │ │ │ │ self = <secureli.modules.core.core_services.scanner.HooksScannerService │ │ │ │ object at 0x7f74789af400> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ IndexError: list index out of range

joe-stafford commented 2 months ago

Link to failed test https://github.com/slalombuild/secureli/actions/runs/8816720469/job/24201671905

isaac-heist-slalom commented 2 months ago

It appears that the above failed test issue has been resolved by https://github.com/slalombuild/secureli/issues/433.

See build results: https://github.com/slalombuild/secureli/actions/runs/8853432652/job/24314361104

isaac-heist-slalom commented 2 months ago

@icornett, can you point to the repo where this error is occurring?

isaac-heist-slalom commented 1 month ago

Discussed this with @icornett offline and he says "it's working now on 0.33.0". Marked bug as "closed".