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


##########
.github/workflows/update_ml_dependency_bounds.yml:
##########
@@ -0,0 +1,143 @@
+# 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.
+
+# Raises exclusive upper bounds of ML dependencies in setup.py / tox.ini when
+# PyPI has a newer stable release, then opens a pull request. Never merges.
+# Does not regenerate container requirements (see 
update_python_dependencies.yml).
+#
+# If an open pull request titled "Update ML dependency bounds*" already exists,
+# this run is skipped so reviewer edits on that branch are not overwritten.
+# Close that PR to get a fresh run.
+#
+# Behavior, holds, and an example generated PR body:
+#   scripts/tools/README_ml_dependency_bounds.md
+#
+# Example PR body the script generates:
+#
+#   This PR was created by automation and has not been reviewed by a human yet.
+#   ...
+#   Bumped bounds:
+#   - setup_torch_torch_extra (sdks/python/setup.py): torch>=2.3.0,<2.15.0 -> 
torch>=2.3.0,<2.16.0
+#   Held:
+#   - setup_torch_ml_base_core: torch 2.12 requires triton 3.7, ...
+
+name: Update ML Dependency Bounds
+
+on:
+  schedule:
+  - cron: "0 0 * * 0"
+  workflow_dispatch:
+permissions:
+  actions: write
+  contents: write
+  pull-requests: write
+
+concurrency:
+  group: '${{ github.workflow }} @ ${{ github.ref }}'
+  cancel-in-progress: true
+
+jobs:
+  update_ml_dependency_bounds:
+    if: github.event_name == 'workflow_dispatch' || github.repository == 
'apache/beam'
+    runs-on: [self-hosted, ubuntu-24.04, main]
+    name: Update ML Dependency Bounds
+    timeout-minutes: 30
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v7
+        with:
+          persist-credentials: false
+      - name: Setup environment
+        uses: $/.github/actions/setup-environment-action
+        with:
+          python-version: "3.11"
+          # The script does not use tox.
+          tox-cache: false
+      - name: Install script dependencies
+        run: pip install packaging pyyaml pytest
+      - name: Install gh cli
+        uses: $/.github/actions/setup-gh-cli-linux
+      - name: Check for an open pull request from this workflow
+        id: existing_pr
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          existingPr=$(gh pr list --state open --limit 5 \
+            --search 'is:pr is:open in:title "Update ML dependency bounds"' \
+            --json number,isCrossRepository \
+            --jq '[.[] | select(.isCrossRepository | not)] | .[0].number // 
empty')
+          echo "number=$existingPr" >> "$GITHUB_OUTPUT"
+          if [ -n "$existingPr" ]; then
+            message="Open pull request #$existingPr from this workflow exists. 
Skipping this run. Close that pull request to get a new run."
+            echo "$message"
+            echo "$message" >> "$GITHUB_STEP_SUMMARY"
+          fi
+      - name: Test the update script
+        if: steps.existing_pr.outputs.number == ''
+        run: python -m pytest scripts/tools/update_ml_dependency_bounds_test.py
+      - name: Update ML dependency bounds
+        if: steps.existing_pr.outputs.number == ''
+        run: |
+          set -o pipefail
+          python scripts/tools/update_ml_dependency_bounds.py \
+            --pr-body-file "$RUNNER_TEMP/pr_body.md" | tee 
"$RUNNER_TEMP/report.txt"
+          {
+            echo "## ML dependency bounds"
+            echo '```'
+            cat "$RUNNER_TEMP/report.txt"
+            echo '```'
+          } >> "$GITHUB_STEP_SUMMARY"
+      - name: Commit changes and create PR
+        id: create_pr
+        if: steps.existing_pr.outputs.number == ''
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          if [ -z "$(git status --porcelain)" ]; then
+            echo "No changes on the files"
+            echo "created=false" >> "$GITHUB_OUTPUT"
+            exit 0
+          fi
+          git config user.name "$GITHUB_ACTOR"
+          git config user.email actions@"$RUNNER_NAME".local
+          gh auth setup-git
+          branchName=update_ml_dependency_bounds_$(date +%s)
+          git checkout -b "$branchName"
+          git add -A
+          git commit -m "Update ML dependency bounds" --quiet
+          git push origin "$branchName" --quiet
+          GITHUB_PR_URL=$(gh pr create --title "Update ML dependency bounds" 
--label "python" --body-file "$RUNNER_TEMP/pr_body.md" --base master)
+          echo "Link of the new PR  $GITHUB_PR_URL"
+          echo "created=true" >> "$GITHUB_OUTPUT"
+          echo "branch=$branchName" >> "$GITHUB_OUTPUT"
+      - name: Trigger Python PostCommit workflows on the new branch
+        if: steps.create_pr.outputs.created == 'true'
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Pick up current and future PostCommit workflows whose name mentions
+          # Python, so this list does not need hand updates.
+          mapfile -t workflows < <(gh workflow list --all --json 
name,path,state \
+            --jq '.[] | select(.state=="active") | select(.name | 
test("(?i)python")) | select(.name | test("(?i)post\\s*commit")) | .path')
+          if [ ${#workflows[@]} -eq 0 ]; then
+            echo "No matching Python PostCommit workflows found"
+            exit 0
+          fi
+          for wf in "${workflows[@]}"; do
+            echo "Triggering $wf on ${{ steps.create_pr.outputs.branch }}"

Review Comment:
   ## zizmor / 
   
   code injection via template expansion: may expand into attacker-controllable 
code
   
   [Show more 
details](https://github.com/apache/beam/security/code-scanning/3546)



##########
.github/workflows/update_ml_dependency_bounds.yml:
##########
@@ -0,0 +1,143 @@
+# 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.
+
+# Raises exclusive upper bounds of ML dependencies in setup.py / tox.ini when
+# PyPI has a newer stable release, then opens a pull request. Never merges.
+# Does not regenerate container requirements (see 
update_python_dependencies.yml).
+#
+# If an open pull request titled "Update ML dependency bounds*" already exists,
+# this run is skipped so reviewer edits on that branch are not overwritten.
+# Close that PR to get a fresh run.
+#
+# Behavior, holds, and an example generated PR body:
+#   scripts/tools/README_ml_dependency_bounds.md
+#
+# Example PR body the script generates:
+#
+#   This PR was created by automation and has not been reviewed by a human yet.
+#   ...
+#   Bumped bounds:
+#   - setup_torch_torch_extra (sdks/python/setup.py): torch>=2.3.0,<2.15.0 -> 
torch>=2.3.0,<2.16.0
+#   Held:
+#   - setup_torch_ml_base_core: torch 2.12 requires triton 3.7, ...
+
+name: Update ML Dependency Bounds
+
+on:
+  schedule:
+  - cron: "0 0 * * 0"
+  workflow_dispatch:
+permissions:
+  actions: write
+  contents: write
+  pull-requests: write
+
+concurrency:
+  group: '${{ github.workflow }} @ ${{ github.ref }}'
+  cancel-in-progress: true
+
+jobs:
+  update_ml_dependency_bounds:
+    if: github.event_name == 'workflow_dispatch' || github.repository == 
'apache/beam'
+    runs-on: [self-hosted, ubuntu-24.04, main]
+    name: Update ML Dependency Bounds
+    timeout-minutes: 30
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v7
+        with:
+          persist-credentials: false
+      - name: Setup environment
+        uses: $/.github/actions/setup-environment-action
+        with:
+          python-version: "3.11"
+          # The script does not use tox.
+          tox-cache: false
+      - name: Install script dependencies
+        run: pip install packaging pyyaml pytest
+      - name: Install gh cli
+        uses: $/.github/actions/setup-gh-cli-linux
+      - name: Check for an open pull request from this workflow
+        id: existing_pr
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          existingPr=$(gh pr list --state open --limit 5 \
+            --search 'is:pr is:open in:title "Update ML dependency bounds"' \
+            --json number,isCrossRepository \
+            --jq '[.[] | select(.isCrossRepository | not)] | .[0].number // 
empty')
+          echo "number=$existingPr" >> "$GITHUB_OUTPUT"
+          if [ -n "$existingPr" ]; then
+            message="Open pull request #$existingPr from this workflow exists. 
Skipping this run. Close that pull request to get a new run."
+            echo "$message"
+            echo "$message" >> "$GITHUB_STEP_SUMMARY"
+          fi
+      - name: Test the update script
+        if: steps.existing_pr.outputs.number == ''
+        run: python -m pytest scripts/tools/update_ml_dependency_bounds_test.py
+      - name: Update ML dependency bounds
+        if: steps.existing_pr.outputs.number == ''
+        run: |
+          set -o pipefail
+          python scripts/tools/update_ml_dependency_bounds.py \
+            --pr-body-file "$RUNNER_TEMP/pr_body.md" | tee 
"$RUNNER_TEMP/report.txt"
+          {
+            echo "## ML dependency bounds"
+            echo '```'
+            cat "$RUNNER_TEMP/report.txt"
+            echo '```'
+          } >> "$GITHUB_STEP_SUMMARY"
+      - name: Commit changes and create PR
+        id: create_pr
+        if: steps.existing_pr.outputs.number == ''
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          if [ -z "$(git status --porcelain)" ]; then
+            echo "No changes on the files"
+            echo "created=false" >> "$GITHUB_OUTPUT"
+            exit 0
+          fi
+          git config user.name "$GITHUB_ACTOR"
+          git config user.email actions@"$RUNNER_NAME".local
+          gh auth setup-git
+          branchName=update_ml_dependency_bounds_$(date +%s)
+          git checkout -b "$branchName"
+          git add -A
+          git commit -m "Update ML dependency bounds" --quiet
+          git push origin "$branchName" --quiet
+          GITHUB_PR_URL=$(gh pr create --title "Update ML dependency bounds" 
--label "python" --body-file "$RUNNER_TEMP/pr_body.md" --base master)
+          echo "Link of the new PR  $GITHUB_PR_URL"
+          echo "created=true" >> "$GITHUB_OUTPUT"
+          echo "branch=$branchName" >> "$GITHUB_OUTPUT"
+      - name: Trigger Python PostCommit workflows on the new branch
+        if: steps.create_pr.outputs.created == 'true'
+        env:
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        run: |
+          # Pick up current and future PostCommit workflows whose name mentions
+          # Python, so this list does not need hand updates.
+          mapfile -t workflows < <(gh workflow list --all --json 
name,path,state \
+            --jq '.[] | select(.state=="active") | select(.name | 
test("(?i)python")) | select(.name | test("(?i)post\\s*commit")) | .path')
+          if [ ${#workflows[@]} -eq 0 ]; then
+            echo "No matching Python PostCommit workflows found"
+            exit 0
+          fi
+          for wf in "${workflows[@]}"; do
+            echo "Triggering $wf on ${{ steps.create_pr.outputs.branch }}"

Review Comment:
   ## zizmor / 
   
   code injection via template expansion: may expand into attacker-controllable 
code
   
   [Show more 
details](https://github.com/apache/beam/security/code-scanning/3547)



-- 
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