Skip to main content
Enable CodeQL scanning for your repository and review the results for a Node.js (JavaScript/TypeScript) application using GitHub Advanced Security (GHAS). This guide shows the high-level steps to:
  • Enable CodeQL at the organization level in GitHub Enterprise Advanced Security.
  • Let the default CodeQL setup run via GitHub Actions.
  • Inspect CodeQL findings in the repository Security & Analysis -> Code scanning alerts.
  • Triage and remediate typical Node.js issues such as path traversal and missing rate limiting.
Step 1 — Enable GHAS CodeQL at the organization level Open your GitHub Enterprise settings, navigate to Advanced Security, and edit the organization Advanced Security configuration to enable code scanning (CodeQL) and other protections.
A dark-themed screenshot of a GitHub Enterprise "Advanced Security" settings page for an organization called NextGen Gaming, showing security stats (Dependabot 0%, Code Security 0%, Secret Protection 100%) and configuration options.
Within the Advanced Security configuration you can:
  • Turn on secret scanning, push protection, and code scanning.
  • Choose the CodeQL setup mode (default or advanced).
  • Leave runner selection unset to allow repository/owner-level decisions, or select GitHub-hosted vs self-hosted runners.
  • Enable options such as “prevent direct alert dismissal” to enforce tracked remediation.
A screenshot of a GitHub Enterprise "Settings" page for the NextGen Gaming organization, showing the Advanced Security "Edit configuration" screen. The page lists configuration fields and secret protection options like secret scanning, validity checks, and push protection with their enabled/disabled states.
Some Advanced Security features (for example, Dependabot version updates and CodeQL code scanning) run using GitHub Actions and therefore consume GitHub Actions minutes. Keep that in mind when enabling organization-wide CodeQL analysis.
If you enable organization-wide CodeQL, repositories will inherit the default setup and trigger workflow runs automatically. Confirm runner selection and billing implications before enabling at scale.
Step 2 — Default CodeQL setup triggers a workflow run After you save the organization-level configuration, repositories covered by the setting will trigger the default CodeQL setup. This creates a GitHub Actions workflow that initializes CodeQL and runs analysis for the languages detected (for example, JavaScript/TypeScript).
A GitHub Actions workflow run page showing "CodeQL Setup" for a repository. The "Analyze (javascript-typescript)" job is displayed with a checklist of steps (Set up job, Checkout repository, Initialize CodeQL, Perform CodeQL Analysis, etc.).
Step 3 — Review CodeQL results in Security & Analysis When the workflow completes, go to the repository’s Security & Analysis (Security and Quality) -> Code scanning alerts. CodeQL lists alerts with metadata (severity, detection time, affected branch). Clicking an alert shows the file and line, the weakness description, remediation guidance, and often code examples. You can assign alerts, link them to issues, or create a branch to fix the code. Common CodeQL alert types for Node.js Vulnerable example: unsafe path resolution This minimal Express example demonstrates the pattern CodeQL typically flags: directly joining unvalidated user input into a filesystem path.
Why this is dangerous If filename contains traversal sequences (for example ../../etc/passwd), the server may send files outside the intended directory. CodeQL flags this pattern as a path traversal/uncontrolled data in path expression. Safer alternatives
  • Use res.sendFile() with the root option to constrain file lookup to a known directory.
  • Normalize and validate filenames (e.g., path.basename, verify resolved path is within the allowed root).
  • Prefer whitelisting allowed filenames or mapping IDs to stored files rather than accepting arbitrary filenames.
Example: using root (recommended when serving from a known directory)
Example: explicit validation of the resolved path
Triage workflow tips
  • Start by reviewing the CodeQL alert description and the file/line context provided.
  • Prioritize high-severity alerts and those affecting protected branches.
  • Use CodeQL remediation guidance and the example fixes to create pull requests.
  • Assign the alert to the developer or team responsible and link to a tracking issue if needed.
Resources and further reading CodeQL alerts typically include remediation guidance, sample fixes, and links to documentation. Use those resources along with file-level details to triage, assign, and remediate vulnerabilities effectively.

Watch Video