@W-23563851: extend CAP security scanner with S17/S18/S19 (WARN) - #54
Open
jbisaSF wants to merge 3 commits into
Open
@W-23563851: extend CAP security scanner with S17/S18/S19 (WARN)#54jbisaSF wants to merge 3 commits into
jbisaSF wants to merge 3 commits into
Conversation
Adds three new WARN-tier rules to `.github/scripts/security-scan.sh`, all surfaced by the Avalara Tax v1.1.0 CAP review: - S17: BM controller `guard.ensure([...])` includes a state-changing method (`post`/`put`/`patch`/`delete`) but omits `'csrf'`. Scoped to `/bm_cartridges/` so storefront controllers with their own CSRF token flow are not flagged. - S18: `Logger.(warn|error|info|debug|trace)(... JSON.stringify(err|error|e| response|svcResponse|svcResult|result ...))` — raw error/response objects stringified into logs; recommend logging only `error.message` or a redacted status object. - S19: `encodeURI(...)` with a `+` concatenation or template-literal interpolation in the argument. `encodeURI` preserves URL delimiters (`/ ? & = #`) and single quotes; recommend `encodeURIComponent` per user-provided segment/param. All three are WARN, not BLOCK, so exit code and blocking-finding count are unchanged on already-shipped apps. Comments are filtered via the existing `strip_comments` helper. Fixture tests in `test-security-scan.sh` add positive and negative cases per rule (fires; does not fire on comment-only, unrelated code, or out-of-scope paths). Total: 123 tests pass, 0 fail. Documented in `.claude/skills/shared/security-rules.md` (which `.claude/skills/validate-app/references/security-scan.md` links to as the canonical rule list) with a one-paragraph description and suggested fix per rule. Verified: Avalara v1.1.1 (v1.1.0 is no longer in the local registry — see commit a60c0f4 for the removal) → 3 S18 warnings on `logger.error(... JSON.stringify(response.details))`; S17/S19 have no live matches on the fixed versions, so their shape correctness is carried by fixture tests. Blocking count unchanged (0 → 0). Byte-identical scanner output vs. `main` on `commerce-noibu-analytics-app-v0.1.0` and `commerce-vertex-tax-app-v1.0.0`. Co-Authored-By: Claude <noreply@anthropic.com>
kumaravinashcommercecloud
previously approved these changes
Jul 24, 2026
Address review nits by adding fixtures for every alternation in the S17 and S18 regex, so a future narrowing of either regex is caught by CI instead of silently reducing coverage. - S17: add `patch` and `delete` state-changing-method fixtures (previously only `post` and `put` were covered). - S18: add fixtures for the missing log levels (`info`, `trace`) and identifiers (`error`, `e`, `svcResult`, `result`). Tests: 129 passed, 0 failed (was 123).
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.
Summary
Extends
.github/scripts/security-scan.shwith three new WARN-tier rules surfaced by the Avalara Tax v1.1.0 CAP review:guard.ensure([...])includes a state-changing method (post/put/patch/delete) but omits'csrf'. Scoped to/bm_cartridges/so storefront controllers with their own CSRF-token flow are not flagged.Logger.(warn|error|info|debug|trace)(... JSON.stringify(err|error|e|response|svcResponse|svcResult|result ...))— raw error/response objects stringified into logs. Log onlyerror.messageor a redacted status object.encodeURI(...)with a+concatenation or template-literal interpolation in the argument.encodeURIpreserves URL delimiters (/ ? & = #) and single quotes; useencodeURIComponentper user-provided segment/param.All three are WARN, not BLOCK, so exit code and total blocking-findings count are unchanged on already-shipped apps. Comments are filtered via the existing
strip_commentshelper.Files changed
.github/scripts/security-scan.sh— S17/S18/S19 blocks added after S16, using the existingwarn/strip_comments/head -Nhelper pattern..github/scripts/test-security-scan.sh— fixture-based positive and negative cases per rule..claude/skills/shared/security-rules.md— canonical rule doc (which.claude/skills/validate-app/references/security-scan.mdlinks to) updated with a one-paragraph description and suggested fix per new rule.Acceptance criteria — status
logger.error(... JSON.stringify(response.details))). S17/S19 covered by fixture tests only — v1.1.0 (the reviewed pre-fix version) is no longer in the localcommerce-apps-testingregistry (removed ina60c0f4), and v1.1.1+ have no BM cartridge JS orencodeURImisuse. Shape correctness is proven by the fixtures./bm_cartridges/. S18: identifier list matches the WI verbatim. S19: requires+or\${insideencodeURI(...);\bencodeURI\bdoes not matchencodeURIComponent(.strip_comments. Negative fixtures for commented forms..claude/skills/shared/security-rules.mdwith description and suggested fix.commerce-noibu-analytics-app-v0.1.0andcommerce-vertex-tax-app-v1.0.0vs.main.Test plan
bash .github/scripts/test-security-scan.sh— 123 passed, 0 failed (was 100 before this change).bash .github/scripts/security-scan.sh <avalara-v1.1.1>— 3 S18 warnings, 0 S17, 0 S19, 0 blocking findings, exit 0.bash .github/scripts/security-scan.sh <noibu-analytics-v0.1.0>and<vertex-tax-v1.0.0>— byte-identical output vs.main.security.yml,test-scripts.yml,verify-zip.yml) — will report after the PR build completes.Notes
Details__c) referencescommerce-apps-testing/.github/scripts/security-scan.shas the file to touch; the scanner is duplicated verbatim incommerce-appsandcommerce-apps-testing, and this PR lands the fix incommerce-appsat the user's direction.🤖 Generated with Claude Code