Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions .github/actions/setup-just/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
name: Set up shared tooling
description: Install the locked published package and declared base tools.

inputs:
profile:
description: Full tooling, or security scanners without Cargo and paper tools.
default: full

runs:
using: composite
steps:
- name: Validate tooling profile
shell: bash
env:
TOOLING_PROFILE: ${{ inputs.profile }}
run: |
case "$TOOLING_PROFILE" in
full|security) ;;
*) echo "Unsupported tooling profile: $TOOLING_PROFILE" >&2; exit 1 ;;
esac

- name: Install declared uv
uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
with:
Expand All @@ -14,8 +29,10 @@ runs:
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.cache/research-repo-tools
key: managed-tools-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pyproject.toml','rust-toolchain.toml','.python-version','tooling/papers.toml') }}
restore-keys: managed-tools-${{ runner.os }}-${{ runner.arch }}-
key: >-
managed-tools-${{ runner.os }}-${{ runner.arch }}-${{ inputs.profile }}-${{
hashFiles('pyproject.toml','rust-toolchain.toml','.python-version','tooling/papers.toml') }}
restore-keys: managed-tools-${{ runner.os }}-${{ runner.arch }}-${{ inputs.profile }}-

- name: Install the locked tooling package
shell: bash
Expand All @@ -28,9 +45,17 @@ runs:
run: uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain sync-binaries

- name: Install and export declared base tools
if: inputs.profile == 'full'
shell: bash
run: |
set -euo pipefail
uv run --locked --managed-python --only-group tooling research-repo-tools toolchain sync
uv sync --locked --managed-python --group dev --group papers
uv run --locked --no-sync --no-python-downloads research-repo-tools toolchain export

- name: Install security Python tools
if: inputs.profile == 'security'
shell: bash
run: |
set -euo pipefail
uv sync --locked --managed-python --only-group security
12 changes: 3 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ updates:
groups:
actions:
patterns: ['*']
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
cooldown:
default-days: 7
groups:
python:
patterns: ['*']
# Hosted uv updates reject the inherited Python >=3.15 baseline. Restore this
# ecosystem after dependabot/dependabot-core#16524 is resolved. Keep the
# dependency graph and OSV scans enabled; use just update-python-dependencies.
2 changes: 2 additions & 0 deletions .github/settings/actions-selected.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"github_owned_allowed": false,
"verified_allowed": false,
"patterns_allowed": [
"acgetchell/research-repo-tools/.github/workflows/dependabot-approve.yml@*",
"actions/cache@*",
"actions/checkout@*",
"actions/upload-artifact@*",
"astral-sh/setup-uv@*",
"dependabot/fetch-metadata@*",
"github/codeql-action/analyze@*",
"github/codeql-action/init@*",
"github/codeql-action/upload-sarif@*"
Expand Down
14 changes: 14 additions & 0 deletions .github/settings/main-ruleset.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"do_not_enforce_on_create": true,
"strict_required_status_checks_policy": true,
"required_status_checks": [
{"context": "Analyze (actions)", "integration_id": 15368},
{"context": "Analyze (python)", "integration_id": 15368},
{"context": "Tooling validation", "integration_id": 15368},
{"context": "Gitleaks secret scan", "integration_id": 15368},
{"context": "OSV dependency scan", "integration_id": 15368},
Expand All @@ -36,6 +38,18 @@
{"context": "CodeRabbit", "integration_id": 347564}
]
}
},
{
"type": "code_scanning",
"parameters": {
"code_scanning_tools": [
{
"tool": "CodeQL",
"alerts_threshold": "errors",
"security_alerts_threshold": "high_or_higher"
}
]
}
}
]
}
4 changes: 4 additions & 0 deletions .github/settings/workflow-permissions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"default_workflow_permissions": "read",
"can_approve_pull_request_reviews": true
}
38 changes: 38 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Dependabot approval and auto-merge

# Trusted base-branch policy; the shared job never checks out or runs PR code.
on: # zizmor: ignore[dangerous-triggers]
pull_request_target:
types: [opened, reopened, ready_for_review, synchronize]
branches: [main]

permissions: {}

concurrency:
group: dependabot-auto-merge-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
approve-and-enable-auto-merge:
permissions:
contents: write
pull-requests: write
# Exact published research-repo-tools v0.2.3 source, reviewed for this caller.
uses: acgetchell/research-repo-tools/.github/workflows/dependabot-approve.yml@4085125526e21b2855eb7c61a52ee312782ae31a
with:
repository: acgetchell/Papers
policy: >-
{"github_actions": {
"files": [
".github/actions/setup-just/action.yml",
".github/workflows/ci.yml",
".github/workflows/codeql.yml",
".github/workflows/dependabot-auto-merge.yml",
".github/workflows/gitleaks.yml",
".github/workflows/osv.yml",
".github/workflows/papers.yml",
".github/workflows/zizmor.yml"
]
}, "uv": {
"files": ["pyproject.toml", "uv.lock"]
}}
4 changes: 3 additions & 1 deletion .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ jobs:
fetch-depth: 0
persist-credentials: false
- uses: $/.github/actions/setup-just
with:
profile: security
- name: Scan reachable history and current files
id: scan
run: just security-secrets
run: uv run --locked --no-sync just security-secrets
- name: Retain redacted security reports
if: ${{ !cancelled() && steps.scan.outcome != 'skipped' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/osv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ jobs:
with:
persist-credentials: false
- uses: $/.github/actions/setup-just
with:
profile: security
- name: Audit the root Python lockfile
id: scan
run: just security-osv
run: uv run --locked --no-sync just security-osv
- name: Retain dependency scan reports
if: ${{ !cancelled() && steps.scan.outcome != 'skipped' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ jobs:
with:
persist-credentials: false
- uses: $/.github/actions/setup-just
with:
profile: security
- name: Audit Actions using the shared tooling
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p target/security
just security-workflows --require-online --format sarif > target/security/zizmor.sarif
uv run --locked --no-sync just security-workflows --require-online --format sarif > target/security/zizmor.sarif
- name: Upload workflow security analysis
if: >-
always() && hashFiles('target/security/zizmor.sarif') != '' &&
Expand Down
28 changes: 25 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ for native auto-merge. It fails on selection or compilation failure. When no
paper is affected it passes without compiling; the remaining required reviews,
CI, and security checks still apply.

The CodeQL Actions and Python analysis jobs are required. Hosted code-scanning
protection also blocks CodeQL error-level alerts and high or critical security
alerts; a successful analysis job alone does not mean its findings are accepted.

The hosted ruleset requires CODEOWNER approval for `.coderabbit.yaml`,
`.coderabbit.yml`, and `.github/**`, including CODEOWNERS itself. Paper files
have no human ownership requirement, so eligible paper PRs can still receive
Expand Down Expand Up @@ -76,9 +80,27 @@ Run `just security` to compose the root lockfile and full-history/current-input
scans, or select `just security-osv` and `just security-secrets` individually.
They use the shared managed scanners. Use `just security-workflows --require-online`
for authenticated workflow-security auditing.
Workflows use read-only repository permissions and pinned external actions.
Dependabot proposes Python and Actions updates; maintainers review them before
merging. CodeRabbit is configured for automatic PR and incremental review,
Gitleaks, OSV, and zizmor use the lightweight `security` dependency group and
the shared verified binary installer. Their CI setup does not install Cargo
tools or paper dependencies. Full tooling and paper jobs keep their existing
setup profile.

Workflows use read-only permissions by default and pinned external actions.
Dependabot proposes Actions updates. The pinned shared approval workflow
verifies Dependabot identity, signed commits, exact changed-file policy, and
the current head before approving and enabling native auto-merge. Required
checks, resolved threads, and human CODEOWNER review still apply; an Actions
approval does not satisfy the human owner requirement for `.github/**`.

Hosted uv updates are paused because Dependabot rejects the inherited Python
3.15 baseline. Use `just update-python-dependencies` and `just ci` for Python
maintenance, and the shared adoption commands for shared-package upgrades.
Keep the dependency graph, security alerts, and OSV scans enabled. Graph-update
jobs may still report the same upstream limitation. Restore uv updates after
[Python 3.15 support](https://github.com/dependabot/dependabot-core/issues/16524)
is available; do not lower the inherited baseline to accommodate the updater.

CodeRabbit is configured for automatic PR and incremental review,
including drafts, and approves eligible low merge-risk PRs after its findings
are addressed and the latest commit is reviewed. Automatic approval is disabled
for PRs changing `.github/**`; the hosted CODEOWNER rule also protects approval
Expand Down
60 changes: 51 additions & 9 deletions docs/SECURING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ policy files document the expected configuration and validate workflow changes.

- Enable secret scanning, secret push protection, Dependabot alerts/security
updates, and private vulnerability reporting.
- Set the default Actions token permissions to read and disable Actions-created
pull request approvals. Jobs elevate only the permissions they need.
- Set default Actions token permissions to read. Permit Actions-created PR
approvals for the trusted shared Dependabot workflow using
[workflow-permissions.json](../.github/settings/workflow-permissions.json);
jobs elevate only the permissions they need.
- Permit only the explicit action patterns in
[actions-selected.json](../.github/settings/actions-selected.json), with verified
publishers and GitHub-owned actions not broadly allowed. Require full commit SHA pins.
Expand Down Expand Up @@ -38,19 +40,18 @@ Paper files have no CODEOWNER entry. Their existing one-approval requirement
can still be satisfied by CodeRabbit, subject to its low merge-risk policy and
all required checks. No blanket human approval is required for ordinary papers.

PR #3 introduces the ownership map, so path-specific enforcement begins after
it is merged into `main`. The hosted requirement is enabled before that merge;
it cannot assign an owner while the base branch has no CODEOWNERS file.
`@acgetchell` is currently the only human collaborator. GitHub does not permit
self-approval, so maintainer-authored control changes, including this bootstrap
PR, require deliberate manual review and use of the existing administrator
self-approval, so maintainer-authored control changes require deliberate manual
review and use of the existing administrator
bypass, or an additional trusted human code owner. Automation must not use
that bypass. See [GitHub's CODEOWNERS documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).

## Required checks

| Check | Provider |
| --- | --- |
| Analyze (actions) | GitHub Actions |
| Analyze (python) | GitHub Actions |
| Changed paper builds | GitHub Actions |
| CodeRabbit | CodeRabbit GitHub App |
| GitHub Actions Security Analysis | GitHub Actions |
Expand All @@ -66,6 +67,13 @@ Changes to shared paper tooling, including the root Justfile, rebuild all
standalone sources. This required check applies to native auto-merge as well as
manual merging.

The hosted ruleset also requires CodeQL scanning results. It blocks error-level
alerts and high or critical security alerts, independently of the analysis jobs'
success status. CodeQL already runs for Actions and Python, so this adds
enforcement without another scanner. Review severity exceptions deliberately;
the rule applies to alerts introduced on changed lines in PRs. See
[GitHub's merge-protection documentation](https://docs.github.com/en/code-security/concepts/code-scanning/merge-protection).

## Security workflows

Gitleaks and OSV run on PRs, `main` pushes, weekly schedules, and manual dispatch
Expand All @@ -74,6 +82,14 @@ inputs; OSV scans the root `uv.lock`. Validated JSON/SARIF security reports are
retained for seven days, including on findings. These are security reports, not
LaTeX build artifacts.

Scanner jobs select the composite setup action's `security` profile. It installs
the locked `security` Python group and uses `research-repo-tools toolchain
sync-binaries` to verify native scanner pins without Rust/Cargo builds, full
tooling, or paper dependencies. Just is provided by the inherited shared Python
tools. Tooling validation and paper compilation retain the default `full`
profile. Both profiles use the same root manifest, lockfile, and inherited
Python/tool versions.

The zizmor workflow uses the shared authenticated, required-online command and
uploads SARIF to code scanning. CodeQL covers Actions and Python; no Rust crate
or notebook workload is run in this repository. Workflow checking also enforces
Expand All @@ -98,6 +114,31 @@ on correctness and build plumbing. Review does not publish papers or refresh
their reviewer PDFs. [Blog publishing](https://github.com/acgetchell/Papers/issues/2)
has a separate scope and approval path.

## Dependency updates

Dependabot's weekly GitHub Actions updates and seven-day cooldown remain
enabled. Hosted uv version updates are paused until its updater supports the
inherited Python 3.15 baseline. Keep the dependency graph enabled: its separate
uv graph jobs may still fail until upstream support lands. OSV continues to
audit the actual root lockfile. Use `just update-python-dependencies` for
deliberate Python updates and the shared adoption flow for shared-package
upgrades, followed by `just ci`.

The Dependabot caller reuses the approval workflow at the exact
`research-repo-tools` v0.2.3 commit. It runs from trusted base-branch policy,
never checks out PR code, verifies signed Dependabot commits and current-head
identity, and accepts only explicitly listed dependency files. It then approves
and enables native squash auto-merge; CI, code scanning, thread resolution, and
human CODEOWNER requirements still gate the merge. The optional approval job is
not a required check because it intentionally skips ordinary PRs.

The hosted Actions allowlist includes the shared reusable workflow and its
pinned `dependabot/fetch-metadata` action. Default tokens remain read-only;
write permissions are limited to the approval job. Its bot approval cannot
replace `@acgetchell`'s owner approval for GitHub controls. The caller becomes
active after merging into `main`; a later Dependabot open, reopen, or push event
uses it. Rerunning an older job does not load a newly deployed caller.

## Applying settings

Enable native auto-merge with the committed repository setting:
Expand All @@ -110,7 +151,8 @@ gh api --method PATCH repos/acgetchell/Papers \
Enabling this repository setting does not arm every PR. Maintainers enable
auto-merge separately on each ready PR in GitHub or with
`gh pr merge NUMBER --repo acgetchell/Papers --auto --merge`. Drafts remain
unmergeable. No workflow grants itself approval or bypasses the ruleset.
unmergeable. The shared workflow approves only verified Dependabot updates;
it never approves ordinary PRs or bypasses the ruleset.

After reviewing a policy change, repository administrators can apply the action
allowlist with the GitHub CLI:
Expand All @@ -121,7 +163,7 @@ gh api --method PUT repos/acgetchell/Papers/actions/permissions \
gh api --method PUT repos/acgetchell/Papers/actions/permissions/selected-actions \
--input .github/settings/actions-selected.json
gh api --method PUT repos/acgetchell/Papers/actions/permissions/workflow \
-f default_workflow_permissions=read -F can_approve_pull_request_reviews=false
--input .github/settings/workflow-permissions.json
```

For the ruleset, read `gh api repos/acgetchell/Papers/rulesets`, then update the
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ requires-python = ">=3.15"
[dependency-groups]
tooling = ["research-repo-tools[python-tools]==0.2.3"]
dev = [
{ include-group = "security" },
# The shared setup command requires this direct include.
{ include-group = "tooling" },
"actionlint-py==1.7.12.25",
"shellcheck-py==0.11.0.1",
"shfmt-py==4.2.0",
"yamllint==1.38.0",
"zizmor==1.31.1",
]
papers = ["research-repo-tools[papers,python-tools]==0.2.3"]
security = [{ include-group = "tooling" }, "zizmor==1.31.1"]

[tool.uv]
package = false
Expand Down
Loading
Loading