Skip to main content

require-codeql-security-events-write

Rule catalog ID: R098

Targeted pattern scopeโ€‹

Jobs that run github/codeql-action/analyze.

What this rule reportsโ€‹

This rule reports CodeQL analysis jobs that do not grant security-events: write.

Why this rule existsโ€‹

CodeQL analysis uploads results to GitHub code scanning. Without security-events: write, those results cannot be published correctly.

โŒ Incorrectโ€‹

permissions:
contents: read

โœ… Correctโ€‹

permissions:
contents: read
security-events: write

Additional examplesโ€‹

This rule complements require-sarif-upload-security-events-write by covering CodeQL analysis jobs directly, even when they do not use a separate SARIF upload step.

ESLint flat config exampleโ€‹

import githubActions from "eslint-plugin-github-actions-2";

export default [githubActions.configs.codeScanning];

When not to use itโ€‹

Disable this rule only if CodeQL results are uploaded through a different mechanism outside the workflow.

Further readingโ€‹