-
Notifications
You must be signed in to change notification settings - Fork 24
fix(workflows): add packages: read permission to update-codeql-version.yml #163
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
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
1a2ef21
fix(workflows): add packages: read permission to update-codeql-versio…
felickz 3fa6f79
debug: temporary step to inspect codeql resolve qlpacks output
felickz ad7dac7
debug: test gh-codeql bundle install + qlpacks disk layout
felickz 711dcf9
debug: point directly at gh-codeql bundle unpack dir
felickz 216b117
debug: search go dir + resolve qlpacks with bundle codeql binary
felickz 426b42d
debug: try codeql-action codeql-bundle release asset
felickz ebfb97f
debug: list all qlpacks dir entries via tar tzf without extraction
felickz 3d531e5
fix(workflows): pin codeql/* library deps to the CLI-bundle version b…
felickz 4ec3a99
chore: mark pin-codeql-library-versions.sh executable
felickz 3835f06
fix(workflows): exclude ql/hotspots from the pack-upgrade loop
felickz ee26fcc
fix(workflows): gitignore the downloaded codeql_home CLI install dir
felickz 4e14bb4
docs(contributing): document exact-pinning of codeql/* dependencies
felickz 315fd0b
fix(workflows): exclude codeql_home from qlpack.yml discovery loops
felickz 970be4d
fix(pin-script): make library-version pinning idempotent across CLI b…
felickz 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,97 @@ | ||
| #!/usr/bin/env bash | ||
| # Pins every `codeql/<name>: '*'` dependency in this repo's qlpack.yml files to | ||
| # the exact library version shipped in the official CodeQL Bundle for a given | ||
| # CLI release. | ||
| # | ||
| # Why this exists: `codeql pack upgrade` resolves an unconstrained `'*'` | ||
| # dependency to the *latest-ever-published* version in the configured | ||
| # registry (GHCR) - completely independent of whatever CodeQL CLI version is | ||
| # pinned in `.codeqlversion`. That mismatch can jump `codeql/<lang>-all` | ||
| # several major versions ahead of what the pinned CLI actually ships/tests | ||
| # against, which can silently break analyses (see CONTRIBUTING.md's | ||
| # "Updating the pinned CodeQL CLI/library version" section for a worked | ||
| # example). Pinning these `codeql/*` deps to the exact bundle-paired version | ||
| # before running `codeql pack upgrade` makes that resolution deterministic | ||
| # and keeps every pack's declared library dependency in lockstep with the | ||
| # CLI version this repo says it supports. | ||
| # | ||
| # Usage: pin-codeql-library-versions.sh <cli-version> | ||
| # e.g. pin-codeql-library-versions.sh 2.21.4 | ||
| # | ||
| # Requires: gh (authenticated), tar, sed, find. Run from the repo root. | ||
| set -euo pipefail | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| echo "Usage: $0 <cli-version>" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| VERSION="$1" | ||
| BUNDLE_TAG="codeql-bundle-v${VERSION}" | ||
| WORKDIR="$(mktemp -d)" | ||
| trap 'rm -rf "$WORKDIR"' EXIT | ||
|
|
||
| echo "Determining codeql/* library versions bundled with CodeQL CLI ${VERSION}..." | ||
| echo "(source of truth: github/codeql-action release '${BUNDLE_TAG}', asset codeql-bundle-linux64.tar.gz)" | ||
|
|
||
| if ! gh release download "$BUNDLE_TAG" --repo github/codeql-action \ | ||
| --pattern "codeql-bundle-linux64.tar.gz" --dir "$WORKDIR" --clobber; then | ||
| echo "::error::Could not download the CodeQL Bundle for tag '${BUNDLE_TAG}' from github/codeql-action releases." >&2 | ||
| echo "Every CLI release published to github/codeql-cli-binaries should have a matching 'codeql-bundle-v<version>' release in github/codeql-action - check that the tag exists." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # List every bundled `codeql/<name>` qlpack and its exact version WITHOUT | ||
| # extracting any file contents - the bundle is large (~500MB) and we only | ||
| # need the directory listing (name + version are encoded in the path). | ||
| VERSIONS_FILE="$WORKDIR/versions.txt" | ||
| tar tzf "$WORKDIR/codeql-bundle-linux64.tar.gz" \ | ||
| | grep -E '^codeql/qlpacks/codeql/[^/]+/[^/]+/$' \ | ||
| | sed -E 's#^codeql/qlpacks/codeql/([^/]+)/([^/]+)/$#\1 \2#' \ | ||
| | sort -u > "$VERSIONS_FILE" | ||
|
|
||
| echo "Discovered $(wc -l < "$VERSIONS_FILE") bundled codeql/* packages for CLI ${VERSION}." | ||
|
|
||
| # Every real qlpack.yml in the repo, excluding gitignored local build | ||
| # artifacts (.codeql/ pack caches, the /codeql cloned-repo checkout dir). | ||
| mapfile -t QLPACK_FILES < <(find . -name qlpack.yml -not -path "*/.codeql/*" -not -path "./codeql/*") | ||
|
|
||
| declare -A PINNED_COUNT=() | ||
| while read -r pkg ver; do | ||
| [[ -z "$pkg" ]] && continue | ||
| count=0 | ||
| for file in "${QLPACK_FILES[@]}"; do | ||
| # Only touch lines declaring an unconstrained `codeql/<pkg>: '*'` (or | ||
| # unquoted / double-quoted `*`) dependency; any trailing comment is left | ||
| # untouched since the substitution only replaces the matched quote-star-quote. | ||
| if grep -qE "^[[:space:]]*codeql/${pkg}:[[:space:]]*[\"']?\\*[\"']?[[:space:]]*(#.*)?\$" "$file"; then | ||
| sed -i -E "s#^([[:space:]]*codeql/${pkg}:[[:space:]]*)([\"']?)\\*\\2#\\1\\2${ver}\\2#" "$file" | ||
| count=$((count + 1)) | ||
| fi | ||
|
felickz marked this conversation as resolved.
Outdated
|
||
| done | ||
| if [[ $count -gt 0 ]]; then | ||
| PINNED_COUNT["$pkg@$ver"]=$count | ||
| fi | ||
| done < "$VERSIONS_FILE" | ||
|
|
||
| echo | ||
| echo "Pinned codeql/* dependencies:" | ||
| for key in "${!PINNED_COUNT[@]}"; do | ||
| echo " - ${key} (${PINNED_COUNT[$key]} file(s))" | ||
| done | sort | ||
|
|
||
| # Surface any remaining unconstrained codeql/* dependency that this script | ||
| # did NOT pin (e.g. it isn't one of the standard per-language bundle | ||
| # packages) so it doesn't silently keep resolving to registry-latest. | ||
| echo | ||
| echo "codeql/* dependencies left unpinned (not found in the CodeQL Bundle):" | ||
| REMAINING=0 | ||
| for file in "${QLPACK_FILES[@]}"; do | ||
| if grep -qE "^[[:space:]]*codeql/[A-Za-z0-9_.-]+:[[:space:]]*[\"']?\*[\"']?[[:space:]]*(#.*)?\$" "$file"; then | ||
| grep -nE "^[[:space:]]*codeql/[A-Za-z0-9_.-]+:[[:space:]]*[\"']?\*[\"']?[[:space:]]*(#.*)?\$" "$file" | sed "s#^# ${file}:#" | ||
| REMAINING=1 | ||
| fi | ||
| done | ||
| if [[ "$REMAINING" -eq 0 ]]; then | ||
| echo " (none)" | ||
| fi | ||
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.