[APS-19017] fix: supply-chain hygiene (mocha->devDeps, pin Semgrep image, files allowlist) - #1129
Open
Rohannagariya1 wants to merge 2 commits into
Open
Rohannagariya1 wants to merge 2 commits into
Rohannagariya1 wants to merge 2 commits into
Conversation
karanshah-browserstack
previously approved these changes
Jun 15, 2026
…mage, add files allowlist [APS-19017] INF-005: remove mocha from dependencies (kept in devDependencies); CLI loads mocha from user project via requireModule(), prod copy unnecessary. npm ls mocha --omit=dev now empty. INF-007: pin Semgrep CI image returntocorp/semgrep -> @sha256:f4791a54c891eabe1188248135574e6e03dfc31dfd3f3b747c7bec7079bfed1b (latest as of 2026-06-15). INF-008: add package.json files allowlist [bin/, README.md, LICENSE.md] so npm pack no longer ships .github/, CODEOWNERS, .nycrc.yml, test/. Verified via npm pack --dry-run. NOT applied: CSL-003 md5->sha256 (constants.js) — behavioral change to upload-dedup hash; needs human sign-off. Resolves: APS-19017 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Raghav11-11
force-pushed
the
fix/APS-19017-supply-chain-hygiene
branch
from
September 16, 2026 06:15
e61413b to
4015286
Compare
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited) Review profile: ASSERTIVE Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
…ride; mocha bundling load-bearing for reporter/index.js:12 require
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.
Security Fix: APS-19017 (Low, supply-chain hygiene)
Applies the SAFE mechanical hygiene fixes from the ticket. The mocha
dependencies→devDependenciesmove (INF-005) was proposed but has been reverted after review — reasoning below.INF-007 — unpinned Semgrep CI image
Pinned
.github/workflows/Semgrep.ymlfromimage: returntocorp/semgrep:1.166.0(version tag) toimage: returntocorp/semgrep:1.166.0@sha256:c180f0c93a17b420c0af5006214a29d3c747c5459c732b740191adf657dd0068(version tag + digest).Why: a version tag can be re-published by the maintainer at any time. If Return-to-corp's Docker Hub account is compromised, an attacker can replace
:1.166.0with a malicious image → every CI run of this repo pulls it → attacker gets access to GitHub Actions secrets (including the npm publish token — which would let them publish a malicious version of this CLI to every BrowserStack customer). Digest is cryptographically immutable — Docker refuses to pull anything except an image whose bytes hash toc180f0c9....Verified: digest resolved via Docker Hub manifest API on 2026-09-16; same image bits master runs against today, just referenced by content-hash instead of tag.
INF-008 — tarball ships
.github/andCODEOWNERSAdded a
filesallowlist topackage.json:["bin/", "README.md", "LICENSE.md"].Why: master has no
filesfield; the.npmignoreonly excludestest/andresults/. So the current npm tarball includes.github/,CODEOWNERS,.nycrc.yml,.eslintrc*,.gitignore,.editorconfig— all internal repo hygiene files, none of which the CLI needs to run.Verified:
npm pack --dry-runon this branch → 120.8 kB tarball, 62 files, containing onlybin/*+README.md+LICENSE.md+package.json(auto-included by npm)..github/,CODEOWNERS,test/,.nycrc.ymlcorrectly excluded. All runtime code (bin/runner.jsentry,bin/testObservability/*,bin/helpers/*,bin/commands/*,bin/templates/*,bin/testhub/*,bin/accessibility-automation/*) still ships.Note on allowlist contents: the ticket originally suggested
["bin/", "README.md", "LICENSE", "index.js"]. Adjusted to match repo reality — the file isLICENSE.md(notLICENSE), andindex.jsdoesn't exist in the repo (pre-existing brokenmainfield, not addressed here).INF-001 — axios
Already
^1.15.0on master. No change needed. Confirmed vianpm ls axios.INF-005 — mocha in production dependencies — REVERTED
Was in an earlier version of this PR; removed after code review found two problems with the ticket's reasoning:
The CVE the ticket cites (GHSA-5c6j-r48x-rmvq via
serialize-javascript) is already mitigated on master.package.jsonhas"overrides": { "serialize-javascript": ">=7.0.5" }— npm respects this override during resolution, so mocha's transitiveserialize-javascriptresolves to the patched version regardless of mocha being independenciesor not. The security scanner that generated APS-19017 didn't account for this existing override.Removing mocha would break TestObservability for globally-installed CLI customers.
bin/testObservability/reporter/index.js:12doesrequire('mocha/lib/runnable')(regularrequire, notrequireModule) with a code comment explicitly saying "need to handle as this isn't present in older mocha versions" — i.e., the developer intentionally wanted the bundled mocha as a version-safety fallback. Because the CLI is installed globally per BrowserStack's official docs (npm install -g browserstack-cypress-cli) and TestObservability is enabled by default for Cypress v10+, thisrequirewould fail withMODULE_NOT_FOUNDon every default-config customer's next session — Node's regularrequirecan't reach the customer'snode_modulesfrom a globally-installed CLI's directory.Net effect of the revert: no code change, but the ticket's INF-005 concern is already addressed by the existing
overrideson master.NOT applied — needs separate decision
constants.js:401md5 → sha256): Changes the upload-dedup hash algorithm. Client-only change would leave the CLI sending SHA-256 hashes that BS's server-side dedup (currently keyed on MD5) doesn't recognize → every next upload for every customer becomes a full re-upload until the SHA-256 cache warms. Also may need server-side changes if the dedup logic hard-codes MD5 length/format. Requires client+server coordination and one-time bandwidth spike acceptance. Deferred for a separate ticket/PR — noted on APS-19017.Testing
npm pack --dry-run— tarball contains onlybin/+README.md+LICENSE.md+package.json. Verified.npm test— 13 failing, all a subset of master's pre-existing 16 failures (flaky usage-reporting / video-config / stub-count families, unrelated to this change). No new regressions.Jira Ticket
https://browserstack.atlassian.net/browse/APS-19017