CodeQL 2: fix(security): close remaining CodeQL security alerts#190
CodeQL 2: fix(security): close remaining CodeQL security alerts#190rlorenzo wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughWindows path regex simplified for lint-staged paths; linter temp file handling refactored to use dedicated temp directories with cleanup closures instead of single-file unlinking; .NET path construction standardized from ChangesLinting infrastructure refactor
Path API standardization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #190 +/- ##
=======================================
Coverage 42.96% 42.96%
=======================================
Files 877 877
Lines 51468 51468
Branches 4802 4802
=======================================
Hits 22113 22113
Misses 28831 28831
Partials 524 524
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/lint-any.js`:
- Around line 317-323: The temp directory created by fs.mkdtempSync (tempDir)
can leak if fs.writeFileSync(tempFile, ...) throws because cleanup is only
assigned afterwards; change the logic so that cleanup is set immediately after
creating tempDir (or wrap the mkdtempSync + writeFileSync sequence in a
try/catch) and in the catch remove tempDir (fs.rmSync(tempDir, { recursive:
true, force: true })) before rethrowing the error, ensuring tempDir/tempFile are
always cleaned up even when fs.writeFileSync fails; update references around
tempDir, tempFile, fs.mkdtempSync, fs.writeFileSync, and cleanup accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8c8bca24-88db-426b-96d8-b7be589bc90b
📒 Files selected for processing (4)
scripts/lib/lint-staged-common.jsscripts/lint-any.jsweb/Program.csweb/ViteProxyHelpers.cs
- scripts/lint-any.js: replace predictable temp-file name in os.tmpdir() with fs.mkdtempSync (private mode-0700 dir, cryptographic suffix) so the file inside cannot be predicted/preempted by another local process. Cleanup moved into a returned callback to remove the dir rather than just unlinking a single file. - scripts/lib/lint-staged-common.js: drop duplicated backslash in Windows drive-letter character class (semantically a no-op). - web/Program.cs, web/ViteProxyHelpers.cs: migrate four Path.Combine calls to Path.Join per CLAUDE.md convention; avoids the silent-drop behavior the rule flags. Closes CodeQL alerts: js/insecure-temporary-file (1), js/regex/duplicate-in-character-class (1), cs/path-combine (4).
3013f3c to
a6ad40f
Compare
Summary
Closes the 6 remaining CodeQL alerts in the
securityfamily that aren't already addressed by PR #184 (CMS path-injection) or PR #189 (generated-code exclusions).scripts/lint-any.js- switch temp-file creation from a predictable name inos.tmpdir()tofs.mkdtempSync(private mode-0700 directory, cryptographic suffix). Cleanup moved into a returned callback so the directory is removed, not just a single file. Closes 1×js/insecure-temporary-file.scripts/lib/lint-staged-common.js:321- drop duplicated\\in the Windows drive-letter character class. Semantically a no-op ([\\/]and[\/]match the same characters). Closes 1×js/regex/duplicate-in-character-class.web/Program.cs(×3),web/ViteProxyHelpers.cs- migratePath.Combine→Path.Join. All four call sites pass relative second args today, so the silent-drop edge case the rule warns about can't actually fire;Path.Joinlacks the footgun. Closes 4×cs/path-combine.Context
Second in the
CodeQL N:cleanup series (after #189). Independent of #184/#189.Test plan
npm run test- 1946 backend + 749 frontend passingnpm run lint- clean on changed files (pre-existing warnings unrelated)npm run verify:build- passesSummary by CodeRabbit