Repository navigation
chore(security): add OpenSSF Scorecard workflow #1671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nirmal-joishi-a0
wants to merge
1
commit into
master
Choose a base branch
from
security/add-scorecard
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| name: Scorecard analysis | ||
|
|
||
| # Runs OpenSSF Scorecard supply-chain analysis directly via ossf/scorecard-action | ||
| # (no composite wrapper, no cross-org dependency). All action refs are SHA-pinned. | ||
| # | ||
| # Scorecard requirements | ||
| # ────────────────────── | ||
| # • Supported triggers (per OSSF) are push and schedule on the default branch. | ||
| # pull_request is added below ONLY as a smoke test on a real runner from the PR. | ||
| # workflow_dispatch provides manual smoke tests after this workflow exists on the default branch. | ||
| # OSSF officially documents both triggers as EXPERIMENTAL ("The pull_request and | ||
| # workflow_dispatch triggers are experimental" — scorecard-action README); the docs do not | ||
| # detail how results differ on them. Because they are experimental, treat a PR run as a | ||
| # smoke signal only — this workflow is fully validated only after merge to the default branch. | ||
| # • The checkout step MUST set persist-credentials: false (required by Scorecard's | ||
| # security model to avoid leaking the GITHUB_TOKEN into the analysis environment). | ||
| # • publish_results: true publishes to the public Scorecard API and enables the | ||
| # Scorecard badge. It requires id-token: write on the job AND a push/schedule | ||
| # event — it must stay false on pull_request/workflow_dispatch. Set to 'false' to | ||
| # keep results private (id-token can then be omitted from the job permissions). | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['master'] | ||
| pull_request: | ||
| branches: ['master'] # EXPERIMENTAL per OSSF: smoke test only, not an authoritative result | ||
| workflow_dispatch: {} # EXPERIMENTAL per OSSF: manual re-run, available only after merge (default-branch copy) | ||
| schedule: | ||
| - cron: '30 1 * * 6' # weekly, Saturday 01:30 UTC | ||
|
|
||
| permissions: read-all # default: restrict everything; the job overrides what it needs | ||
|
|
||
| jobs: | ||
| analysis: | ||
| name: Scorecard analysis | ||
| runs-on: ubuntu-latest | ||
| # No event guard: pull_request and workflow_dispatch are allowed to run as an | ||
| # experimental smoke test (see the header). Keep publish_results: false on those | ||
| # events — publishing requires a push/schedule event and id-token: write. | ||
| permissions: | ||
| security-events: write # upload SARIF to the Security tab / Code Scanning dashboard | ||
| # id-token: write # OIDC token for Scorecard's public API publishing (publish_results: true) | ||
| # Uncomment this line only when you set publish_results: true | ||
| contents: read # checkout the repository | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| with: | ||
| persist-credentials: false # required by Scorecard — do not remove | ||
|
|
||
| - name: Run analysis | ||
| uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3 | ||
| with: | ||
| results_file: results.sarif | ||
| results_format: sarif | ||
| # publish_results: true publishes to the Scorecard public dataset and enables the badge. | ||
| # Requires id-token: write above and a push/schedule event. | ||
| # Set to 'true' (and enable id-token: write) to publish results to the Scorecard public dataset. | ||
| publish_results: false | ||
|
|
||
| # Upload SARIF as a workflow artifact (optional — comment out to disable). | ||
| # https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts | ||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: SARIF file | ||
| path: results.sarif | ||
| retention-days: 5 # adjust as needed | ||
|
|
||
| # Upload SARIF to GitHub Code Scanning dashboard (optional — comment out to disable). | ||
| # Skipped only for fork PRs: there the GITHUB_TOKEN is read-only (no security-events: write) | ||
| # and the upload fails. The guard still runs on push/schedule and on same-repo PRs, where the | ||
| # token can write. (github.event.pull_request is null on push/schedule, so !…fork is true.) | ||
| - name: Upload to code-scanning | ||
| if: ${{ !github.event.pull_request.head.repo.fork }} | ||
| uses: github/codeql-action/upload-sarif@99df26d4f13ea111d4ec1a7dddef6063f76b97e9 # v4.37.0 | ||
| with: | ||
| sarif_file: results.sarif | ||
| category: scorecard | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🌐 Web query:
GitHub Container Registry GHCR container image tag immutability can package owners overwrite tag documentation💡 Result:
🏁 Script executed:
Repository: auth0/react-native-auth0
Length of output: 4355
🌐 Web query:
GitHub Actions documentation docker:// container action image reference digest action.yml image docker:// inputs with parameters; GitHub Container Registry can existing tag be overwritten immutable tag documentation💡 Result:
🌐 Web query:
site:docs.github.com GitHub Container Registry overwrite existing container image tag digest immutable tags💡 Result:
🏁 Script executed:
Repository: auth0/react-native-auth0
Length of output: 7505
🌐 Web query:
official Docker documentation image tags mutable references tag can be moved digest immutable GitHub Actions Docker action runs.image pulls image reference each run💡 Result:
Pin the Scorecard container image by digest.
The SHA pin fixes
action.yml, butaction.ymlselectsdocker://ghcr.io/ossf/scorecard-action:v2.4.3. A tag is a mutable image reference. If the tag is moved before a later run pulls the image, different action code can execute with this job’ssecurity-events: writepermission.Use an action revision whose
runs.imagepins the GHCR image by digest, or maintain an equivalent pinned wrapper. Do not replace this step with a directdocker://reference because that bypasses the action metadata and does not preserve the configuredwithinputs.🤖 Prompt for AI Agents