Repository navigation
Merge v22 patches from v22.21.1 branch #29
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
Changes from all commits
6f70fb0
a8d4c9b
0c1288a
5e0424e
2d64ee8
b9b6b32
b577cda
ba48e86
9977ae6
2118248
5122fc2
9260bf1
cf4884d
3814757
0824123
39bd639
18a6979
99fede0
0f26935
829e1c9
6dad6fe
ab57e94
bd560ee
d2b5f7f
17f3b44
19c9937
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,63 +12,37 @@ on: | |
| jobs: | ||
| build-packages: | ||
| if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }} | ||
| permissions: | ||
| id-token: write | ||
| contents: write | ||
| strategy: | ||
| matrix: | ||
| include: | ||
| - platform: linux | ||
| arch: x64 | ||
| bazel_arch: amd64 | ||
| runs_on: ubuntu-22.04 | ||
| - platform: linux | ||
| arch: arm64 | ||
| bazel_arch: arm64 | ||
| runs_on: ubuntu-22.04-arm | ||
| runs-on: ${{ matrix.runs_on }} | ||
|
|
||
| env: | ||
| NODE_VERSION: v22.21.1 | ||
| PLATFORM: ${{ matrix.platform }} | ||
| ARCH: ${{ matrix.arch }} | ||
| BAZEL_ARCH: ${{ matrix.bazel_arch }} | ||
| REPO: ${{ github.repository }} | ||
|
|
||
| steps: | ||
| # Check out the v22.21.1 branch (not the workflow's default branch) so that | ||
| # Dockerfile.Packages and the Node source tree are present. The workflow YAML | ||
| # itself runs from whichever ref triggered it (main for workflow_dispatch, or | ||
| # v22.21.1 for workflow_run) — that's what the OIDC subject claim binds to, | ||
| # and it's how the IAM role's ref_patterns gate works. `ref:` here only | ||
| # controls which tree gets checked out into $GITHUB_WORKSPACE. | ||
| # | ||
| # Security note: v22.21.1 is not a protected branch, so in principle any of | ||
| # the repo's ~530 collaborators could push a malicious Dockerfile.Packages | ||
| # and have this workflow build+upload the resulting image. That same risk | ||
| # already existed for the Node source itself (which also lives on this | ||
| # branch), so this change does not expand the attack surface. A follow-up | ||
| # PR will propose a structural fix (branch protection, patch series, or | ||
| # submodule model) — tracked in our internal project notes. | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v3 | ||
| with: | ||
| ref: ${{ env.NODE_VERSION }} | ||
|
|
||
| - name: Debug Matrix Values | ||
| run: | | ||
| echo "Matrix platform: $PLATFORM" | ||
| echo "Matrix arch: $ARCH" | ||
| echo "Matrix platform: ${{ matrix.platform }}" | ||
| echo "Matrix arch: ${{ matrix.arch }}" | ||
| - name: Download Node archive | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| ASSET="node-${NODE_VERSION}-${PLATFORM}-${ARCH}-LATEST.tar.xz" | ||
| gh release download "node-${NODE_VERSION}-release" \ | ||
| gh release download node-${{ env.NODE_VERSION }}-release \ | ||
| --repo asana/node \ | ||
| --pattern "$ASSET" | ||
| mv "$ASSET" node.tar.xz | ||
| --pattern "node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz" | ||
| mv node-${{ env.NODE_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}-LATEST.tar.xz node.tar.xz | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Execute the Dockerfile | ||
| run: | | ||
|
|
@@ -91,73 +65,13 @@ jobs: | |
| mv node_modules/cld ./cld@2.9.1/node_modules/ | ||
| mv node_modules/unix-dgram ./unix-dgram@2.0.6/node_modules/ | ||
| mv "node_modules/@datadog/pprof" "./@datadog+pprof@5.8.0/node_modules/@datadog/" | ||
| tar --hard-dereference -cvzf "packages_${ARCH}.tar.gz" bcrypt@5.1.0 cld@2.9.1 unix-dgram@2.0.6 "@datadog+pprof@5.8.0" | ||
| tar --hard-dereference -cvzf packages_${{matrix.arch}}.tar.gz bcrypt@5.1.0 cld@2.9.1 unix-dgram@2.0.6 "@datadog+pprof@5.8.0" | ||
| - name: Upload archive to release | ||
| # Use `gh release upload` (first-party GitHub CLI, pre-installed on runners) | ||
| # instead of softprops/action-gh-release (one-maintainer third-party action). | ||
| # Behavior: --clobber overwrites an existing asset with the same name, matching | ||
| # softprops's default. The release must already exist (created by build-node.yml). | ||
| uses: softprops/action-gh-release@v1 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium severity blocking issue identified in your code: The More details about thisThe workflow runs To resolve this comment: ✨ Commit fix suggestion
💬 Ignore this findingReply with Semgrep commands to ignore this finding.
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by github-actions-mutable-action-tag. Please reach out to Security (go/sec-inbox) if you need help with this. You can view more details about this finding in the Semgrep AppSec Platform. |
||
| with: | ||
| name: node-${{ env.NODE_VERSION }}-LATEST | ||
| tag_name: node-${{ env.NODE_VERSION }}-release | ||
| files: packages_${{matrix.arch}}.tar.gz | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| gh release upload "node-${NODE_VERSION}-release" \ | ||
| "packages_${ARCH}.tar.gz" \ | ||
| --clobber \ | ||
| --repo "$REPO" | ||
| # S3 upload is restricted to the protected main branch only. The IAM role | ||
| # (push_node_gyp_packages) trusts only refs/heads/main via OIDC. To upload | ||
| # packages to S3 after a Node upgrade, trigger workflow_dispatch from main. | ||
| - name: Configure AWS credentials | ||
| if: github.ref == 'refs/heads/main' | ||
| uses: aws-actions/configure-aws-credentials@v4 | ||
| with: | ||
| aws-region: us-east-1 | ||
| role-to-assume: arn:aws:iam::403483446840:role/autogen_github_actions_beta_push_node_gyp_packages | ||
|
|
||
| - name: Upload packages to S3 | ||
| if: github.ref == 'refs/heads/main' | ||
| run: | | ||
| # Upload to s3://asana-oss-cache/node-gyp/... (CloudFront path_patterns entry | ||
| # added in codez PR #390222 — that must be merged + applied via Spacelift | ||
| # before this workflow can successfully publish fetchable objects). | ||
| # | ||
| # No --acl public-read: the bucket has BucketOwnerEnforced | ||
| # (disable_confusing_acls = true), which disables ACLs entirely. | ||
| # BlockPublicAcls + IgnorePublicAcls provide additional coverage. | ||
| # Reads come via CloudFront OAC. | ||
| NODE_MAJOR=$(echo "$NODE_VERSION" | sed 's/^v//' | cut -d. -f1) | ||
| SHA256=$(sha256sum "packages_${ARCH}.tar.gz" | awk '{print $1}') | ||
| SHORT_HASH=${SHA256:0:8} | ||
| S3_KEY="node-gyp/packages_${BAZEL_ARCH}_node${NODE_MAJOR}-${SHORT_HASH}.tar.gz" | ||
| echo "Uploading packages_${ARCH}.tar.gz to s3://asana-oss-cache/$S3_KEY" | ||
| aws s3 cp "packages_${ARCH}.tar.gz" "s3://asana-oss-cache/$S3_KEY" | ||
| { | ||
| echo "S3_KEY=$S3_KEY" | ||
| echo "SHA256=$SHA256" | ||
| echo "NODE_MAJOR=$NODE_MAJOR" | ||
| } >> "$GITHUB_ENV" | ||
| - name: Verify upload is reachable via CloudFront | ||
| if: github.ref == 'refs/heads/main' | ||
| run: | | ||
| # Mac Bazel builds rewrite asana-oss-cache.s3.us-east-1.amazonaws.com/* | ||
| # to asana-oss-cache.asana.biz/* (CloudFront). If the S3 key prefix isn't | ||
| # allowlisted in CloudFront's path_patterns, Bazel fetches will 403. | ||
| # Fail fast here rather than after someone tries to build. | ||
| URL="https://asana-oss-cache.asana.biz/$S3_KEY" | ||
| echo "Checking $URL" | ||
| if ! curl -fsSI "$URL"; then | ||
| echo "CloudFront returned an error for $URL. Check path_patterns in system_packages.tf." | ||
| exit 1 | ||
| fi | ||
| - name: Print tools_repositories.bzl stanza | ||
| if: github.ref == 'refs/heads/main' | ||
| run: | | ||
| echo "" | ||
| echo "=== Update tools_repositories.bzl in codez ===" | ||
| echo " name = \"node_gyp_packages_${BAZEL_ARCH}_node${NODE_MAJOR}\"," | ||
| echo " urls = [\"https://asana-oss-cache.s3.us-east-1.amazonaws.com/$S3_KEY\"]," | ||
| echo " sha256 = \"$SHA256\"," | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High severity blocking issue identified in your code:
The untrusted
inputs.DOCKER_FILEvalue is interpolated into a shell command, allowing command injection on the GitHub Actions runner. An attacker can execute commands and potentially steal tokens, secrets, source code, or build artifacts.More details about this
inputs.DOCKER_FILEis inserted directly into a shell command. Because workflow inputs can be supplied or influenced by an untrusted workflow invocation, shell metacharacters in that value are executed by the runner rather than treated as part of the Dockerfile path.For example, an attacker could provide this input:
The step would effectively run:
The injected command runs on the same GitHub Actions runner as
docker build, so it can read accessible environment variables, workspace files, checked-out Node source, Docker credentials, and other tokens or secrets available to the job. An attacker could then use those credentials to access repositories, publish modified artifacts, or exfiltrate source code.To resolve this comment:
✨ Commit fix suggestion
View step-by-step instructions
Add an
enventry to theExecute the Dockerfilestep to transfer the workflow input into an environment variable:DOCKER_FILE: ${{ inputs.DOCKER_FILE }}Replace the direct expression in the shell command with the quoted environment variable:
docker build -t node22_fips_build -f "./$DOCKER_FILE" .If only specific Dockerfiles are valid, validate
DOCKER_FILEagainst an allowlist before running Docker, such ascase "$DOCKER_FILE" in Dockerfile|Dockerfile.*) ;; *) exit 1 ;; esac.💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasonsAlternatively, triage in Semgrep AppSec Platform to ignore the finding created by run-shell-injection.
Please reach out to Security (go/sec-inbox) if you need help with this.
You can view more details about this finding in the Semgrep AppSec Platform.