-
Notifications
You must be signed in to change notification settings - Fork 2
Supply chain hardening for npm and actions #258
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 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
50f63f3
Avoid auto-upgrade of node "@types/vscode"
data-douser e76f456
ci: supply chain hardening for .github/workflows/**
data-douser 80111a9
Fix esbuild rebuild w/ "--ignore-scripts"
data-douser 76543db
More fixes for failing CI workflows
data-douser 563ed1d
Fix download path in dependabot-commit-dist.yml
data-douser 34d88c3
Address review feedback for PR #258
data-douser ca534c0
ci: drop dependabot-commit-dist workflow handoff
data-douser a30be1d
Apply suggestions from code review
data-douser 1cfaf0f
Update .github/workflows/build-and-test-extension.yml
data-douser 48e9791
Update .github/workflows/client-integration-tests.yml
data-douser ceafb04
Merge branch 'main' into dd/actions-hardening/1
data-douser 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
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
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
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,133 @@ | ||
| name: Dependabot Commit Dist - CodeQL Development MCP Server | ||
|
|
||
| ## Auto-rebuild and commit 'server/dist/**' on Dependabot PRs. | ||
| ## | ||
| ## Two-workflow handoff: 'build-server.yml' rebuilds with no write token | ||
| ## (npm ci --ignore-scripts), uploads the 'server-dist' artifact. This | ||
| ## workflow runs in the trusted default-branch context, downloads the | ||
| ## artifact, and pushes it to the PR branch. No PR-supplied code executes | ||
| ## here. | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ['Build Server - CodeQL Development MCP Server'] | ||
| types: [completed] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| commit-dist: | ||
| name: Commit Rebuilt server/dist to Dependabot PR Branch | ||
| runs-on: ubuntu-latest | ||
|
|
||
| if: >- | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'success' && | ||
| github.event.workflow_run.actor.login == 'dependabot[bot]' | ||
|
|
||
| permissions: | ||
| contents: write | ||
| actions: read | ||
|
|
||
| steps: | ||
| - name: Commit Dist - Validate workflow_run head | ||
| id: pr | ||
| env: | ||
| HEAD_REPO: ${{ github.event.workflow_run.head_repository.full_name }} | ||
| HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} | ||
| HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | ||
| REPO: ${{ github.repository }} | ||
| run: | | ||
| set -euo pipefail | ||
| if [ "${HEAD_REPO}" != "${REPO}" ]; then | ||
| echo "::error::Refusing to push: head repo '${HEAD_REPO}' != '${REPO}'" | ||
| exit 1 | ||
| fi | ||
| if [ -z "${HEAD_BRANCH}" ] || [ -z "${HEAD_SHA}" ]; then | ||
| echo "::error::Missing head_branch or head_sha" | ||
| exit 1 | ||
| fi | ||
| echo "branch=${HEAD_BRANCH}" >> "${GITHUB_OUTPUT}" | ||
| echo "sha=${HEAD_SHA}" >> "${GITHUB_OUTPUT}" | ||
|
|
||
| - name: Commit Dist - Checkout PR branch | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| ref: ${{ steps.pr.outputs.branch }} | ||
| persist-credentials: true | ||
| fetch-depth: 1 | ||
|
|
||
| ## Abort if the branch advanced since the build started; the next | ||
| ## build-server run will re-trigger this workflow. | ||
| - name: Commit Dist - Verify checkout matches build SHA | ||
Check failureCode scanning / CodeQL Checkout of untrusted code in trusted context High
Potential execution of untrusted code on a privileged workflow (
workflow_run Error loading related location Loading |
||
|
github-advanced-security[bot] marked this conversation as resolved.
Fixed
|
||
| id: verify | ||
| env: | ||
| EXPECTED_SHA: ${{ steps.pr.outputs.sha }} | ||
| run: | | ||
| set -euo pipefail | ||
| ACTUAL_SHA="$(git rev-parse HEAD)" | ||
| if [ "${ACTUAL_SHA}" != "${EXPECTED_SHA}" ]; then | ||
| echo "::warning::Branch advanced from ${EXPECTED_SHA} to ${ACTUAL_SHA}; skipping." | ||
| echo "skip=true" >> "${GITHUB_OUTPUT}" | ||
| else | ||
| echo "skip=false" >> "${GITHUB_OUTPUT}" | ||
| fi | ||
|
|
||
| - name: Commit Dist - Download server-dist artifact | ||
| if: steps.verify.outputs.skip == 'false' | ||
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | ||
| with: | ||
| name: server-dist | ||
| path: artifact/ | ||
| run-id: ${{ github.event.workflow_run.id }} | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| ## Defence in depth: confirm the artifact contains exactly the two | ||
| ## expected bundle files before copying into the repo. The upload | ||
| ## step in 'build-server.yml' preserves the 'server/dist/' prefix | ||
| ## relative to the workspace root, so files land under that path. | ||
| - name: Commit Dist - Verify artifact contents | ||
| if: steps.verify.outputs.skip == 'false' | ||
| run: | | ||
| set -euo pipefail | ||
| for f in server/dist/codeql-development-mcp-server.js \ | ||
| server/dist/codeql-development-mcp-server.js.map; do | ||
| if [ ! -f "artifact/${f}" ]; then | ||
| echo "::error::Missing expected artifact file: ${f}" | ||
| exit 1 | ||
| fi | ||
| done | ||
| UNEXPECTED="$(find artifact -type f \ | ||
| ! -path 'artifact/server/dist/codeql-development-mcp-server.js' \ | ||
| ! -path 'artifact/server/dist/codeql-development-mcp-server.js.map' \ | ||
| -print)" | ||
| if [ -n "${UNEXPECTED}" ]; then | ||
| echo "::error::Unexpected files in artifact:" | ||
| echo "${UNEXPECTED}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Commit Dist - Commit and push (if changed) | ||
| if: steps.verify.outputs.skip == 'false' | ||
| env: | ||
| BRANCH: ${{ steps.pr.outputs.branch }} | ||
| run: | | ||
| set -euo pipefail | ||
| cp artifact/server/dist/codeql-development-mcp-server.js server/dist/ | ||
| cp artifact/server/dist/codeql-development-mcp-server.js.map server/dist/ | ||
|
|
||
| git config user.name 'dependabot[bot]' | ||
| git config user.email '49699333+dependabot[bot]@users.noreply.github.com' | ||
| git add server/dist/codeql-development-mcp-server.js \ | ||
| server/dist/codeql-development-mcp-server.js.map | ||
|
|
||
| if git diff --cached --quiet; then | ||
| echo "::notice::server/dist already up to date." | ||
| exit 0 | ||
| fi | ||
|
|
||
| git commit -m "chore(deps): rebuild server/dist after dependency update | ||
|
|
||
| [dependabot skip]" | ||
| git push origin "HEAD:${BRANCH}" | ||
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
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.
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.