mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-10-29 07:43:26 +08:00
* fix(ci): pin workflow action references to full commit SHAs Extend the #836 pin discipline from action.yml to every workflow: all 21 external `uses:` references across the 8 workflow files now carry a full 40-hex commit SHA with a strict `# vX.Y.Z` comment, each SHA verified against the commit its version tag resolves to. Majors are unchanged (translation-sync stays on checkout v4), so behavior is identical — only the tags can no longer move. release.yml matters most: it holds the npm token and the attestation id-token, so a moved upstream tag there had credential blast radius (#841). verify-action-pins.sh now covers .github/workflows/*.yml as well. This also restores the review-requested hardening from #836 that raced the merge and never landed on main (pushed as 37fc06f eight minutes after the merge commit): full-line anchoring with a strict version comment, a directive pre-filter so commented examples are skipped, and the grep -n prefix strip. The extension surfaced why that matters immediately - without the pre-filter the check flags codeql.yml's commented setup-example line. Fixes #841 * fix(scripts): fail closed on flow-mapping uses entries and cover .yaml workflows Adversarial review of the extended check found two coverage gaps. A flow-mapping entry (`- {uses: actions/cache@v6}`) slipped past the anchored directive filter that block-style lines go through — the old unanchored grep would have flagged it, so the anchoring traded a comment false-positive for a narrow fail-open regression. The directive now matches the flow opener too, and since the pinned pattern never accepts flow syntax, such entries fail closed as unusual rather than vanishing. The file glob also only covered *.yml; GitHub executes *.yaml workflows just the same, so those join the set under nullglob (an absent glob would otherwise survive as a literal and trip the missing-file guard). * fix(scripts): scope the pin check back to action.yml The repo-level SHA-pinning setting covers this repository's own workflows at job start; the script keeps guarding the layer that setting cannot see — nested uses: inside the published composite action.yml, which only execute in consumers' workflows. Co-authored-by: wu21-web <149216116+wu21-web@users.noreply.github.com> * fix(ci): pin newly-added workflow action references to full SHAs Rebasing onto main surfaced floating tags in workflows added after this branch diverged: idea-ext.yml (checkout, gradle wrapper-validation, setup-java), ci.yml (windows job checkout, setup-go), and frontend-ext.yml (checkout, cache). Pin them to the same 40-hex SHAs used elsewhere so the whole workflow set is SHA-pinned, matching the goal of #841. * style(ci): use full version in checkout pin comments action-contract.yml and plugin-contract.yml already pin the full SHA but their trailing comments read # v7; normalize to # v7.0.1 to match the rest of the repo. Comment-only change, no behavior difference. * fix(scripts): catch quoted uses: keys in the pin-check directive A quoted mapping key ("uses": / 'uses' :) is valid YAML but did not match the directive filter, so such a line was silently skipped and a floating tag inside it escaped the check. Broaden the directive to match quoted keys and space-before-colon; the pinned pattern still rejects those forms, so they fail closed as unusual syntax rather than slipping through. Reported by wu21-web in review of #856. * fix(scripts): extend pin check to workflow files Scope verify-action-pins.sh back over .github/workflows/*.yml and *.yaml, not just action.yml. Workflows carry credentials (release.yml holds the npm token and attestation id-token), and a moved upstream tag there is not otherwise caught: floating tags reach main today, so runtime enforcement is not blocking them. The check now fails closed on any future floating reference in a workflow. All current references already pass. --------- Co-authored-by: Fanzzzd <fanzzzd@users.noreply.github.com> Co-authored-by: wu21-web <149216116+wu21-web@users.noreply.github.com> Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com> Co-authored-by: kite <lizhengfeng.lzf@alibaba-inc.com>
108 lines
5.0 KiB
YAML
108 lines
5.0 KiB
YAML
# For most projects, this workflow file will not need changing; you simply need
|
||
# to commit it to your repository.
|
||
#
|
||
# You may wish to alter this file to override the set of languages analyzed,
|
||
# or to provide custom queries or build logic.
|
||
#
|
||
# ******** NOTE ********
|
||
# We have attempted to detect the languages in your repository. Please check
|
||
# the `language` matrix defined below to confirm you have the correct set of
|
||
# supported CodeQL languages.
|
||
#
|
||
name: "CodeQL Advanced"
|
||
|
||
on:
|
||
push:
|
||
branches: [ "main" ]
|
||
pull_request:
|
||
branches: [ "main" ]
|
||
schedule:
|
||
- cron: '39 6 * * 5'
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||
cancel-in-progress: false
|
||
|
||
jobs:
|
||
analyze:
|
||
name: Analyze (${{ matrix.language }})
|
||
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
||
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
||
# - https://gh.io/supported-runners-and-hardware-resources
|
||
# - https://gh.io/using-larger-runners (GitHub.com only)
|
||
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
||
permissions:
|
||
# required for all workflows
|
||
security-events: write
|
||
|
||
# required to fetch internal or private CodeQL packs
|
||
packages: read
|
||
|
||
# only required for workflows in private repositories
|
||
actions: read
|
||
contents: read
|
||
|
||
strategy:
|
||
fail-fast: false
|
||
matrix:
|
||
include:
|
||
- language: actions
|
||
build-mode: none
|
||
- language: go
|
||
build-mode: autobuild
|
||
- language: javascript-typescript
|
||
build-mode: none
|
||
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
|
||
# Use `c-cpp` to analyze code written in C, C++ or both
|
||
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
||
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
||
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
||
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
||
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
||
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
||
steps:
|
||
- name: Checkout repository
|
||
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||
|
||
# Add any setup steps before running the `github/codeql-action/init` action.
|
||
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
||
# or others). This is typically only required for manual builds.
|
||
# - name: Setup runtime (example)
|
||
# uses: actions/setup-example@v1
|
||
|
||
# Initializes the CodeQL tools for scanning.
|
||
- name: Initialize CodeQL
|
||
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
|
||
with:
|
||
languages: ${{ matrix.language }}
|
||
build-mode: ${{ matrix.build-mode }}
|
||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||
# By default, queries listed here will override any specified in a config file.
|
||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||
|
||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
||
# queries: security-extended,security-and-quality
|
||
|
||
# If the analyze step fails for one of the languages you are analyzing with
|
||
# "We were unable to automatically build your code", modify the matrix above
|
||
# to set the build mode to "manual" for that language. Then modify this step
|
||
# to build your code.
|
||
# ℹ️ Command-line programs to run using the OS shell.
|
||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||
- name: Run manual build steps
|
||
if: matrix.build-mode == 'manual'
|
||
shell: bash
|
||
run: |
|
||
echo 'If you are using a "manual" build mode for one or more of the' \
|
||
'languages you are analyzing, replace this with the commands to build' \
|
||
'your code, for example:'
|
||
echo ' make bootstrap'
|
||
echo ' make release'
|
||
exit 1
|
||
|
||
- name: Perform CodeQL Analysis
|
||
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
|
||
with:
|
||
category: "/language:${{matrix.language}}"
|