Skip to content

fix(codeql): detect raw JS/TS source in auto language mode#241

Merged
CybotTM merged 1 commit into
mainfrom
fix/codeql-auto-detect-js
Jul 19, 2026
Merged

fix(codeql): detect raw JS/TS source in auto language mode#241
CybotTM merged 1 commit into
mainfrom
fix/codeql-auto-detect-js

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 19, 2026

Copy link
Copy Markdown
Member

Problem

The reusable CodeQL workflow's languages: auto mode added javascript-typescript only when a package.json existed or a .ts/.tsx/.mts file was found within 4 directory levels. Two gaps followed:

  1. Raw-JS repos were scanned as Go-only. A repo with a hand-written plain-JS frontend and no package.json (e.g. ldap-manager's internal/web/static/js/*.js) was detected as go only, so its JavaScript was never analyzed — a real coverage gap that hid a live js/xss-through-dom alert.
  2. It deadlocked the code_scanning merge gate. GitHub still lists javascript as an eligible language for such repos, so a code_scanning ruleset perpetually expects a JavaScript CodeQL result that auto never produces — blocking every PR (this is exactly what blocked ldap-manager for weeks).

The 4-level depth bound also never reached internal/web/static/js/*.js (depth 5), so even adding .js names alone would not have fixed it.

Change

auto now adds javascript-typescript when a package.json exists or any first-party .js/.jsx/.mjs/.cjs/.ts/.tsx/.mts/.cts source file is present:

  • node_modules/, vendor/, .git/ are pruned (third-party / not our source, and huge).
  • Depth bound raised 4 → 8 to reach nested layouts.
  • package.json is no longer required.

Impact

Repos already passing an explicit languages: list are unaffected (explicit lists still win). Go-only repos with no JS/TS stay go-only (verified). Repos with previously-unscanned first-party JS will start getting JavaScript analysis on their next run — the intended coverage improvement; this may surface new alerts.

Verification

  • actionlint clean; YAML parses.
  • Detection logic smoke-tested against four cases — depth-5 raw JS → detected; only-node_modules/vendor JS → go-only; package.json only → detected; pure-Go → go-only.

Follow-up to ldap-manager#624 (explicit languages there) and the js/xss-through-dom fix in ldap-manager#625; this closes the class at the reusable so other repos don't hit it.

The `auto` language detector added javascript-typescript only when a
package.json existed or a .ts/.tsx/.mts file was found within 4 levels.
Repos with a hand-written plain-JS frontend and no package.json (e.g.
ldap-manager's internal/web/static/js/*.js at depth 5) were detected as
go-only, so their JS was never scanned. Worse, GitHub still lists
javascript as an eligible language, so a code_scanning merge gate then
perpetually expects a JavaScript CodeQL result that never arrives,
blocking every PR.

Detect any first-party .js/.jsx/.mjs/.cjs/.ts/.tsx/.mts/.cts file,
pruning node_modules/vendor/.git, with the depth bound raised to 8 so
nested layouts are reached. package.json is no longer required.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 19, 2026 19:26
@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@sonarqubecloud

Copy link
Copy Markdown

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM merged commit fdfa64d into main Jul 19, 2026
11 of 12 checks passed
@CybotTM
CybotTM deleted the fix/codeql-auto-detect-js branch July 19, 2026 21:27
CybotTM added a commit that referenced this pull request Jul 19, 2026
Doc-only follow-up to #241. The header comment still described the old
behaviour ("first 4 levels", ignoring only `node_modules`/`vendor`)
while the implementation uses `maxdepth 8` and also prunes `.git/`. This
aligns the comment with the code — no functional change.
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.

2 participants