Skip to content

fix: address all open CodeQL TypeScript alerts#75

Merged
marcusds merged 10 commits into
mainfrom
fix/codeql-typescript-cleanup/mschwab
May 28, 2026
Merged

fix: address all open CodeQL TypeScript alerts#75
marcusds merged 10 commits into
mainfrom
fix/codeql-typescript-cleanup/mschwab

Conversation

@marcusds
Copy link
Copy Markdown
Contributor

@marcusds marcusds commented May 27, 2026

Summary

Closes all 34 open CodeQL alerts on main for language:typescript. Two commits:

Commit 1 — 21 alerts (567e054e51)

Security

Code-quality (18 alerts)

Commit 2 — 13 alerts (e46160dbb8)

Build/dev scripts shifted from shell-interpolated execSync to argv-form execFileSync / execFile, plus a TOCTOU collapse and two fetch-origin allowlists:

Test plan

  • pnpm --filter nemo-studio-ui lint — clean
  • pnpm --filter nemo-studio-ui typecheck — no new errors in non-SDK code (pre-existing duplicate-identifier errors in sdk/generated/agents/* exist on main, unrelated)
  • Targeted vitest run for touched files: util.spec.ts, useSubmitICLsFile.spec.ts, WorkspaceDashboardRoute/index.spec.tsx, useDownloadFileAsArrayBuffer.spec.ts — 42/42 passed
  • CI runs full test + typecheck + lint matrix
  • Confirm CodeQL re-scan closes the 34 alerts after merge

Summary by CodeRabbit

  • Security Improvements

    • Stronger URL validation for CDN stylesheet fetching and safer browser-opening to prevent unsafe resource access.
  • Bug Fixes

    • More reliable large-file background downloads with improved error reporting and stable transfer behavior.
  • Refactor

    • Standardized script/process execution across tooling, simplified test/page constructors, and streamlined SDK generation/formatting flows (now uses local spec files).

Review Change Stack

marcusds added 2 commits May 27, 2026 12:13
Close 21 open CodeQL alerts on main:

Security
- LargeFileWorker: remove dead `download` (untrusted-URL fetch) and `upload`
  actions; only `downloadAsFile` (SDK path-based) is used by callers. Closes
  #4 (client-side-request-forgery) and #17 (missing-origin-check).
- orval/generate.ts: use `fs.mkdtempSync` for the OpenAPI spec temp file
  instead of a predictable `os.tmpdir()` path. Closes #5
  (insecure-temporary-file).

Code-quality
- Drop redundant `this.page = page` / `this.request = request` in 11
  e2e-tests classes — TS parameter properties (`public readonly page: Page`,
  `private request: APIRequestContext`) already assign the field. Closes
  #22-#32 (useless-assignment-to-property).
- Drop redundant null/undefined checks after narrowing in
  ReportTraceModal/utils, BenchmarkDetailsPanel, api/intake/utils,
  ActionMenu, useSubmitICLsFile. Closes #33-#37.
- SafeSynthesizerJobReportRoute/util: drop unreachable `else if (score >= 8)`
  branches and the dead `UNAVAILABLE` fallback; add explicit
  `Number.isNaN` guard at the top of each grading helper. Closes #20, #21.
- WorkspaceDashboardRoute: drop inner `MODEL_COMPARE_ENABLED ? a : b`
  ternary that always picked `a` (lives inside an outer
  `MODEL_COMPARE_ENABLED &&` guard); drop now-unused
  `getWorkspaceBaseModelsRoute` import. Closes #19.

Signed-off-by: mschwab <mschwab@nvidia.com>
Drop shell interpolation in dev/build scripts so user-supplied branch names,
commit hashes, paths, and env values cannot be parsed as shell syntax. Also
plug a TOCTOU and add origin allowlists for the two http-to-file fetches.

- scripts/cherry-pick.ts: route every git call through execFileSync('git',
  [...]). Closes #6-#10 (indirect-cmd-line-injection).
- scripts/git-utils.ts: openBrowser uses execFile + argv array; status/branch
  helpers use execFileSync with argv. Removes the brittle " → \" escape and
  the shell-interpolated browser command. Closes #1
  (incomplete-sanitization) and #11 (indirect-cmd-line-injection).
- sdk/orval/format-generated.ts: prettier runs via execFileSync. Closes #2
  (shell-cmd-injection-from-env) and #13 (indirect-cmd-line-injection).
- sdk/orval/generate.ts: orval runs via execFileSync, with its parameters
  passed in env instead of interpolated into a shell string; remote spec
  fetches are restricted to an allowlist of github/gitlab hosts; the
  existsSync+readFileSync TOCTOU in postProcessZodFiles is collapsed into a
  single try/catch on ENOENT. Closes #3 (file-system-race), #12
  (indirect-cmd-line-injection), and #14 (http-to-file-access).
- studio/scripts/fetch-styles.ts: validate that the fetch URL hostname
  matches the configured Kaizen CDN before fetching. Closes #15
  (http-to-file-access).

Signed-off-by: mschwab <mschwab@nvidia.com>
@marcusds marcusds requested review from a team as code owners May 27, 2026 19:25
- scripts/git-utils.ts openBrowser: parse URL with `new URL()` and require
  http/https before spawning. Replace the Windows `cmd /c start` shell
  invocation with `rundll32 url.dll,FileProtocolHandler` so no branch goes
  through a shell. Pass `--` separator on darwin/linux so a URL starting
  with `-` cannot be parsed as an option. Closes #3951.
- sdk/orval/generate.ts: delete the unused HTTP-fetch branch from
  `getFile()`. All current `serviceConfigs` reference local YAML paths, so
  the network->file write CodeQL flagged on line 131 (#14) no longer
  exists. Throws a clear error if a remote URL is configured.

Signed-off-by: mschwab <mschwab@nvidia.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Suite Lines Covered Line Rate Branch Rate
Unit Tests 18246/24195 75.4% 61.9%
Integration Tests 11665/22977 50.8% 25.9%

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Standardizes subprocess execution to execFile/execFileSync with argv arrays, adds URL origin/protocol validation, removes remote spec support for Orval, tightens LargeFileWorker messages to download-only, and applies small TypeScript/logic simplifications across tests and UI code.

Changes

Process execution, security, and test infrastructure improvements

Layer / File(s) Summary
Git subprocess execution standardization
web/packages/scripts/src/cherry-pick.ts, web/packages/scripts/src/git-utils.ts
Cherry-pick script and git-utils migrate all git operations from shell-string execSync to execFile/execFileSync argument-array calls (fetch, checkout, pull, cherry-pick, add, push, remote get-url).
URL validation and security
web/packages/scripts/src/git-utils.ts, web/packages/studio/scripts/fetch-styles.ts
openBrowser and fetchCss parse and validate URLs, accept only HTTP(S), use encodeURIComponent for path parts, and ensure CDN host + HTTPS before proceeding.
Orval & formatter subprocess updates
web/packages/sdk/orval/format-generated.ts, web/packages/sdk/orval/generate.ts
Prettier and orval invocations use execFileSync; remote http spec URLs now throw; generation writes spec to a dedicated temp dir and cleans it up; file postprocessing uses try/catch ENOENT.
E2E test API class constructor simplification
web/packages/studio/e2e-tests/api/customizations.ts, datasets.ts, evaluations.ts, models.ts, projects.ts
API test classes use TypeScript parameter properties (private request: APIRequestContext), removing redundant this.request = request assignments.
E2E test page class constructor simplification
web/packages/studio/e2e-tests/pages/project-customizations.ts, project-datasets.ts, project-evaluations.ts, project-models.ts, project-safe-synthesizer.ts, projects.ts
Page test classes use public readonly page: Page parameter properties, removing explicit constructor assignments.
LargeFileWorker simplification and contract tightening
web/packages/studio/src/workers/LargeFileWorker.ts
Worker now only supports action: 'downloadAsFile', requires path, routes downloads through NeMo Files SDK, returns ArrayBuffer transferably, and reports errors via done/error.
Code quality and refactoring improvements
web/packages/studio/src/api/intake/utils.ts, src/components/PromptTuningForm/InContextLearningSection/hooks/useSubmitICLsFile.ts, src/components/ReportTraceModal/utils.ts, src/components/evaluation/Configurations/ActionMenu.tsx, src/components/sidePanels/BenchmarkDetailsPanel/index.tsx, src/routes/SafeSynthesizerJobReportRoute/util.ts, src/routes/WorkspaceDashboardRoute/index.tsx
Type-guard clarifications, ternary simplification, nullish checks, unconditional slotIcon rendering, metric map simplification, explicit Number.isNaN early returns, and dashboard import/href cleanup.
  • Possibly related PRs:

Suggested reviewers

  • svvarom
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main objective: addressing CodeQL TypeScript alerts across multiple files in two commits. It is concise, clear, and accurately reflects the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codeql-typescript-cleanup/mschwab

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 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 `@web/packages/scripts/src/cherry-pick.ts`:
- Around line 33-36: Remove the unconditional repository-wide staging step
(git('add', '.')) so we don't accidentally include unrelated changes; instead
update the flow in cherry-pick.ts to instruct or prompt the user to manually
stage only the resolved files (e.g., print a message like "Please stage the
resolved files and run 'git cherry-pick --continue' when ready") and then only
invoke git('cherry-pick', '--continue') after confirmation; specifically replace
the git('add', '.') call with a user prompt/notice and/or a confirmation check
before calling git('cherry-pick', '--continue').

In `@web/packages/scripts/src/git-utils.ts`:
- Around line 24-35: The current platform-specific branch builds args with a
lingering '--' before safeUrl which breaks macOS `open` and Linux `xdg-open`;
update the branches that set cmd/args (the `process.platform === 'darwin'` and
the fallback else) to remove the '--' so they set args to [safeUrl] (leave the
Windows `rundll32` branch unchanged), referencing the variables cmd, args,
safeUrl and the platform checks around them.

In `@web/packages/sdk/orval/format-generated.ts`:
- Around line 478-481: The current execFileSync('prettier', ['--write',
generatedPath], ...) call is not Windows-portable; update the call in
format-generated.ts (the execFileSync invocation) to run via a shell so .cmd
shims work on Windows by adding shell: true to the options (keep stdio and cwd
unchanged), e.g. pass { stdio: 'inherit', cwd: path.join(__dirname, '..'),
shell: true } so Prettier executes correctly on Windows and POSIX.

In `@web/packages/sdk/orval/generate.ts`:
- Around line 120-130: The execFileSync call invoking pnpm can fail on Windows
because Node cannot directly execute pnpm.cmd shims; update the invocation
around the execFileSync call that uses orvalEnv (the block with variable
orvalEnv and the execFileSync('pnpm', ['exec', 'orval'], { stdio: 'inherit',
env: orvalEnv })) to run via a shell on Windows: either set shell: true in the
execFileSync options or detect process.platform === 'win32' and invoke cmd.exe
/c pnpm ... so the pnpm.cmd/.bat shim is executed correctly while keeping stdio
and env intact.
🪄 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: CHILL

Plan: Enterprise

Run ID: f1629c8f-2618-4678-afb7-9c1e9cc1ae4b

📥 Commits

Reviewing files that changed from the base of the PR and between ba0bbfc and a42e8b5.

📒 Files selected for processing (24)
  • web/packages/scripts/src/cherry-pick.ts
  • web/packages/scripts/src/git-utils.ts
  • web/packages/sdk/orval/format-generated.ts
  • web/packages/sdk/orval/generate.ts
  • web/packages/studio/e2e-tests/api/customizations.ts
  • web/packages/studio/e2e-tests/api/datasets.ts
  • web/packages/studio/e2e-tests/api/evaluations.ts
  • web/packages/studio/e2e-tests/api/models.ts
  • web/packages/studio/e2e-tests/api/projects.ts
  • web/packages/studio/e2e-tests/pages/project-customizations.ts
  • web/packages/studio/e2e-tests/pages/project-datasets.ts
  • web/packages/studio/e2e-tests/pages/project-evaluations.ts
  • web/packages/studio/e2e-tests/pages/project-models.ts
  • web/packages/studio/e2e-tests/pages/project-safe-synthesizer.ts
  • web/packages/studio/e2e-tests/pages/projects.ts
  • web/packages/studio/scripts/fetch-styles.ts
  • web/packages/studio/src/api/intake/utils.ts
  • web/packages/studio/src/components/PromptTuningForm/InContextLearningSection/hooks/useSubmitICLsFile.ts
  • web/packages/studio/src/components/ReportTraceModal/utils.ts
  • web/packages/studio/src/components/evaluation/Configurations/ActionMenu.tsx
  • web/packages/studio/src/components/sidePanels/BenchmarkDetailsPanel/index.tsx
  • web/packages/studio/src/routes/SafeSynthesizerJobReportRoute/util.ts
  • web/packages/studio/src/routes/WorkspaceDashboardRoute/index.tsx
  • web/packages/studio/src/workers/LargeFileWorker.ts

Comment thread web/packages/scripts/src/cherry-pick.ts
Comment thread web/packages/scripts/src/git-utils.ts
Comment thread web/packages/sdk/orval/format-generated.ts Outdated
Comment thread web/packages/sdk/orval/generate.ts Outdated
marcusds added 2 commits May 27, 2026 12:56
xdg-open does not honor -- as an option terminator; passing it as an arg
caused openBrowser to fail on Linux. URL is already validated to http(s),
so the separator wasn't load-bearing — just drop it on the Linux branch.

Codex review on PR #75.

Signed-off-by: mschwab <mschwab@nvidia.com>
- scripts/git-utils.ts: drop `--` from macOS `open` argv too. `open`'s man
  page does not document `--` as an end-of-options separator. URL is
  already validated to http(s), so the separator wasn't load-bearing.
- sdk/orval/format-generated.ts: on Windows, run prettier through
  `cmd.exe /c` so the `prettier.cmd` shim resolves. `execFileSync` on
  Windows cannot launch .cmd shims directly.
- sdk/orval/generate.ts: same Windows wrap for `pnpm exec orval`.

Signed-off-by: mschwab <mschwab@nvidia.com>
Comment thread web/packages/sdk/orval/format-generated.ts Fixed
Comment thread web/packages/sdk/orval/format-generated.ts Fixed
marcusds added 3 commits May 27, 2026 13:05
The Windows cmd.exe /c wrap added in ec7aa93 re-opened a CodeQL
data-flow finding (#3961, #3962) because generatedPath traces back to
process.argv[2]. Validate the argv against a safe-char regex at entry
so CodeQL sees it as sanitized before it flows into argv or paths.

Signed-off-by: mschwab <mschwab@nvidia.com>
CodeQL did not recognize the regex check as a sanitizer; switching to a
hardcoded Set lookup against known serviceConfigs paths so the data flow
is reducible to a finite set of literal values.

Signed-off-by: mschwab <mschwab@nvidia.com>
Replace the prettier CLI invocation with prettier's programmatic
format/resolveConfig/getFileInfo API. No subprocess means no
cmd.exe wrap, no command-line argument flow, and the CodeQL
indirect-command-line-injection / shell-cmd-injection-from-env
alerts on format-generated.ts can resolve. Also fixes the Windows
.cmd shim resolution problem CR raised, since prettier now runs
in-process.

The servicePath argv is still validated against a hardcoded Set
of known serviceConfigs paths to prevent directory traversal via
path.join.

Signed-off-by: mschwab <mschwab@nvidia.com>
Comment thread web/packages/sdk/orval/format-generated.ts Fixed
Comment thread web/packages/sdk/orval/format-generated.ts Fixed
marcusds added 2 commits May 27, 2026 13:38
CodeQL flagged the statSync -> readFileSync / writeFileSync pair in
formatWithPrettier as a file-system-race. Getting Dirent entries from
readdirSync(dir, { withFileTypes: true }) lets us check isDirectory /
isFile inline without a separate stat round-trip, closing the alert.

Signed-off-by: mschwab <mschwab@nvidia.com>
Codex flagged that getTsFiles and splitZodTagFilesIn still used the
readdir-string + statSync pattern, leaving two more file-system-race
sinks even after formatWithPrettier was converted. Switch both to
readdirSync(dir, { withFileTypes: true }) and use Dirent.isFile() /
isDirectory() inline. Removes the last statSync from this script.

Signed-off-by: mschwab <mschwab@nvidia.com>
@marcusds marcusds enabled auto-merge May 28, 2026 16:09
Copy link
Copy Markdown

@dmariali dmariali left a comment

Choose a reason for hiding this comment

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

lgtm!

@marcusds marcusds added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit cc6bb63 May 28, 2026
23 checks passed
aray12 pushed a commit that referenced this pull request May 28, 2026
* fix: address open CodeQL alerts in TypeScript code

Close 21 open CodeQL alerts on main:

Security
- LargeFileWorker: remove dead `download` (untrusted-URL fetch) and `upload`
  actions; only `downloadAsFile` (SDK path-based) is used by callers. Closes
  #4 (client-side-request-forgery) and #17 (missing-origin-check).
- orval/generate.ts: use `fs.mkdtempSync` for the OpenAPI spec temp file
  instead of a predictable `os.tmpdir()` path. Closes #5
  (insecure-temporary-file).

Code-quality
- Drop redundant `this.page = page` / `this.request = request` in 11
  e2e-tests classes — TS parameter properties (`public readonly page: Page`,
  `private request: APIRequestContext`) already assign the field. Closes
  #22-#32 (useless-assignment-to-property).
- Drop redundant null/undefined checks after narrowing in
  ReportTraceModal/utils, BenchmarkDetailsPanel, api/intake/utils,
  ActionMenu, useSubmitICLsFile. Closes #33-#37.
- SafeSynthesizerJobReportRoute/util: drop unreachable `else if (score >= 8)`
  branches and the dead `UNAVAILABLE` fallback; add explicit
  `Number.isNaN` guard at the top of each grading helper. Closes #20, #21.
- WorkspaceDashboardRoute: drop inner `MODEL_COMPARE_ENABLED ? a : b`
  ternary that always picked `a` (lives inside an outer
  `MODEL_COMPARE_ENABLED &&` guard); drop now-unused
  `getWorkspaceBaseModelsRoute` import. Closes #19.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: refactor remaining CodeQL-flagged build scripts to argv form

Drop shell interpolation in dev/build scripts so user-supplied branch names,
commit hashes, paths, and env values cannot be parsed as shell syntax. Also
plug a TOCTOU and add origin allowlists for the two http-to-file fetches.

- scripts/cherry-pick.ts: route every git call through execFileSync('git',
  [...]). Closes #6-#10 (indirect-cmd-line-injection).
- scripts/git-utils.ts: openBrowser uses execFile + argv array; status/branch
  helpers use execFileSync with argv. Removes the brittle " → \" escape and
  the shell-interpolated browser command. Closes #1
  (incomplete-sanitization) and #11 (indirect-cmd-line-injection).
- sdk/orval/format-generated.ts: prettier runs via execFileSync. Closes #2
  (shell-cmd-injection-from-env) and #13 (indirect-cmd-line-injection).
- sdk/orval/generate.ts: orval runs via execFileSync, with its parameters
  passed in env instead of interpolated into a shell string; remote spec
  fetches are restricted to an allowlist of github/gitlab hosts; the
  existsSync+readFileSync TOCTOU in postProcessZodFiles is collapsed into a
  single try/catch on ENOENT. Closes #3 (file-system-race), #12
  (indirect-cmd-line-injection), and #14 (http-to-file-access).
- studio/scripts/fetch-styles.ts: validate that the fetch URL hostname
  matches the configured Kaizen CDN before fetching. Closes #15
  (http-to-file-access).

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: close remaining CodeQL alerts re-emitted on PR scan

- scripts/git-utils.ts openBrowser: parse URL with `new URL()` and require
  http/https before spawning. Replace the Windows `cmd /c start` shell
  invocation with `rundll32 url.dll,FileProtocolHandler` so no branch goes
  through a shell. Pass `--` separator on darwin/linux so a URL starting
  with `-` cannot be parsed as an option. Closes #3951.
- sdk/orval/generate.ts: delete the unused HTTP-fetch branch from
  `getFile()`. All current `serviceConfigs` reference local YAML paths, so
  the network->file write CodeQL flagged on line 131 (#14) no longer
  exists. Throws a clear error if a remote URL is configured.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: drop -- separator for xdg-open

xdg-open does not honor -- as an option terminator; passing it as an arg
caused openBrowser to fail on Linux. URL is already validated to http(s),
so the separator wasn't load-bearing — just drop it on the Linux branch.

Codex review on PR #75.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: address CodeRabbit findings on PR #75

- scripts/git-utils.ts: drop `--` from macOS `open` argv too. `open`'s man
  page does not document `--` as an end-of-options separator. URL is
  already validated to http(s), so the separator wasn't load-bearing.
- sdk/orval/format-generated.ts: on Windows, run prettier through
  `cmd.exe /c` so the `prettier.cmd` shim resolves. `execFileSync` on
  Windows cannot launch .cmd shims directly.
- sdk/orval/generate.ts: same Windows wrap for `pnpm exec orval`.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: validate format-generated.ts servicePath argv

The Windows cmd.exe /c wrap added in ec7aa93 re-opened a CodeQL
data-flow finding (#3961, #3962) because generatedPath traces back to
process.argv[2]. Validate the argv against a safe-char regex at entry
so CodeQL sees it as sanitized before it flows into argv or paths.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: replace regex with hardcoded Set allowlist for servicePath

CodeQL did not recognize the regex check as a sanitizer; switching to a
hardcoded Set lookup against known serviceConfigs paths so the data flow
is reducible to a finite set of literal values.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: use prettier Node API instead of subprocess

Replace the prettier CLI invocation with prettier's programmatic
format/resolveConfig/getFileInfo API. No subprocess means no
cmd.exe wrap, no command-line argument flow, and the CodeQL
indirect-command-line-injection / shell-cmd-injection-from-env
alerts on format-generated.ts can resolve. Also fixes the Windows
.cmd shim resolution problem CR raised, since prettier now runs
in-process.

The servicePath argv is still validated against a hardcoded Set
of known serviceConfigs paths to prevent directory traversal via
path.join.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: use readdirSync withFileTypes to avoid statSync TOCTOU

CodeQL flagged the statSync -> readFileSync / writeFileSync pair in
formatWithPrettier as a file-system-race. Getting Dirent entries from
readdirSync(dir, { withFileTypes: true }) lets us check isDirectory /
isFile inline without a separate stat round-trip, closing the alert.

Signed-off-by: mschwab <mschwab@nvidia.com>

* fix: drop remaining statSync usages in format-generated.ts

Codex flagged that getTsFiles and splitZodTagFilesIn still used the
readdir-string + statSync pattern, leaving two more file-system-race
sinks even after formatWithPrettier was converted. Switch both to
readdirSync(dir, { withFileTypes: true }) and use Dirent.isFile() /
isDirectory() inline. Removes the last statSync from this script.

Signed-off-by: mschwab <mschwab@nvidia.com>

---------

Signed-off-by: mschwab <mschwab@nvidia.com>
Signed-off-by: Alex Ray <alray@nvidia.com>
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