Repository navigation
fix(sonar): constrain update-platforms CLI paths to the repo (tssecurity:S8707) - #206
Merged
Merged
Conversation
SonarQube rule tssecurity:S8707 flags path traversal through the command-line arguments accepted by the platform table updater scripts. Both scripts now resolve any provided results/target path relative to the working directory and exit when the path would escape it.
setchy
marked this pull request as ready for review
October 7, 2026 12:15
The previous guard only checked for a leading '..' in the relative path, which path.relative() does not produce for a target on a different Windows drive (it returns the target verbatim), letting e.g. D:\evil through. It also rejected legitimate names that merely start with '..' (e.g. '..foo'). Reject rel === '..' or rel starting with '..' + sep, plus any isAbsolute(rel), and return the resolved absolute path so callers cannot re-resolve a stale relative value.
|
setchy
added a commit
that referenced
this pull request
Oct 7, 2026
…:S8707) (#233) #206 wrapped process.argv path overrides in a custom resolveFromCwd guard, but Sonar's taint analysis does not recognize the guard: the flow still reaches readdirSync/readFileSync/writeFileSync, so all 6 S8707 issues stayed open on main after that merge. Both workflows invoke these scripts with no arguments, so the CLI overrides were unused. Use fixed relative paths and delete the now-dead helper.
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
The
update-platforms.mtsscripts (visual + e2e) acceptedprocess.argvresults-dir and target-file paths and passed them straight intoreadFileSync/readdirSync/writeFileSync, which ruletssecurity:S8707flags as a path-traversal vector.Both scripts now validate the resolved path stays within the working directory and refuse anything that escapes it. The validation lives in one shared helper so the two scripts don't carry duplicate copies (which also keeps the SonarCloud duplication gate green).
Changes
tests/util/resolve-from-cwd.mtsresolveFromCwd(): resolves a CLI path from the working directory and refuses anything that escapes ittests/visual/update-platforms.mtsresolveFromCwd()and validateprocess.argv[2]/argv[3]tests/e2e/update-platforms.mtsresolveFromCwd()and validateprocess.argv[2]/argv[3]Verification
pnpm lint(oxlint + oxfmt) — cleanpnpm typecheck— cleanpnpm test— 129/129 passingnode(the CI invocation): traversal arguments (../evil) are refused with exit 1; in-repo paths resolve normallyFindings