You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@zeppelin.apache.org by "jongyoul (via GitHub)" <gi...@apache.org> on 2026/08/06 08:47:17 UTC

[PR] [MINOR] Add daily npm audit remediation workflow [zeppelin]

jongyoul opened a new pull request, #5390:
URL: https://github.com/apache/zeppelin/pull/5390

   ### What is this PR for?
   
   Add a daily and manually dispatchable workflow that detects high/critical npm audit failures in `zeppelin-web-angular/projects/zeppelin-react` and prepares a validated lockfile-only remediation PR.
   
   The workflow never pushes to `master` and never merges a PR. After all checks pass, it writes only to the dedicated `automation/npm-audit-fix-zeppelin-react` branch and opens or updates a draft PR.
   
   Duplicate prevention is content-based:
   
   * the workflow serializes runs with one concurrency group;
   * it always uses the same upstream automation branch;
   * it queries PRs by the exact upstream owner and branch;
   * if the generated lockfile blob is already present in the latest open, closed, or merged automation PR, it does not push or create another PR;
   * if an open automation PR exists with different lockfile content, it updates that PR;
   * closing an unchanged automation PR is respected, so the same fix is not recreated the next day.
   
   The write job is separated from the read-only preparation job. It runs only for scheduled/manual events in `apache/zeppelin`, and only after all of these safeguards pass:
   
   * the audit failure contains a real high/critical vulnerability report;
   * `npm audit fix --package-lock-only --ignore-scripts` changes exactly the React lockfile and never uses `--force`;
   * clean parent and React installs complete;
   * the repaired lockfile passes audit, lint, tests, and production build.
   
   ### What type of PR is it?
   
   Improvement
   
   ### Todos
   
   * [x] Validate the current lockfile-only remediation path locally.
   * [x] Validate the workflow with `actionlint`.
   * [ ] Obtain ASF Infrastructure approval before enabling an Action to push an official source-repository branch, as required by the [ASF GitHub Actions policy](https://infra.apache.org/github-actions-policy.html#pushing-commits-to-repositories).
   * [ ] Confirm that the repository setting allowing GitHub Actions to create pull requests is enabled.
   
   ### What is the Jira issue?
   
   N/A for this draft. A Jira can be created before marking the PR ready if required.
   
   ### How should this be tested?
   
   The current `master` lockfile was tested with Node 22 and npm 10.9.4 using the same sequence as the workflow:
   
   * initial audit: 3 high, 0 critical vulnerabilities;
   * lockfile-only audit fix: only `zeppelin-react/package-lock.json` changed;
   * repaired audit: 0 vulnerabilities;
   * ESLint: passed;
   * Vitest: 14/14 passed;
   * production webpack build: passed (existing asset-size warning only);
   * YAML parsing, `actionlint` v1.7.12, and `git diff --check`: passed.
   
   For generated PRs, GitHub documents that `pull_request` checks created through `GITHUB_TOKEN` start in an approval-required state. A maintainer can approve those runs; the remediation workflow also completes audit/lint/test/build before creating the PR. See [GitHub's `GITHUB_TOKEN` documentation](https://docs.github.com/en/actions/concepts/security/github_token#when-github_token-triggers-workflow-runs).
   
   ### Screenshots (if appropriate)
   
   N/A
   
   ### Questions:
   
   * Does the license files need to update? No.
   * Is there breaking changes for older versions? No; automatic fixes are restricted to compatible lockfile-only changes.
   * Does this needs documentation? The workflow and generated PR body describe the behavior; no user-facing documentation is changed.
   


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add daily npm audit remediation workflow [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on PR #5390:
URL: https://github.com/apache/zeppelin/pull/5390#issuecomment-5263409282

   @tbonelee @voidmatcha How about this idea? 🙏 


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add daily npm audit remediation workflow [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul merged PR #5390:
URL: https://github.com/apache/zeppelin/pull/5390


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add daily npm audit remediation workflow [zeppelin]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #5390:
URL: https://github.com/apache/zeppelin/pull/5390#discussion_r3749102468


##########
.github/workflows/npm-audit-remediation.yml:
##########
@@ -0,0 +1,291 @@
+# 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.
+
+name: npm audit remediation
+
+on:
+  schedule:
+    - cron: '23 2 * * *'
+  workflow_dispatch:
+  pull_request:
+    paths:
+      - '.github/workflows/npm-audit-remediation.yml'
+
+concurrency:
+  group: npm-audit-remediation
+  cancel-in-progress: false
+
+env:
+  FRONTEND_DIRECTORY: zeppelin-web-angular
+  PACKAGE_DIRECTORY: zeppelin-web-angular/projects/zeppelin-react
+  LOCKFILE: zeppelin-web-angular/projects/zeppelin-react/package-lock.json
+  REMEDIATION_BRANCH: automation/npm-audit-fix-zeppelin-react
+  PR_TITLE: '[HOTFIX] Refresh zeppelin-react lockfile for npm audit'
+
+jobs:
+  prepare:
+    runs-on: ubuntu-24.04
+    timeout-minutes: 30
+    permissions:
+      contents: read
+    outputs:
+      audited_sha: ${{ steps.revision.outputs.sha }}
+      needs_remediation: ${{ steps.audit.outputs.needs_remediation }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v5
+        with:
+          fetch-depth: 0
+          persist-credentials: false
+          ref: ${{ github.event_name == 'pull_request' && github.sha || 'master' }}
+
+      - id: revision
+        name: Record audited revision
+        shell: bash
+        run: echo "sha=$(git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
+
+      - name: Set up Node.js
+        uses: actions/setup-node@v5
+        with:
+          node-version-file: 'zeppelin-web-angular/.nvmrc'
+
+      - id: audit
+        name: Check npm audit
+        working-directory: ${{ env.PACKAGE_DIRECTORY }}
+        shell: bash
+        run: |
+          set +e
+          npm audit --package-lock-only --audit-level=high --json \
+            > "${RUNNER_TEMP}/npm-audit-before.json"
+          audit_status=$?
+          set -e
+
+          if [[ ${audit_status} -eq 0 ]]; then
+            echo "needs_remediation=false" >> "${GITHUB_OUTPUT}"
+            exit 0
+          fi
+
+          vulnerable_count=$(node - "${RUNNER_TEMP}/npm-audit-before.json" <<'NODE'
+          const fs = require('fs');
+          const report = JSON.parse(fs.readFileSync(process.argv[2], 'utf8'));
+          const counts = report.metadata && report.metadata.vulnerabilities;
+          if (!counts) {
+            process.exit(2);
+          }
+          console.log((counts.high || 0) + (counts.critical || 0));
+          NODE
+          ) || {
+            cat "${RUNNER_TEMP}/npm-audit-before.json"
+            echo "::error::npm audit failed without a valid vulnerability report"
+            exit "${audit_status}"
+          }
+
+          if [[ ${vulnerable_count} -eq 0 ]]; then
+            cat "${RUNNER_TEMP}/npm-audit-before.json"
+            echo "::error::npm audit failed without a high or critical vulnerability"
+            exit "${audit_status}"
+          fi
+
+          echo "needs_remediation=true" >> "${GITHUB_OUTPUT}"
+          echo "Found ${vulnerable_count} high or critical vulnerabilities"
+
+      - name: Generate a lockfile-only fix
+        if: steps.audit.outputs.needs_remediation == 'true'
+        working-directory: ${{ env.PACKAGE_DIRECTORY }}
+        run: npm audit fix --package-lock-only --ignore-scripts --audit-level=high
+
+      - name: Verify the generated diff
+        if: steps.audit.outputs.needs_remediation == 'true'
+        shell: bash
+        run: |
+          changed_files=$(git diff --name-only)
+          if [[ "${changed_files}" != "${LOCKFILE}" ]]; then
+            echo "::error::Expected only ${LOCKFILE} to change, got:"
+            printf '%s\n' "${changed_files}"
+            exit 1
+          fi
+          git diff --check
+
+      - name: Install frontend dependencies
+        if: steps.audit.outputs.needs_remediation == 'true'
+        working-directory: ${{ env.FRONTEND_DIRECTORY }}
+        run: npm ci --ignore-scripts --no-audit
+
+      - name: Validate the fix
+        if: steps.audit.outputs.needs_remediation == 'true'
+        working-directory: ${{ env.PACKAGE_DIRECTORY }}
+        run: |
+          npm ci --ignore-scripts --no-audit
+          npm audit --audit-level=high
+          npm run lint
+          npm test
+          npm run build
+
+      - name: Create remediation artifact
+        if: steps.audit.outputs.needs_remediation == 'true'
+        shell: bash
+        run: |
+          artifact_directory="${RUNNER_TEMP}/npm-audit-remediation"
+          mkdir -p "${artifact_directory}"
+          git diff --binary -- "${LOCKFILE}" > "${artifact_directory}/fix.patch"
+          cp "${RUNNER_TEMP}/npm-audit-before.json" "${artifact_directory}/audit-before.json"
+          test -s "${artifact_directory}/fix.patch"
+
+      - name: Upload remediation artifact
+        if: steps.audit.outputs.needs_remediation == 'true'
+        uses: actions/upload-artifact@v6
+        with:
+          name: npm-audit-remediation
+          path: ${{ runner.temp }}/npm-audit-remediation
+          retention-days: 1
+
+  publish:
+    needs: prepare
+    if: >-
+      needs.prepare.outputs.needs_remediation == 'true' &&
+      github.event_name != 'pull_request' &&
+      github.repository == 'apache/zeppelin'
+    runs-on: ubuntu-24.04

Review Comment:
   The PR description notes ASF Infrastructure approval is required before enabling a workflow that pushes branches, but once this workflow is merged the scheduled runs will immediately be eligible to push (via the publish job) when audit failures occur. To keep the workflow safe-by-default, add an explicit opt-in gate (for example a repo variable) to the publish job so it cannot write until maintainers intentionally enable it.



-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MINOR] Add daily npm audit remediation workflow [zeppelin]

Posted by "jongyoul (via GitHub)" <gi...@apache.org>.
jongyoul commented on PR #5390:
URL: https://github.com/apache/zeppelin/pull/5390#issuecomment-5290008322

   Merged into master (9f7092b4).


-- 
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: reviews-unsubscribe@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org