fix(scanners): do not embed literal quotes in checkov/bandit exclusion args#350
Merged
rafaelpereyra merged 1 commit intoJul 6, 2026
Conversation
e7c5cc5 to
dba27ca
Compare
…n args
ASH builds checkov --skip-path and bandit --exclude args as
single-string f'--flag="{value}"' tokens. Because subprocess is
called with shell=False, the quote characters end up inside the argv
value, and downstream tools treat them as part of the pattern,
silently disabling all path exclusions.
Drop the quote wrap from the three affected f-strings and add unit
regression tests asserting no emitted token contains a literal '"'.
Fixes awslabs#349
dba27ca to
0f8c896
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, 349
Description of changes:
The built-in
checkovandbanditscanner plugins construct their--skip-path/--excludeCLI arguments as single-string tokens with literal double-quote characters wrapped around the value. ASH invokes scanners viasubprocesswith the defaultshell=False, so the"characters end up inside the argv value rather than being interpreted as shell quoting. The downstream tools then treat the quotes as part of the pattern — checkov compiles a regex that requires a literal"character in the file path, so no real path matches and exclusions silently fail.The failure is silent: scanners exit 0, no warning is emitted, and the only observable symptom is that path exclusions don't appear to take effect. Both built-in
KNOWN_IGNORE_PATHSand any user-configuredskip_path/excluded_pathsentries are affected.Affected versions: Tested v3.2.1 and v3.5.2, although likely present in older versions.
See the linked issue for the full reproducer.
Fix
Remove the embedded quotes from the three affected f-strings. The values are passed as argv via
subprocess, so no shell-level quoting is needed — the argument delimiter is the argv boundary.automated_security_helper/plugin_modules/ash_builtin/scanners/checkov_scanner.py:two occurrences (the
KNOWN_IGNORE_PATHSloop and the userskip_pathloop).automated_security_helper/plugin_modules/ash_builtin/scanners/bandit_scanner.py:one occurrence (the single
--excludetoken).Tests
Two new unit-test files under
tests/unit/plugin_modules/ash_builtin/:test_checkov_scanner_skip_path_quoting.py:test_process_config_options_skip_path_arguments_contain_no_literal_quotes— asserts no emitted--skip-path=ToolExtraArg.keycontains a literal"character.test_process_config_options_skip_path_values_are_verbatim— parametrized over five filesystem-safe paths; asserts each emitted token equals exactly--skip-path={path}.test_bandit_scanner_exclude_quoting.py:test_process_config_options_exclude_argument_contains_no_literal_quotes— asserts no emitted--exclude=ToolExtraArg.keycontains a literal"character.test_process_config_options_exclude_argument_value_is_well_formed— asserts the comma-joined--exclude=value splits into the expected list of glob entries (mirroring the source-codePath(...).joinpath(...)construction so the test stays correct under any future Path-normalization changes).Also updated a stale comment in
tests/integration/scanners/test_bandit_scanner.py::test_process_config_options_exclusionsthat documented the buggy quoted form as if it were intentional. The assertion itself is quote-agnostic and is unchanged.
Verification
uv run pytest --run-integration tests/unit/ tests/integration/scanners/ -v --no-cov) shows the same pre-existing 5 failures as before the fix (unrelated env / mock signature drift); zero new failures.uv run ruff checkanduv run ruff format --checkclean on all five touched files.uv tool install --from . automated-security-helper --force, ran against a project with acdk.out/directory andscanners.checkov.options.skip_path: "cdk.out". Verified scan properly excluded cdk.out.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.