Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 27, 2025

Issue

The extension was incorrectly passing TypeScript files to CodeQL using typescript-queries instead of javascript-queries, causing scans to fail. According to CodeQL documentation, TypeScript files should be analyzed using JavaScript queries.

Root Cause

When languages were auto-detected from GitHub or manually configured, the original language names (like "typescript") were sometimes used instead of the properly mapped CodeQL language names (like "javascript"). This happened because the language mapping was only applied during initial auto-detection, not consistently throughout the analysis flow.

Fix

Added an additional language mapping step in runLocalScan() to ensure all languages are consistently mapped to CodeQL languages, regardless of whether they come from:

  • Auto-detection from GitHub repository languages
  • Manual configuration in VS Code settings

Key Changes

  • Modified runLocalScan() in codeqlService.ts to always apply language mapping
  • TypeScript files now correctly use codeql/javascript-queries instead of codeql/typescript-queries
  • Database paths, output files, and query suites use the correct language mapping
  • Fix works for both auto-detection and manual language configuration scenarios

Before

# Failed command that was generated
codeql database analyze [...] "codeql/typescript-queries:codeql-suites/typescript-code-scanning.qls"

After

# Correct command now generated
codeql database analyze [...] "codeql/javascript-queries:codeql-suites/javascript-code-scanning.qls"

Testing

  • Verified fix handles auto-detection, manual configuration, and mixed scenarios
  • Confirmed TypeScript files are consistently mapped to JavaScript for CodeQL analysis
  • Database paths now use /javascript instead of /typescript
  • Output files now use repo-javascript-hash.sarif instead of repo-typescript-hash.sarif

Fixes #6.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] BUG: Extension passes Typescript to CodeQL for query packs instead of Javascript Fix TypeScript to JavaScript mapping in CodeQL analysis Jun 27, 2025
Copilot AI requested a review from felickz June 27, 2025 20:48
@felickz
Copy link
Collaborator

felickz commented Jun 28, 2025

Seems like a sensible fix

@GeekMasher GeekMasher marked this pull request as ready for review June 30, 2025 09:49
@GeekMasher GeekMasher merged commit dae8af3 into main Jun 30, 2025
5 checks passed
@GeekMasher GeekMasher deleted the copilot/fix-6 branch June 30, 2025 09:49
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.

BUG: Extension passes Typescript to CodeQL for query packs instead of Javascript

3 participants