Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The rule incorrectly flags separator-terminated prefixes, and its containment guidance can accept paths outside the intended root on another Windows drive.
2 open issues
What changed in this PR
Adds a custom ESLint rule to detect path-containment checks that use bare directory prefixes, extending lint coverage for gh-aw’s setup JavaScript.
Changes:
- Detects
startsWith()checks againstpath.resolve(),path.join(), andpath.normalize()results, directly or through single-assignment variables. - Adds valid and invalid rule test cases.
- Registers the rule, enables it as a warning, and documents its usage.
| File | Description |
|---|---|
eslint-factory/src/rules/no-path-startswith-without-separator.ts |
Implements path-prefix detection and remediation guidance. |
eslint-factory/src/rules/no-path-startswith-without-separator.test.ts |
Tests accepted patterns, reported patterns, and the documentation URL. |
eslint-factory/src/index.ts |
Registers the new rule in the plugin. |
eslint-factory/README.md |
Documents the rule and recommended alternatives. |
eslint-factory/eslint.config.cjs |
Enables the rule at warning level. |
Review effort: Balanced (auto)
| schema: [], | ||
| messages: { | ||
| noBarePathPrefix: | ||
| "startsWith() with a bare directory path also matches sibling directories (e.g. /work/repo-evil starts with /work/repo). Compare against `root + path.sep` (and allow `=== root` separately) or use path.relative() and reject results starting with '..'.", |
There was a problem hiding this comment.
Updated the diagnostic to recommend rejecting path.isAbsolute(relative) as well as relative === '..' and relative.startsWith('..' + path.sep). Fix committed as 2154ccd.
| node.callee.object.type === "Identifier" && | ||
| node.callee.object.name === "path" && | ||
| node.callee.property.type === "Identifier" && | ||
| PATH_METHODS.has(node.callee.property.name) |
There was a problem hiding this comment.
The matcher now exempts separator-terminated path.join() and path.normalize() results, including direct calls and single-assignment variables; path.resolve() remains flagged. Regression tests cover both forms. Fix committed as 2154ccd.
|
✅ Ponytail Reviewer completed successfully!
|
|
🔎 PR Code Quality Reviewer is reviewing code quality for this pull request... |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Test Quality Sentinel completed test quality analysis. Warning Threat detection engine error Threat detection could not complete its analysis due to a tooling error. This is not a security finding. What happenedThe threat detection results could not be parsed. Review the workflow run logs to troubleshoot the error. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
There was a problem hiding this comment.
What this change does: This change adds an ESLint rule that flags startsWith() containment checks against bare path.resolve(), path.join(), and path.normalize() results. It registers and documents the rule and adds focused direct and alias tests.
Should fix:
-
Duplicate scope resolution (
eslint-factory/src/rules/no-path-startswith-without-separator.ts:43-55)- What this is: The rule resolves an identifier alias before checking its initializer.
- Problem: The repository already uses
ASTUtils.findVariable(sourceCode.getScope(node), node)for this exact scope-chain lookup (for example,no-dynamic-string-replacement.ts), so this duplicates scope-resolution logic for a one-alias rule. - Fix: Import
ASTUtilsand use that helper, keeping the existing single-definition and write checks. - If we skip it: Future scope-resolution fixes must be duplicated here.
Verdict: fix 1 first.
Lean: -8 lines possible.
Generated by ✂️ Ponytail Reviewer for #75594 · codex · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| if (node.type !== "Identifier") { | ||
| return false; | ||
| } | ||
| let scope: ReturnType<typeof sourceCode.getScope> | null = sourceCode.getScope(node); |
There was a problem hiding this comment.
What this is: This loop resolves the identifier alias before checking its initializer. Problem: The repository already uses ASTUtils.findVariable(sourceCode.getScope(node), node) for this exact scope-chain lookup (for example, no-dynamic-string-replacement.ts), so this duplicates scope-resolution logic for a one-alias rule. Fix: Import ASTUtils and use that helper, keeping the existing single-definition and write checks. If we skip it: Future scope-resolution fixes must be duplicated here.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs, /tdd, and /grill-with-docs. Requesting changes because the rule ships guidance that is wrong for some inputs.
📋 Key Themes & Highlights
Key Themes
- Incorrect fix advice (blocking): The rule message and README suggest
path.relative()with a..prefix check, which wrongly rejects legitimate names such as..foo. Theroot + path.sepadvice also breaks filesystem-root paths. - Coverage gaps: No test exercises the scope walk when a parameter shadows an outer path variable. Aliased
pathcalls are silently missed. - Open threads: The two existing Copilot threads on the
path.sep-terminated prefixes (lines 17 and 32) are valid and still apply.
Positive Highlights
- ✅ Clean
isBarePathValuehelper with single-assignment checks that limit false positives - ✅ Uses
context.sourceCodeand follows the sibling-rule test layout - ✅ Registration in
index.ts,eslint.config.cjs, and the README is complete
Limitation
I could not run the rule's tests: npm ci failed on a registry TLS error in this environment, so these findings come from reading the diff and checking Node path behaviour directly.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~6 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
| node.callee.type === "MemberExpression" && | ||
| !node.callee.computed && | ||
| node.callee.object.type === "Identifier" && | ||
| node.callee.object.name === "path" && |
There was a problem hiding this comment.
[/tdd] isPathCall only matches the bare identifier path. Aliases such as nodePath.resolve(...), path.posix.resolve(...), and destructured resolve calls are silently missed, which is a false negative. Either widen the match or document the limit in the README so authors do not assume full coverage.
@copilot please address this.
|
|
||
| ### `no-path-startswith-without-separator` | ||
|
|
||
| Disallow `value.startsWith(root)` where `root` is a bare `path.resolve()`/`path.join()`/`path.normalize()` result (directly or via a single-assignment variable). `/work/repo-evil` passes a `startsWith("/work/repo")` check. Compare against `root + path.sep` (plus `=== root`) or use `path.relative()` instead. |
There was a problem hiding this comment.
[/grill-with-docs] The advice root + path.sep is wrong for the filesystem root. path.resolve(/) is already /, so the suggested check becomes a startsWith against //, which rejects every absolute path. Document the fix as: append path.sep only when root does not already end with it.
💡 Impact
The failure is fail-closed, so this is not a security hole. It still breaks valid callers, and the same wording appears in the rule message.
@copilot please address this.
| schema: [], | ||
| messages: { | ||
| noBarePathPrefix: | ||
| "startsWith() with a bare directory path also matches sibling directories (e.g. /work/repo-evil starts with /work/repo). Compare against `root + path.sep` (and allow `=== root` separately) or use path.relative() and reject results starting with '..'.", |
There was a problem hiding this comment.
[/diagnosing-bugs] The alternative suggested here is unsafe for ..-prefixed names. path.relative(/work/repo, /work/repo/..foo/x) returns ..foo/x, so rejecting any result that starts with .. wrongly blocks a legitimate file. Check the path segment instead: rel === ".." || rel.startsWith(".." + path.sep) || path.isAbsolute(rel).
💡 Verified behaviour
Checked with Node: the result for that example is ..foo/x. The path.isAbsolute check also covers the Windows cross-drive case raised in the open thread.
@copilot please address this.
| `const root = path.resolve(base); if (dest.startsWith(root + path.sep)) {}`, | ||
| "const root = path.resolve(base); if (dest.startsWith(`${root}${path.sep}`)) {}", | ||
| `if (path.resolve(target).startsWith("/tmp/gh-aw/")) {}`, | ||
| `function f(root) { return file.startsWith(root); }`, |
There was a problem hiding this comment.
[/tdd] Add a shadowing case here. An outer const root = path.resolve(...) that an inner parameter shadows should stay valid. Nothing covers the scope walk in isBarePathValue yet.
💡 Suggested test
`const root = path.resolve(base); function f(root) { return file.startsWith(root); }`,@copilot please address this.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: da7531a
|
…startswith-without-separator-7d0e882b21d2ac1d Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
🎉 This pull request is included in a new release. Release: |

Warning
Threat detection engine error
Threat detection could not complete its analysis due to a tooling error. This is not a security finding.
What happened
The threat detection results could not be parsed.
Review the workflow run logs to troubleshoot the error.
New rule:
no-path-startswith-without-separatorFlags
x.startsWith(root)whererootis a barepath.resolve/join/normalizeresult (directly or via a single-assignment const)./work/repo-evilpassesstartsWith("/work/repo"), so these are path-containment bypasses.Research (window 2026-10-24 to 2026-11-07)
gh issue list --search "created:>=2026-10-24 actions/setup/js"returned 17 results; relevant: [uk-ai-resilience] Tier C: upload_asset follows symlinks (code scanning 1039) #73220 (upload_asset follows symlinks), [uk-ai-resilience] Harden MCP HTTP server runner: add auth and request body size limit #72479 (MCP HTTP server hardening), eslint-factory: exclude vendored/generated files from custom rule linting (work_queue_yaml.cjs) #74386 (eslint-factory scope). No direct recurring prefix-check report.repos/github/gh-aw/discussionsfiltered to created >= 2026-10-24: 0 matches (GraphQL query returned null data).Local scan
Containment checks in
actions/setup/jsare inconsistent. Safe ones appendpath.sep(e.g.merge_remote_agent_github_folder.cjs,find_repo_checkout.cjs); others such asengine_log_parser.cjsandpush_repo_memory.cjsrely on a trailing separator only by construction. The rule fires only on provable bare path values, so false-positive risk is low;root + path.sepand literal prefixes are accepted.Validation (from
eslint-factory)npm ci: oknpm run build: oknpm test -- src/rules/no-path-startswith-without-separator.test.ts: 2 passednpm run lint:setup-js: exit 0, 0 errors, 1116 warnings (rule enabled aswarn)Registered in
src/index.ts, enabled ineslint.config.cjs, documented in README.