Repository navigation
[FSSDK-13472] Fix Arnica findings: example runners, loopback server, unused dev dependencies - #1195
Open
Esra Kartal (esrakartalOpt) wants to merge 2 commits into
Open
Esra Kartal (esrakartalOpt) wants to merge 2 commits into
Esra Kartal (esrakartalOpt) wants to merge 2 commits into
Conversation
…unused dev dependencies - Run npm with execFileSync and an argument list, with no shell, in the CommonJS and TypeScript example runners (fixes the detect-child-process findings and the unquoted tarball path). - Bind the example datafile server to localhost only, instead of every network interface. - Accept only a .ts source in generate-messages.js, and test it. - Remove the unused dev dependencies mocha-lcov-reporter and coveralls-next. - Document why the remaining path-traversal and http-server findings are safe. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
Both example runners and their runQuiet helpers still use Windows shell execution, which can split paths containing spaces and interpret path metacharacters as additional commands.
1 open issue
What changed in this PR
Addresses FSSDK-13472 by hardening SDK example tooling, validating message-generator inputs, and removing unused development dependencies.
Changes:
- Converts example runners to argument-array process calls and restricts the sample datafile server to localhost.
- Rejects unsupported message-generator inputs, adds regression tests, and documents security-scanner suppressions.
- Removes unused coverage packages and updates the lockfile.
| File | Description |
|---|---|
scripts/test-generate-messages.js |
Tests rejection of JSON and generated TypeScript inputs. |
scripts/run-ts-example.js |
Uses argument arrays for npm calls with Windows-specific shell handling. |
scripts/run-cjs-example.js |
Applies the same npm invocation changes to the CommonJS runner. |
scripts/platform-utils.js |
Adds comments explaining path-traversal suppression. |
scripts/generate-messages.js |
Validates input extensions and documents path-traversal suppressions. |
rolldown.config.mjs |
Adds suppression comments for repository-derived shim paths. |
package.json |
Removes two unused coverage dependencies. |
package-lock.json |
Removes corresponding package entries and other dependency entries. |
examples/shared/datafile-server.js |
Binds to localhost and documents intentional local HTTP use. |
Review effort: Balanced
…ell cannot split it Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
Fixes the Arnica findings in FSSDK-13472. I re-checked each one against current
masterand ran the real Semgrep rules on the files before and after (the "before" run reproduces Arnica's 12 SAST findings on the same lines).scripts/run-cjs-example.jsandscripts/run-ts-example.jsnow callexecFileSync('npm', [args])with no shell, instead ofexecSyncwith a command string. The same npm commands run as before. This also fixes a real bug: the tarball path was put unquoted into a shell command, so a repo path with a space or a shell character would break or change the command. On Windows npm isnpm.cmd, which Node only runs through a shell, and a shell joins the arguments without escaping them. So the tarball is passed as a path relative to the example folder (for example../../optimizely-optimizely-sdk-6.7.1.tgz) and no part of the checkout path is ever an argument. The rule does not flagexecFileSync, so there is no suppression.examples/shared/datafile-server.jscalledlisten(PORT)with no host, so it listened on every network interface. It now listens onlocalhostonly (the examples usehttp://localhost:8910). Plain HTTP stays on purpose, since it serves the sample datafile locally, and the finding is suppressed with that reason.scripts/generate-messages.js(3): the path is a command line argument, so it now accepts only a.tssource and never a generated.gen.tsfile. The existing CI testscripts/test-generate-messages.jscovers both rejections. The three remaining findings are suppressed with the reason written above them.rolldown.config.mjs(2) andscripts/platform-utils.js(2): the names come fromreaddirSyncof folders in the repo at build time, never from user input. Suppressed with the reason above each.mocha-lcov-reporterandcoveralls-next, and their now-unused dependencies, frompackage.jsonand the lockfile. CI uploads coverage withcoverallsapp/github-actionandnyc, not with these.@types/nisestays:niseships no types andrequest_handler.browser.spec.tsneeds them.Not changed
master. All 11actions/checkoutsteps already havepersist-credentials: false, so Arnica's list is from before that. A rescan should clear them.image-sizeintests/react-native-metro/fixtures/rn-0.73(2 findings): not fixed on purpose. Metro 0.80.12 callsrequire("image-size")(buffer)as a function. The only patched line, 2.0.3, exports an object when loaded withrequire, and there is no patched 1.x. So anoverridesentry would pass the test (the test app has no images) but silently break Metro's image handling. Upgrading Metro, as Arnica suggests, would defeat the fixture, which pins Metro 0.80 to reproduce an old Metro bug. It is test-only and never shipped. This should be dismissed in Arnica with that reason. The same advisory is Dependabot alerts 591 and 592 in FSSDK-13473.Test plan
scripts/test-generate-messages.jspasses, and fails when the new guard is removed. Platform isolation tests pass (24 of 24).npm cion a clean copy installs from the edited lockfile (688 packages): the removed packages are gone and@types/niseis still installed.npm run buildandnpm run coveralls(writescoverage/lcov.info) both succeed.npm run test-typescript(including the SDK's polling client fetching the datafile from the loopback-only server) and CI's CommonJS sequence (npm pack,npm run test-commonjs -- --skip-build --skip-run, thennpm startin the example). Both pass, with no leftover files or lockfile changes.localhostand refuses the LAN address.nosemgrepcomments, which use the registry rule IDs (with the comments removed the same 7 and 1 come back). Arnica needs a rescan to confirm it honors them.sp ace & x. The previous version (absolute tarball path) fails there, because the shell splits the path at the space. The relative-path version installs correctly, with and without the shell.Issues
🤖 Generated with Claude Code