Skip to content

Commit 2e1d6c1

Browse files
Copilotdata-douser
andauthored
Pin GitHub Actions to full-length commit SHAs (#47)
* Initial plan * Pin GitHub Actions to full-length commit SHAs and add workflow instructions Agent-Logs-Url: https://github.com/advanced-security/codeql-development-template/sessions/2b09ef7b-423b-462a-93f1-8107507d935f Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> * Remove unrelated codeql-pack.lock.yml files accidentally included Agent-Logs-Url: https://github.com/advanced-security/codeql-development-template/sessions/2b09ef7b-423b-462a-93f1-8107507d935f Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> * Upgrade codeql CLI to version 2.25.2 Upgrades the codeql CLI version from 2.23.5 to 2.25.2 in an attempt to resolve unit testing failures for bundled CodeQL queries. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> Co-authored-by: Nathan Randall <data-douser@github.com>
1 parent df23b56 commit 2e1d6c1

7 files changed

Lines changed: 64 additions & 29 deletions

File tree

.github/actions/setup-codeql-environment/action.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ runs:
101101
- name: Cache QLT and CodeQL packages
102102
id: cache-codeql
103103
if: inputs.install-codeql == 'true'
104-
uses: actions/cache@v4
104+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
105105
with:
106106
path: |
107107
~/.qlt/packages
@@ -112,7 +112,7 @@ runs:
112112
113113
- name: Install QLT (CodeQL Development Toolkit)
114114
id: install-qlt
115-
uses: advanced-security/codeql-development-toolkit/.github/actions/install-qlt@main
115+
uses: advanced-security/codeql-development-toolkit/.github/actions/install-qlt@da8bc39fd7dc759c8a528b7c2e7534675c06c62c # main
116116
with:
117117
qlt-version: "latest"
118118
add-to-path: true
@@ -425,7 +425,7 @@ runs:
425425
# Language-specific setup steps with enhanced caching (only if language runtimes installation is enabled)
426426
- name: Setup Node.js
427427
if: inputs.install-language-runtimes == 'true'
428-
uses: actions/setup-node@v6
428+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
429429
with:
430430
cache: "npm"
431431
cache-dependency-path: "package-lock.json"
@@ -435,7 +435,7 @@ runs:
435435
- name: Cache language runtimes
436436
id: cache-runtimes
437437
if: inputs.install-language-runtimes == 'true'
438-
uses: actions/cache@v4
438+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
439439
with:
440440
path: |
441441
~/go/pkg/mod
@@ -449,42 +449,42 @@ runs:
449449
450450
- name: Setup Python (with cache)
451451
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'python') && steps.check-deps.outputs.python-deps == 'true'
452-
uses: actions/setup-python@v6
452+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
453453
with:
454454
python-version: ${{ inputs.python-version }}
455455
cache: "pip"
456456

457457
- name: Setup Python (without cache)
458458
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'python') && steps.check-deps.outputs.python-deps == 'false'
459-
uses: actions/setup-python@v6
459+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
460460
with:
461461
python-version: ${{ inputs.python-version }}
462462

463463
- name: Setup Java (with cache)
464464
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'java') && steps.check-deps.outputs.java-deps == 'true'
465-
uses: actions/setup-java@v5
465+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
466466
with:
467467
distribution: "temurin"
468468
java-version: ${{ inputs.java-version }}
469469
cache: "maven"
470470

471471
- name: Setup Java (without cache)
472472
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'java') && steps.check-deps.outputs.java-deps == 'false'
473-
uses: actions/setup-java@v5
473+
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
474474
with:
475475
distribution: "temurin"
476476
java-version: ${{ inputs.java-version }}
477477

478478
- name: Setup Go (with cache)
479479
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'go') && steps.check-deps.outputs.go-deps == 'true'
480-
uses: actions/setup-go@v6
480+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
481481
with:
482482
go-version: ${{ inputs.go-version }}
483483
cache: true
484484

485485
- name: Setup Go (without cache)
486486
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'go') && steps.check-deps.outputs.go-deps == 'false'
487-
uses: actions/setup-go@v6
487+
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6
488488
with:
489489
go-version: ${{ inputs.go-version }}
490490
cache: false
@@ -493,7 +493,7 @@ runs:
493493
- name: Cache .NET packages
494494
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'csharp')
495495
id: cache-dotnet-packages
496-
uses: actions/cache@v4
496+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
497497
with:
498498
path: |
499499
~/.nuget/packages
@@ -505,20 +505,20 @@ runs:
505505
506506
- name: Setup .NET (for C#)
507507
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'csharp')
508-
uses: actions/setup-dotnet@v5
508+
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
509509
with:
510510
dotnet-version: ${{ inputs.dotnet-version }}
511511

512512
- name: Setup Ruby (with cache)
513513
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'ruby') && steps.check-deps.outputs.ruby-deps == 'true'
514-
uses: ruby/setup-ruby@v1
514+
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1
515515
with:
516516
ruby-version: ${{ inputs.ruby-version }}
517517
bundler-cache: true
518518

519519
- name: Setup Ruby (without cache)
520520
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'ruby') && steps.check-deps.outputs.ruby-deps == 'false'
521-
uses: ruby/setup-ruby@v1
521+
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1
522522
with:
523523
ruby-version: ${{ inputs.ruby-version }}
524524
bundler-cache: false
@@ -527,7 +527,7 @@ runs:
527527
- name: Cache C++ build tools
528528
if: inputs.install-language-runtimes == 'true' && contains(inputs.languages, 'cpp')
529529
id: cache-cpp-tools
530-
uses: actions/cache@v4
530+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
531531
with:
532532
path: |
533533
~/.ccache
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
applyTo: '.github/{actions,workflows}/**/*.{yml,yaml}'
3+
description: 'Instructions for editing GitHub Actions workflows for this repository.'
4+
---
5+
6+
# Copilot Instructions for `.github/{actions,workflows}/**/*.{yml,yaml}` files
7+
8+
## PURPOSE
9+
10+
This file contains instructions for working with GitHub Actions YAML files in the `.github/actions/` and `.github/workflows/` directories of the `codeql-development-template` repository.
11+
12+
## REQUIREMENTS
13+
14+
- **ALWAYS pin ALL external GitHub Actions to full-length commit SHAs, never to tags or branch names — including GitHub-maintained `actions/*` actions.** Add a trailing comment with the original tag for readability (e.g., `uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6`). To resolve a tag to its underlying commit SHA (handling annotated tags correctly), run `git ls-remote https://github.com/OWNER/REPO.git refs/tags/TAG^{}`; for branch-based refs, use `refs/heads/BRANCH`.
15+
- ALWAYS use the principle of least privilege, and explicitly set `permissions` for workflows.
16+
- ALWAYS use valid YAML syntax and follow GitHub Actions workflow conventions.
17+
- ALWAYS follow best practices for GitHub Actions workflows including security, efficiency, and maintainability.
18+
- ALWAYS use descriptive names for workflows, jobs, and steps that clearly explain their purpose.
19+
- ALWAYS check formatting with `npm run lint && npm run format:check` from the repo root directory to ensure consistent formatting after making changes.
20+
- ALWAYS fix linting and formatting errors by running `npm run lint:fix && npm run format` from the repo root directory before committing changes.
21+
22+
## PREFERENCES
23+
24+
- PREFER explicit permissions declarations using the `permissions` key for security.
25+
- PREFER descriptive step names that include the workflow context (e.g., "Lint and Format - Checkout repository").
26+
- PREFER matrix strategies for testing multiple versions when applicable.
27+
- PREFER adding summary outputs using `$GITHUB_STEP_SUMMARY` for better workflow visibility.
28+
29+
## CONSTRAINTS
30+
31+
- **NEVER reference an external GitHub Action by tag or branch name (e.g., `@v6`, `@main`). ALWAYS use the full 40-character commit SHA with a `# tag` comment.**
32+
- NEVER use overly broad permissions.
33+
- NEVER leave any trailing whitespace on any line.
34+
- NEVER use deprecated GitHub Actions or workflow syntax.
35+
- NEVER commit workflow files without running the formatting checks first.

.github/workflows/codeql-qlt-unit-tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
has_languages: ${{ steps.find-languages.outputs.has_languages }}
3131
steps:
3232
- name: Checkout repository
33-
uses: actions/checkout@v6
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3434

3535
- name: Setup CodeQL environment for discovering unit tests
3636
uses: ./.github/actions/setup-codeql-environment
@@ -102,7 +102,7 @@ jobs:
102102

103103
steps:
104104
- name: Checkout repository
105-
uses: actions/checkout@v6
105+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
106106

107107
- name: Setup CodeQL environment for executing `qlt` unit tests
108108
uses: ./.github/actions/setup-codeql-environment
@@ -153,7 +153,7 @@ jobs:
153153
- name: Upload test results
154154
# Upload results even if tests failed, but only if the language is valid
155155
if: ${{ always() && matrix.language && matrix.language != 'unknown' }}
156-
uses: actions/upload-artifact@v7
156+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
157157
with:
158158
name: qlt-test-results-${{ matrix.language }}-${{ runner.os }}
159159
path: |
@@ -167,7 +167,7 @@ jobs:
167167
runs-on: ubuntu-latest
168168
steps:
169169
- name: Checkout repository
170-
uses: actions/checkout@v6
170+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
171171

172172
- name: Setup CodeQL environment for validating `qlt` unit tests
173173
uses: ./.github/actions/setup-codeql-environment
@@ -177,7 +177,7 @@ jobs:
177177
install-ql-packs: false
178178

179179
- name: Download CodeQL unit test results
180-
uses: actions/download-artifact@v8
180+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
181181
with:
182182
pattern: qlt-test-results-*
183183
path: test-results/

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Copilot Setup - Checkout code
32-
uses: actions/checkout@v6
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3333

3434
- name: Copilot Setup - Setup CodeQL environment
3535
uses: ./.github/actions/setup-codeql-environment

.github/workflows/lint-and-format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ jobs:
3535

3636
steps:
3737
- name: Checkout repository
38-
uses: actions/checkout@v6
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3939

4040
- name: Setup Node.js
41-
uses: actions/setup-node@v6
41+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
4242
with:
4343
cache: "npm"
4444
node-version-file: "package.json"

languages/qlt.conf.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"CodeQLCLI": "2.23.5",
3-
"CodeQLStandardLibrary": "codeql-cli/v2.23.5",
4-
"CodeQLCLIBundle": "codeql-bundle-v2.23.5"
2+
"CodeQLCLI": "2.25.2",
3+
"CodeQLStandardLibrary": "codeql-cli/v2.25.2",
4+
"CodeQLCLIBundle": "codeql-bundle-v2.25.2"
55
}

qlt.conf.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"CodeQLCLI": "2.23.5",
3-
"CodeQLStandardLibrary": "codeql-cli/v2.23.5",
4-
"CodeQLCLIBundle": "codeql-bundle-v2.23.5"
2+
"CodeQLCLI": "2.25.2",
3+
"CodeQLStandardLibrary": "codeql-cli/v2.25.2",
4+
"CodeQLCLIBundle": "codeql-bundle-v2.25.2"
55
}

0 commit comments

Comments
 (0)