|
1 | 1 | #!/usr/bin/env bash |
2 | | -# Pins every `codeql/<name>` dependency in this repo's qlpack.yml files to the |
3 | | -# exact library version shipped in the official CodeQL Bundle for a given CLI |
| 2 | +# Pins every `codeql/<name>` `dependencies:` entry in this repo's query/library |
| 3 | +# pack qlpack.yml files (`<language>/src`, `<language>/lib`, etc.) to the exact |
| 4 | +# library version shipped in the official CodeQL Bundle for a given CLI |
4 | 5 | # release - overwriting whatever value is currently there (an unconstrained |
5 | 6 | # `'*'`, or an exact version pinned by a previous run of this script against |
6 | 7 | # an older CLI). |
7 | 8 | # |
8 | | -# Why this exists: `codeql pack upgrade` resolves an unconstrained `'*'` |
9 | | -# dependency to the *latest-ever-published* version in the configured |
10 | | -# registry (GHCR) - completely independent of whatever CodeQL CLI version is |
11 | | -# pinned in `.codeqlversion`. That mismatch can jump `codeql/<lang>-all` |
12 | | -# several major versions ahead of what the pinned CLI actually ships/tests |
13 | | -# against, which can silently break analyses (see CONTRIBUTING.md's |
14 | | -# "Updating the pinned CodeQL CLI/library version" section for a worked |
15 | | -# example). Pinning these `codeql/*` deps to the exact bundle-paired version |
16 | | -# before running `codeql pack upgrade` makes that resolution deterministic |
17 | | -# and keeps every pack's declared library dependency in lockstep with the |
18 | | -# CLI version this repo says it supports. |
| 9 | +# Deliberately does NOT touch `<language>/ext` or `<language>/ext-library-sources` |
| 10 | +# - those are model/extension packs that declare `extensionTargets:`, not |
| 11 | +# `dependencies:`, and are excluded from this script's file list entirely. See |
| 12 | +# CONTRIBUTING.md's "Supported CodeQL versions" section ("Why `extensionTargets` |
| 13 | +# is a floor, not an exact pin") for why: unlike `dependencies:`, an unsatisfied |
| 14 | +# `extensionTargets` constraint doesn't fail loudly, it silently drops the whole |
| 15 | +# extension pack, so re-pinning it to an exact version on every CLI bump (the |
| 16 | +# way this script handles `dependencies:`) turns routine consumer CLI drift into |
| 17 | +# silent, undetected loss of coverage (GitHubSecurityLab/CodeQL-Community-Packs#206). |
| 18 | +# `extensionTargets` floors are maintained by hand instead, as open-ended ranges. |
| 19 | +# |
| 20 | +# Why this exists (for `dependencies:`): `codeql pack upgrade` resolves an |
| 21 | +# unconstrained `'*'` dependency to the *latest-ever-published* version in the |
| 22 | +# configured registry (GHCR) - completely independent of whatever CodeQL CLI |
| 23 | +# version is pinned in `.codeqlversion`. That mismatch can jump |
| 24 | +# `codeql/<lang>-all` several major versions ahead of what the pinned CLI |
| 25 | +# actually ships/tests against, which can silently break analyses (see |
| 26 | +# CONTRIBUTING.md's "Updating the pinned CodeQL CLI/library version" section |
| 27 | +# for a worked example). Pinning these `codeql/*` deps to the exact |
| 28 | +# bundle-paired version before running `codeql pack upgrade` makes that |
| 29 | +# resolution deterministic and keeps every pack's declared library dependency |
| 30 | +# in lockstep with the CLI version this repo says it supports. This is safe |
| 31 | +# for `dependencies:` (unlike `extensionTargets:`) because a genuinely |
| 32 | +# unsatisfiable `dependencies:` constraint fails loudly at `codeql pack |
| 33 | +# install`/`resolve-dependencies` time (`ERROR: No valid pack solution |
| 34 | +# found...`), and any incompatibility in the CLI-bundled `codeql/<lang>-all` |
| 35 | +# itself surfaces as an ordinary QL compile error - never a silent drop. |
19 | 36 | # |
20 | 37 | # This script is idempotent and must be re-run (with a new target version) |
21 | 38 | # on every subsequent CLI bump: once a dependency is pinned to an exact |
@@ -67,8 +84,25 @@ echo "Discovered $(wc -l < "$VERSIONS_FILE") bundled codeql/* packages for CLI $ |
67 | 84 | # artifacts (.codeql/ pack caches, the /codeql cloned-repo checkout dir, and |
68 | 85 | # /codeql_home, where .github/actions/install-codeql downloads/extracts the |
69 | 86 | # CodeQL CLI - which ships its own small vendored qlpack.yml packs, e.g. |
70 | | -# codeql/<lang>/downgrades, that have nothing to do with this repo). |
71 | | -mapfile -t QLPACK_FILES < <(find . -name qlpack.yml -not -path "*/.codeql/*" -not -path "./codeql/*" -not -path "./codeql_home/*") |
| 87 | +# codeql/<lang>/downgrades, that have nothing to do with this repo) - and |
| 88 | +# excluding every `<language>/ext` and `<language>/ext-library-sources` |
| 89 | +# model/extension pack. Those use `extensionTargets:` instead of |
| 90 | +# `dependencies:`, and deliberately do NOT get re-pinned to the exact bundle |
| 91 | +# version on every CLI bump the way `dependencies:` does here (see |
| 92 | +# CONTRIBUTING.md's "Supported CodeQL versions" section, "Why |
| 93 | +# `extensionTargets` is a floor, not an exact pin"). Unlike `dependencies:`, |
| 94 | +# an unsatisfied `extensionTargets` constraint doesn't fail loudly - the CLI |
| 95 | +# just silently drops the whole extension pack (zero data-extension rows |
| 96 | +# applied, only a low-visibility `WARNING: ... is unused`) - so constantly |
| 97 | +# re-pinning it to whatever this repo's own CI happens to test against turns |
| 98 | +# every routine consumer CLI/version mismatch into silent, undetected loss of |
| 99 | +# coverage (see GitHubSecurityLab/CodeQL-Community-Packs#206). Instead, |
| 100 | +# `extensionTargets` is set by hand as an open-ended floor |
| 101 | +# (`codeql/<lang>-all: '>=X.Y.Z'`) and only ever raised when a maintainer |
| 102 | +# confirms an actual breaking change to the models-as-data schema (e.g. an |
| 103 | +# extensible predicate's arity/column set changed) - our own test suite |
| 104 | +# failing is the trigger to look for that, not a routine CLI bump. |
| 105 | +mapfile -t QLPACK_FILES < <(find . -name qlpack.yml -not -path "*/.codeql/*" -not -path "./codeql/*" -not -path "./codeql_home/*" -not -path "*/ext/*" -not -path "*/ext-library-sources/*") |
72 | 106 |
|
73 | 107 | declare -A PINNED_COUNT=() |
74 | 108 | while read -r pkg ver; do |
|
0 commit comments