Skip to main content
This guide shows how to enable CodeQL code scanning for a repository using GitHub Advanced Security (GHAS) and how to review and act on the findings. It covers enabling an enterprise- or organization-level default, inspecting the CodeQL setup workflow in Actions, and interpreting CodeQL alerts with remediation examples.

Enable an organization- or enterprise-level default for CodeQL

If CodeQL analysis is not set up for a repository, you can apply a default CodeQL configuration across repositories from the enterprise or organization Advanced Security settings. This allows administrators to choose a default CodeQL setup and runner policy (GitHub-hosted, labeled/self-hosted, or allow repository owners to select). You can also require reviews before alerts can be dismissed by enabling “prevent direct alert dismissal.”
Applying an organization- or enterprise-wide CodeQL default helps standardize scanning across repos, but it will cause CodeQL workflows to run in GitHub Actions, which can affect Actions minute usage. Dependabot PRs that trigger CI will also consume minutes.
A screenshot of GitHub Enterprise's "Advanced Security" settings showing a modal dialog titled "Apply configuration?" that notes the organization is on a GitHub Advanced Security trial until 2026-09-24 and lists license/usage details, with Cancel and Apply buttons.
After saving the enterprise-level configuration, the selected repositories will automatically receive the default CodeQL setup. You can follow the automatic setup by checking the repository’s Actions page for the CodeQL setup workflow run.

What the CodeQL setup workflow does

The CodeQL setup workflow adds and runs a GitHub Actions workflow that analyzes your code. Typical high-level steps include: You can inspect each job step and logs from the Actions run to troubleshoot or confirm configuration details.
A screenshot of a GitHub repository's Actions page showing a CodeQL Setup workflow run (Analyze (javascript-typescript)) with a list of job steps and checkmarks. The dark-themed UI displays steps like "Set up job," "Checkout repository," "Perform CodeQL Analysis," and "Complete job."
Enabling organization-level CodeQL scanning will launch GitHub Actions workflows across affected repositories. Monitor Actions usage and runner selection (GitHub-hosted vs self-hosted) to control costs and capacity.

Reviewing CodeQL results and alerts

When the CodeQL workflow completes, results appear on the repository’s Security and analysis pages (Security and quality → Code scanning). Each alert includes:
  • Severity and scanner (CodeQL)
  • Detection time and provenance
  • File path and line number
  • Description of the weakness, potential impact, and remediation suggestions
  • Links to related alerts, affected branches, and example fixes
A screenshot of a GitHub repository's "Security and quality" → "Code scanning" page in dark mode showing two open alerts. The findings listed are "Uncontrolled data used in path expression" and "Missing rate limiting," both marked High and detected by CodeQL.
You can interact with alerts to assign owners, open issues, or create a branch directly from the alert to implement fixes. CodeQL’s context and suggested fixes help triage and prioritize remediation work.

Example alert: Uncontrolled data used in path expression (path traversal)

CodeQL often flags patterns where user input is used directly to construct filesystem paths. A vulnerable example:
Why this is dangerous
  • A malicious filename containing ../ or an absolute path may allow access to files outside the intended directory, exposing sensitive data.
  • CodeQL labels these as “Uncontrolled data used in path expression” or similar.
Recommended mitigations
  • Use Express’s res.sendFile with the root option to restrict served files to a known directory:
  • Normalize and validate user input to prevent directory traversal:
  • Prefer a strict allowlist (recommended) when possible:

Quick remediation table

Next steps and references

  • After reviewing an alert: assign it, link to an issue, or create a branch from the alert to implement fixes.
  • Monitor CodeQL runs and Actions minute usage to balance security coverage and cost.
  • Use organization-level settings to standardize scanning policies and require review before dismissals.
Relevant documentation: Review CodeQL alert details for tailored remediation examples and apply fixes following your repository’s development workflow to keep your codebase secure.

Watch Video