diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..4b8aad8 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,31 @@ +# CodeQL static analysis of the TypeScript sources; findings appear under Security > Code scanning. +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "29 4 * * 3" + +permissions: + contents: read + +jobs: + analyze: + name: CodeQL analysis + runs-on: ubuntu-latest + permissions: + security-events: write # upload the analysis + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: github/codeql-action/init@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4 + with: + languages: javascript-typescript, actions + # Bundled and third-party code only adds noise alerts. + config: | + paths-ignore: [action/dist, dist, node_modules] + - uses: github/codeql-action/analyze@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4 diff --git a/.github/workflows/opendrs.yml b/.github/workflows/opendrs.yml index 2180827..b248d8b 100644 --- a/.github/workflows/opendrs.yml +++ b/.github/workflows/opendrs.yml @@ -1,7 +1,7 @@ # Dogfood: score this repository's own PRs and approve the low-risk ones (.opendrs.yml), and # auto-merge only those that are also a captain "quick confirm", once the required checks pass. -# Runs the RELEASED action (@v0), never the PR's own copy: a PR must not be able to edit the -# code that decides whether to approve it. +# Runs a RELEASED action, pinned to a release commit that Dependabot bumps, never the PR's own +# copy: a PR must not be able to edit the code that decides whether to approve it. name: OpenDRS on: @@ -13,17 +13,19 @@ concurrency: group: opendrs-${{ github.event.pull_request.number }} cancel-in-progress: true -# GITHUB_TOKEN only checks out and, on fork PRs, comments; the opendrs-bot app token below does -# the rest, including enabling auto-merge. permissions: contents: read - pull-requests: write - checks: read jobs: opendrs: name: Score, label and approve runs-on: ubuntu-latest + # GITHUB_TOKEN only checks out and, on fork PRs, comments; the opendrs-bot app token below does + # the rest, including enabling auto-merge. Write access is granted here, not at the top level. + permissions: + contents: read + pull-requests: write + checks: read steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -38,7 +40,7 @@ jobs: with: client-id: ${{ vars.OPENDRS_APP_CLIENT_ID }} private-key: ${{ secrets.OPENDRS_APP_PRIVATE_KEY }} - - uses: error-path/opendrs@v0 + - uses: error-path/opendrs@a746b7bd335008fcd03a8857aa0fd8c43c8190ce # v0.7.0 id: opendrs with: github-token: ${{ steps.app-token.outputs.token || github.token }} diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..8ecbeb3 --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,34 @@ +# OpenSSF Scorecard: grades this repository's supply-chain security practices and publishes the +# result to api.scorecard.dev (the README badge). The scorecard action refuses to publish if this +# workflow gains other steps, top-level write permissions or unpinned actions, so keep it this small. +name: Scorecard + +on: + push: + branches: [main] + schedule: + - cron: "17 3 * * 1" + branch_protection_rule: + workflow_dispatch: + +permissions: read-all + +jobs: + analysis: + name: Scorecard analysis + runs-on: ubuntu-latest + permissions: + security-events: write # upload the results to code scanning + id-token: write # sign the published results + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ossf/scorecard-action@23f22cd43608bae7a1f1fa2603d7314dee9538a5 # v2.6.0 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + - uses: github/codeql-action/upload-sarif@1bd86f2fdb4b86187fa4059f16f31a3202acc9ea # v4.39.4 + with: + sarif_file: results.sarif diff --git a/README.md b/README.md index 1274eae..777cb99 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ auto-approved into the merge queue while risky ones still wait for a human.** [![GitHub Marketplace](https://img.shields.io/badge/Marketplace-opendrs%20PR%20Risk%20Score%20and%20Blast%20Radius-2ea44f?logo=github)](https://github.com/marketplace/actions/opendrs-diff-risk-score) [![CI](https://github.com/error-path/opendrs/actions/workflows/ci.yml/badge.svg)](https://github.com/error-path/opendrs/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) +[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/error-path/opendrs/badge)](https://scorecard.dev/viewer/?uri=github.com/error-path/opendrs) AI agents now write and review code faster than people can read it, so human review has become the bottleneck. Most pull requests are low risk, and a few cause most incidents. opendrs measures diff --git a/docs/maintaining.md b/docs/maintaining.md index 8d6151b..a6133e5 100644 --- a/docs/maintaining.md +++ b/docs/maintaining.md @@ -42,6 +42,9 @@ A short runbook for the maintainer. git push origin v0.2.0 && git push -f origin v0 ``` + This repository's own dogfood (`.github/workflows/opendrs.yml`) pins the action by commit, so + it does not follow `v0`: bump its SHA and `# vX.Y.Z` comment in a PR, or merge Dependabot's. + 4. Create a GitHub release from the tag with the changelog section as notes, with **Publish this Action to the GitHub Marketplace** ticked: that is what updates the Marketplace listing from `action.yml`. The form refuses a `description` of 125 characters or more (a test in diff --git a/tests/action/workflows.test.ts b/tests/action/workflows.test.ts index 525fa4a..78ae166 100644 --- a/tests/action/workflows.test.ts +++ b/tests/action/workflows.test.ts @@ -65,7 +65,7 @@ describe("workflows that run the Action", () => { expect(check.name).toBeUndefined(); }); - it.each(["ci", "opendrs", "pages", "publish"])("this repo's %s workflow and its jobs have descriptive names", (file) => { + it.each(["ci", "codeql", "opendrs", "pages", "publish", "scorecard"])("this repo's %s workflow and its jobs have descriptive names", (file) => { const wf = parse(read(`.github/workflows/${file}.yml`)); // A set name, not GitHub's default (the bare file name), which says little in the Actions tab. expect(wf.name).toMatch(/[A-Z]/);