← 输入框|github.com|刷新
Skip to content

[FSSDK-13472] Fix Arnica findings: example runners, loopback server, unused dev dependencies - #1195

Open
Esra Kartal (esrakartalOpt) wants to merge 2 commits into
masterfrom
esra/fssdk-13472-fix-arnica-findings
Open

Esra Kartal (esrakartalOpt) wants to merge 2 commits into
masterfrom
esra/fssdk-13472-fix-arnica-findings

Conversation

@esrakartalOpt

@esrakartalOpt Esra Kartal (esrakartalOpt) commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Arnica findings in FSSDK-13472. I re-checked each one against current master and ran the real Semgrep rules on the files before and after (the "before" run reproduces Arnica's 12 SAST findings on the same lines).

  • Child process (4 findings, fixed). scripts/run-cjs-example.js and scripts/run-ts-example.js now call execFileSync('npm', [args]) with no shell, instead of execSync with 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 is npm.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 flag execFileSync, so there is no suppression.
  • HTTP server (1 finding, hardened). examples/shared/datafile-server.js called listen(PORT) with no host, so it listened on every network interface. It now listens on localhost only (the examples use http://localhost:8910). Plain HTTP stays on purpose, since it serves the sample datafile locally, and the finding is suppressed with that reason.
  • Path traversal (7 findings).
    • scripts/generate-messages.js (3): the path is a command line argument, so it now accepts only a .ts source and never a generated .gen.ts file. The existing CI test scripts/test-generate-messages.js covers both rejections. The three remaining findings are suppressed with the reason written above them.
    • rolldown.config.mjs (2) and scripts/platform-utils.js (2): the names come from readdirSync of folders in the repo at build time, never from user input. Suppressed with the reason above each.
  • Low-reputation dependencies (3 findings). Removed the unused mocha-lcov-reporter and coveralls-next, and their now-unused dependencies, from package.json and the lockfile. CI uploads coverage with coverallsapp/github-action and nyc, not with these. @types/nise stays: nise ships no types and request_handler.browser.spec.ts needs them.

Not changed

  • Artipacked (9 findings): already fixed on master. All 11 actions/checkout steps already have persist-credentials: false, so Arnica's list is from before that. A rescan should clear them.
  • image-size in tests/react-native-metro/fixtures/rn-0.73 (2 findings): not fixed on purpose. Metro 0.80.12 calls require("image-size")(buffer) as a function. The only patched line, 2.0.3, exports an object when loaded with require, and there is no patched 1.x. So an overrides entry 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

  • Full suite on Node 22.23 with npm 12: mocha 815 passed, vitest 1137 passed (81 files), lint 0 errors. scripts/test-generate-messages.js passes, and fails when the new guard is removed. Platform isolation tests pass (24 of 24).
  • npm ci on a clean copy installs from the edited lockfile (688 packages): the removed packages are gone and @types/nise is still installed. npm run build and npm run coveralls (writes coverage/lcov.info) both succeed.
  • Ran both example runners end to end: 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, then npm start in the example). Both pass, with no leftover files or lockfile changes.
  • The example server answers on localhost and refuses the LAN address.
  • Semgrep with the real rules: the original files give the 12 findings Arnica reported. The fixed files give 0 for child process. They give 0 for path and HTTP only because of the nosemgrep comments, 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.
  • Windows shell behaviour (Copilot's comment): I forced the shell path on macOS in a folder named 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.
  • Not tested: a real Windows machine, and the Linux CI run itself.

Issues

  • FSSDK-13472

🤖 Generated with Claude Code

…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>
@coveralls

Coveralls (coveralls) commented Nov 30, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 77.435%. remained the same — esra/fssdk-13472-fix-arnica-findings into master

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread scripts/run-ts-example.js Resolved
…ell cannot split it

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants