github-advanced-security[bot] commented on code in PR #39811:
URL: https://github.com/apache/beam/pull/39811#discussion_r3832720979


##########
.github/workflows/beam_Infrastructure_UsersPermissions.yml:
##########
@@ -43,32 +36,50 @@
     name: Apply user roles changes
     runs-on: [self-hosted, ubuntu-24.04, main]
     timeout-minutes: 30
+    if: ${{ github.event.workflow_run.conclusion == 'success' }}
     steps:
-      - name: Checkout code
+      - name: Checkout trusted base repository
         uses: actions/checkout@v7
         with:
-          ref: ${{ github.event.pull_request.merged == true && github.base_ref 
|| github.event.pull_request.head.sha }}
           persist-credentials: false
+
+      - name: Download Artifacts
+        uses: actions/download-artifact@v4
+        with:
+          name: pr-data
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          run-id: ${{ github.event.workflow_run.id }}
+
+      # Move the users.yml file to the correct location for Terraform to 
process it
+      - name: Prepare users.yml

Review Comment:
   ## CodeQL / Artifact poisoning
   
   Potential artifact poisoning; the artifact being consumed has contents that 
may be controlled by an external user ([workflow_run](1)).
   Potential artifact poisoning; the artifact being consumed has contents that 
may be controlled by an external user ([workflow_run](1)).
   Potential artifact poisoning; the artifact being consumed has contents that 
may be controlled by an external user ([workflow_run](1)).
   
   [Show more 
details](https://github.com/apache/beam/security/code-scanning/1922)



##########
.github/workflows/beam_Infrastructure_UsersPermissions.yml:
##########
@@ -43,32 +36,50 @@
     name: Apply user roles changes
     runs-on: [self-hosted, ubuntu-24.04, main]
     timeout-minutes: 30
+    if: ${{ github.event.workflow_run.conclusion == 'success' }}
     steps:
-      - name: Checkout code
+      - name: Checkout trusted base repository
         uses: actions/checkout@v7
         with:
-          ref: ${{ github.event.pull_request.merged == true && github.base_ref 
|| github.event.pull_request.head.sha }}
           persist-credentials: false
+
+      - name: Download Artifacts
+        uses: actions/download-artifact@v4
+        with:
+          name: pr-data
+          github-token: ${{ secrets.GITHUB_TOKEN }}
+          run-id: ${{ github.event.workflow_run.id }}
+
+      # Move the users.yml file to the correct location for Terraform to 
process it
+      - name: Prepare users.yml
+        run: mv users.yml infra/iam/users.yml
+
+      - name: Load PR Number
+        run: |
+          PR_NUM=$(cat pr_number.txt)
+          echo "PR_NUMBER=$PR_NUM" >> $GITHUB_ENV

Review Comment:
   ## CodeQL / Environment variable built from user-controlled sources
   
   Potential environment variable injection in [PR_NUM=$(cat pr_number.txt)
   echo "PR_NUMBER=$PR_NUM" >> $GITHUB_ENV](1), which may be controlled by an 
external user ([workflow_run](2)).
   
   [Show more 
details](https://github.com/apache/beam/security/code-scanning/1924)



##########
.github/workflows/beam_infraestructure_extract_users.yml:
##########
@@ -0,0 +1,47 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This workflow is used to extract the users.yml file from a pull request and 
upload it
+# as an artifact for further processing.
+# It is triggered when the users.yml file is modified in a pull request.
+
+
+name: Extract users.yml from PR
+
+on:
+  pull_request:
+    paths:
+      - 'infra/iam/users.yml'
+
+jobs:
+  extract_data:
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout PR code
+        uses: actions/checkout@v7
+
+      # Save the PR number to a file for later use
+      - name: Save PR number
+        run: echo ${{ github.event.pull_request.number }} > pr_number.txt
+
+      - name: Upload Artifacts
+        uses: actions/upload-artifact@v4
+        with:
+          name: pr-data
+          path: |
+            infra/iam/users.yml
+            pr_number.txt

Review Comment:
   ## CodeQL / Workflow does not contain permissions
   
   Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. 
Consider setting an explicit permissions block, using the following as a 
minimal starting point: {{contents: read}}
   
   [Show more 
details](https://github.com/apache/beam/security/code-scanning/1923)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to