Skip to content

chore(ci): add security baseline (SECURITY.md, audit, CodeQL, dependabot, concurrency) - #2306

Open
ruflin wants to merge 1 commit into
9.xfrom
chore/ci-security-hardening
Open

ruflin wants to merge 1 commit into
9.xfrom
chore/ci-security-hardening

Conversation

@ruflin

@ruflin ruflin commented Apr 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Establish a supply-chain and security baseline for the repository:

  • SECURITY.md — documents supported branches and the private
    vulnerability-disclosure process (GitHub Security Advisories preferred,
    email fallback).
  • composer audit job in continuous-integration.yaml runs on every
    push and pull request so newly published advisories block the build
    early.
  • CodeQL workflow scans the repository's GitHub Actions with the
    security-and-quality query suite on push, pull request, and weekly
    (Mondays 06:17 UTC). PHP support is still in beta as of 2026-04, so it
    stays out of the matrix for now; the comment in the workflow explains
    how to enable it later.
  • concurrency group in CI cancels in-progress runs when a new
    commit lands on the same PR, reducing CI cost and noise.
  • dependabot.yml keeps Composer, GitHub Actions, and the Docker
    base image up to date. Composer updates are grouped (static-analysis,
    testing) to limit PR churn.

No production code changes.

Identified during a P0/P1 code-review pass.

Test plan

  • python3 -c \"import yaml; yaml.safe_load(open(...))\" validates each YAML file.
  • CI matrix (PHP 8.1–8.5) — see this PR's checks.
  • New audit job runs composer audit cleanly on the current lockfile.

Summary by CodeRabbit

  • Documentation

    • Added a security policy describing supported versions and how to report vulnerabilities for coordinated disclosure.
  • Chores

    • Enhanced CI with workflow-level concurrency to cancel redundant in-progress runs.
    • Added automated dependency vulnerability auditing during CI.
    • Introduced automated security and quality scanning coverage on pushes, pull requests, and on a weekly schedule.
    • Enabled automated dependency update checks for package, CI workflow, and container changes.

Copilot AI review requested due to automatic review settings April 30, 2026 20:37
@coderabbitai

coderabbitai Bot commented Apr 30, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds Dependabot configuration, CodeQL scanning, Composer audit checks, pull request workflow concurrency controls, a vulnerability disclosure policy, and changelog entries describing the new security automation.

Changes

Security maintenance infrastructure

Layer / File(s) Summary
Dependency update configuration
.github/dependabot.yml
Schedules Composer, GitHub Actions, and Docker updates with package grouping, pull request limits, and labels.
CI security workflows
.github/workflows/codeql.yml, .github/workflows/continuous-integration.yaml
Adds CodeQL analysis and a Composer audit job, while canceling redundant pull request workflow runs.
Security policy and release notes
SECURITY.md, CHANGELOG.md
Documents supported versions, vulnerability reporting, scope, and the new security automation.
Estimated code review effort: 2 (Simple) ~12 minutes

Possibly related PRs

  • ruflin/Elastica#2308: Adds a separate dependency-validation job to the same continuous integration workflow.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s main security and CI baseline changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/ci-security-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread SECURITY.md
@@ -0,0 +1,54 @@
# Security Policy

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the SECURITY.md file

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.

Pull request overview

Establishes a repository security/supply-chain baseline by adding a security policy, automated dependency auditing, CodeQL scanning for GitHub Actions, and Dependabot updates, along with CI run-concurrency controls.

Changes:

  • Add SECURITY.md documenting supported versions and private vulnerability reporting.
  • Add composer audit to CI plus workflow-level concurrency settings to reduce redundant PR runs.
  • Add CodeQL workflow and Dependabot configuration for Composer, GitHub Actions, and Docker.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
SECURITY.md Adds security policy, supported versions table, and reporting process.
CHANGELOG.md Documents the new security baseline work under Unreleased → Security.
.github/workflows/continuous-integration.yaml Adds composer audit job and workflow-level concurrency control.
.github/workflows/codeql.yml Adds CodeQL workflow for GitHub Actions with schedule + concurrency control.
.github/dependabot.yml Adds Dependabot update rules for Composer, Actions, and Docker.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md
Comment on lines +19 to +23
* Added a `SECURITY.md` file describing the supported branches and the private vulnerability-disclosure process.
* Added a `composer audit` job to the CI pipeline so PRs surface known advisories early.
* Added a CodeQL workflow that runs `security-and-quality` queries on the repository's GitHub Actions on every push, pull request, and weekly on a schedule.
* Added Dependabot configuration to keep Composer, GitHub Actions, and Docker dependencies up to date.
* Added a workflow `concurrency` group to cancel in-progress runs when a new commit lands on the same pull request.
on: ['push', 'pull_request']

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
- cron: '17 6 * * 1'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
pull_request:
branches: ['9.x']
schedule:
# Run weekly to catch newly published advisories.
Comment thread SECURITY.md
Comment on lines +21 to +27
a public GitHub issue**. Instead use one of the following private channels:

- Open a [GitHub Security Advisory](https://github.com/ruflin/Elastica/security/advisories/new)
on the repository (preferred).
- Or email the maintainer directly at `spam@ruflin.com` with the subject
prefix `[Elastica security]`.

…bot, concurrency)

Establish a supply-chain and security baseline for the repository:

- SECURITY.md documents the supported branches and the private
  vulnerability-disclosure process (GitHub Security Advisories or email).
- A new `audit` job in continuous-integration.yaml runs `composer audit`
  on every push and pull request so known advisories surface early.
- A new CodeQL workflow scans the repository's GitHub Actions with the
  `security-and-quality` query suite on push, pull request, and weekly.
  PHP support stays out of scope for now (CodeQL PHP analysis is still in
  beta as of 2026-04).
- A `concurrency` group cancels in-progress runs when a new commit lands
  on the same pull request, reducing CI cost and noise.
- A `dependabot.yml` keeps Composer, GitHub Actions, and the Docker base
  image up to date with grouped weekly Composer updates.

No production code changes.
@ruflin
ruflin force-pushed the chore/ci-security-hardening branch from 537f282 to ca20015 Compare July 28, 2026 21:06
uses: 'actions/checkout@v4'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
tools: 'composer:v2'

- name: 'Install dependencies with Composer'
uses: 'ramsey/composer-install@v3'

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/continuous-integration.yaml:
- Around line 9-11: Update the audit job configuration in
continuous-integration.yaml to declare minimal GITHUB_TOKEN permissions, setting
contents to read and leaving all unlisted permissions disabled.
- Around line 13-24: Update the Checkout, Setup PHP, and Install dependencies
with Composer steps to reference immutable 40-character commit SHAs instead of
mutable version tags, adding human-readable version comments for each pinned
action. Preserve the existing action configuration and keep the repository’s
Dependabot settings configured to update these pinned references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5966614c-7261-45e2-a56a-d6698eb011b1

📥 Commits

Reviewing files that changed from the base of the PR and between 537f282 and ca20015.

📒 Files selected for processing (5)
  • .github/dependabot.yml
  • .github/workflows/codeql.yml
  • .github/workflows/continuous-integration.yaml
  • CHANGELOG.md
  • SECURITY.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • SECURITY.md
  • .github/dependabot.yml
  • CHANGELOG.md

Comment on lines +9 to +11
audit:
runs-on: 'ubuntu-24.04'
name: 'Composer audit'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== workflow excerpt =="
if [ -f .github/workflows/continuous-integration.yaml ]; then
  nl -ba .github/workflows/continuous-integration.yaml | sed -n '1,140p'
else
  echo "missing .github/workflows/continuous-integration.yaml"
fi

echo
echo "== all local workflow permission declarations =="
python3 - <<'PY'
import pathlib, re
for p in sorted(pathlib.Path('.github/workflows').glob('*.ya*ml')):
    text=p.read_text()
    print(f'--- {p} ---')
    # extract workflow-level and job-level permissions blocks conservatively by indentation,
    # then print occurrences to keep focused.
    lines=text.splitlines()
    for i,l in enumerate(lines,1):
        if re.match(r'^(\s*)permissions:', l):
            indent=len(l)-len(l.lstrip())
            block=[l]
            j=i
            while j < len(lines):
                nxt=lines[j]
                if re.match(r'^(\s*)\S', nxt) and len(nxt)-len(nxt.lstrip()) <= indent and nxt.strip() != l.strip():
                    break
                j += 1
                block.append(lines[j]) if j <= len(lines) else None
            for k,line in enumerate(block):
                print(f'{i+k}: {line}')
PY

echo
echo "== default permissions in repository config =="
rg -n "permissions:|GITHUB_TOKEN" .github/workflows || true
git ls-files .github/workflows | sort

Repository: ruflin/Elastica

Length of output: 216


🌐 Web query:

GitHub Actions workflow syntax permissions contents read job permissions actions set permissions for GITHUB_TOKEN

💡 Result:

In GitHub Actions, you can configure the permissions granted to the GITHUB_TOKEN using the permissions key in your workflow file [1][2]. This allows you to follow the principle of least privilege by granting only the minimum access required for your jobs [2][3]. Permissions can be defined at two levels: 1. Workflow level: If specified at the top level of the YAML file, the permissions apply to all jobs within the workflow [1][4]. 2. Job level: If specified within a specific job, these permissions override any workflow-level settings for that job [1][4]. When you use the permissions key, any permissions not explicitly listed are set to none [1][3]. For example, if you set only contents: read, all other permissions (such as actions, issues, or packages) will have no access [1][4][3]. Example syntax for setting contents: read: jobs: job_id: runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v4 The contents: read setting is commonly used to allow the workflow to clone or fetch the repository code [5][6]. If your workflow requires additional actions, such as pushing changes or creating releases, you must explicitly set the necessary permissions to write [6]. Key points to remember: - write permissions include read permissions [1]. - If you do not define the permissions key, GitHub applies the default permissions for the repository [6]. - Pull requests from public forks are a special case; they receive a read-only token regardless of these settings [3]. For a complete list of available scopes (such as actions, checks, deployments, packages, etc.), refer to the official GitHub Actions workflow syntax documentation [1][3].

Citations:


🏁 Script executed:

#!/bin/sh
set -euo pipefail

echo "== workflow excerpt =="
awk '{printf "%6d  %s\n", NR, $0}' .github/workflows/continuous-integration.yaml | sed -n '1,160p'

echo
echo "== all local workflow permission declarations =="
python3 - <<'PY'
import pathlib, re
pdir = pathlib.Path('.github/workflows')
pdir.mkdir(parents=True, exist_ok=True)
for p in sorted(pdir.glob('*.yml')) + sorted(pdir.glob('*.yaml')):
    text = p.read_text()
    print(f'--- {p} ---')
    lines = text.splitlines()
    for i, l in enumerate(lines, 1):
        if re.match(r'^(\s*)permissions:', l):
            indent = len(l) - len(l.lstrip())
            block = [l]
            j = i
            while j < len(lines):
                nxt = lines[j]
                if re.match(r'^(\s*)\S', nxt) and len(nxt) - len(nxt.lstrip()) <= indent and nxt.strip() != l.strip():
                    break
                j += 1
                if j <= len(lines):
                    block.append(lines[j])
            for k, line in enumerate(block):
                print(f'{i+k}: {line}')
PY

echo
echo "== GITHUB_TOKEN / permissions occurrences =="
grep -RInE 'permissions:|GITHUB_TOKEN' .github/workflows || true
git ls-files .github/workflows | sort

Repository: ruflin/Elastica

Length of output: 7313


Declare minimal permissions for the audit job.

continuous-integration.yaml has no workflow-level permissions, so this job inherits the repository’s default GITHUB_TOKEN permissions while executing external actions. Set contents: read here; unlisted permissions will be none.

🧰 Tools
🪛 zizmor (1.28.0)

[warning] 9-29: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block

(excessive-permissions)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/continuous-integration.yaml around lines 9 - 11, Update
the audit job configuration in continuous-integration.yaml to declare minimal
GITHUB_TOKEN permissions, setting contents to read and leaving all unlisted
permissions disabled.

Source: Linters/SAST tools

Comment on lines +13 to +24
- name: 'Checkout'
uses: 'actions/checkout@v4'

- name: 'Setup PHP'
uses: 'shivammathur/setup-php@v2'
with:
php-version: '8.4'
coverage: 'none'
tools: 'composer:v2'

- name: 'Install dependencies with Composer'
uses: 'ramsey/composer-install@v3'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

echo "== workflow excerpt =="
sed -n '1,80p' .github/workflows/continuous-integration.yaml 2>/dev/null || true

echo
echo "== all action uses in workflows =="
rg -n "uses:\s*[^#]+" .github/workflows || true

echo
echo "== commit/tag refs in local repo =="
git rev-parse --symbolic-full-name HEAD HEAD^ 2>/dev/null || true
git show-ref --tags 2>/dev/null | head -40 || true

Repository: ruflin/Elastica

Length of output: 4246


🌐 Web query:

GitHub Actions secure use use full commit SHA branch tag mutable action security

💡 Result:

To secure GitHub Actions workflows against supply chain attacks, it is considered a critical best practice to pin all actions to a full-length (40-character) commit SHA [1][2][3][4][5]. Why Commit SHAs are Required for Security: - Immutability: Unlike branch names (e.g., @main, @master) or version tags (e.g., @v4), which are mutable pointers that can be moved or force-pushed to different commits by anyone with write access to the action's repository, a full commit SHA is cryptographically immutable [1][3][6][7]. - Mitigation of "Retargeting" Attacks: Using mutable references leaves your workflows vulnerable to malicious code injection if an action's repository or maintainer account is compromised [8][7][9]. An attacker can update an existing tag to point to malicious code, which would then be automatically executed by your workflows without any changes to your YAML files [2][6][7]. Pinning to a SHA prevents this entirely [2][3][10]. - Organizational Enforcement: GitHub now supports organization-level policies that can enforce full commit SHA pinning [11][2][9]. When enabled, workflows using mutable references will fail, ensuring compliance across an entire organization [11][2]. Best Practices for Implementation: - Pinning Format: Always use the full 40-character commit SHA [1][3]. - Maintain Readability: To maintain clarity and support automated updates, include the human-readable version tag as a trailing comment in your workflow file [2][8][7]. Example: - uses: actions/checkout@b4ffde6 # v4.1.1 - Automate Updates: Use dependency management tools like Renovate or Dependabot to automate the maintenance of these pinned SHAs [2][3][8][7]. These tools can be configured to track the associated tags and open pull requests when new versions are released, allowing you to update your pins intentionally [2][8][10]. - Transitive Security: Be aware that the security policy applies to the entire dependency tree. If you maintain an action that uses other actions internally, ensure those sub-actions are also pinned to full commit SHAs [11][9]. - Adoption Cooldowns: To further reduce risk, some organizations adopt a "cooldown" period (e.g., 7-14 days) before updating to new pinned versions of actions, which helps catch malicious releases that are often detected quickly [9].

Citations:


🌐 Web query:

docs.github.com actions reference security hard coding commit SHA Actions

💡 Result:

Pinning GitHub Actions to a full-length commit SHA is a primary security best practice recommended by GitHub to ensure the immutability of the code executed in your workflows [1][2]. Key security considerations include: - Why it is required: Using mutable references like tags (e.g., @v1, @v4) or branch names (e.g., @main) allows the underlying code to be changed or updated silently, posing a supply-chain risk if an action's repository is compromised or a tag is moved [1][3][2]. Pinning to a full 40-character commit SHA ensures that the exact code you audited is the code that runs [4][2]. - Policy Enforcement: GitHub allows administrators to enforce SHA pinning at the repository, organization, and enterprise levels [1][5][6]. When this policy is enabled, any workflow attempting to use an action referenced by a mutable tag or branch will fail [7]. This policy applies to the entire action dependency tree, meaning any internal sub-actions referenced by an action must also be pinned to a SHA [7]. - Managing Updates: While SHA pinning provides immutability, it does not prevent you from keeping your actions up to date. The recommended practice is to pin the action to a full-length commit SHA while keeping the human-readable version as a comment (e.g., uses: actions/checkout@a1b2c3d4e5... # v4.2.0) [3][4]. Tools like Dependabot can track these version comments and automatically open pull requests to update the pinned SHA when a new release is available, providing both security and ease of maintenance [3][5][4]. - Warning against short SHAs: You should always use the full-length (40-character) commit SHA [1][4]. Shortened SHAs are insecure because they are vulnerable to collision attacks where a malicious user could craft a commit that matches the short SHA, leading to ambiguous or compromised references [2]. For detailed configuration steps, refer to GitHub's documentation on securing your workflows [1][6].

Citations:


Pin the actions to immutable commit SHAs.

.github/workflows/continuous-integration.yaml pins the audit job to mutable tags (actions/checkout@v4, shivammathur/setup-php@v2, and ramsey/composer-install@v3), so the job can run changed code without workflow changes. Use full 40-character commit SHAs with human-readable version comments, and keep Dependabot configured to update those pins.

🧰 Tools
🪛 GitHub Check: CodeQL

[warning] 17-17: Unpinned tag for a non-immutable Action in workflow or composite action
Unpinned 3rd party Action 'Continuous integration' step Uses Step uses 'shivammathur/setup-php' with ref 'v2', not a pinned commit hash


[warning] 24-24: Unpinned tag for a non-immutable Action in workflow or composite action
Unpinned 3rd party Action 'Continuous integration' step Uses Step uses 'ramsey/composer-install' with ref 'v3', not a pinned commit hash

🪛 zizmor (1.28.0)

[warning] 13-14: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false

(artipacked)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/continuous-integration.yaml around lines 13 - 24, Update
the Checkout, Setup PHP, and Install dependencies with Composer steps to
reference immutable 40-character commit SHAs instead of mutable version tags,
adding human-readable version comments for each pinned action. Preserve the
existing action configuration and keep the repository’s Dependabot settings
configured to update these pinned references.

Source: Linters/SAST tools

This branch has not been deployed

No deployments
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.

3 participants