Skip to content

ci: add npm audit CI check for react-frontend security#288

Open
TusharB-07 wants to merge 2 commits into
openmainframeproject:masterfrom
TusharB-07:feat/npm-audit-ci-check
Open

ci: add npm audit CI check for react-frontend security#288
TusharB-07 wants to merge 2 commits into
openmainframeproject:masterfrom
TusharB-07:feat/npm-audit-ci-check

Conversation

@TusharB-07

Copy link
Copy Markdown
Collaborator

Closes #285

What this does

  • Adds .github/workflows/frontend-security-audit.yml that runs
    npm audit --audit-level=high on every PR touching react-frontend/
  • Documents the audit policy in docs/Contribute.md

Why

Without a CI gate, npm vulnerabilities can silently re-accumulate.
This makes security enforcement automatic going forward.

Notes

Existing vulnerabilities in the repo will need to be addressed
in a follow-up PR. This PR only adds the enforcement gate as
requested in #285.

Copilot AI review requested due to automatic review settings May 26, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a frontend-focused security audit check to CI and documents it so contributors know what to expect when touching react-frontend/.

Changes:

  • Documented a React frontend security policy in contribution guidelines.
  • Added a GitHub Actions workflow to run npm audit --audit-level=high on PRs that modify react-frontend/**.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
docs/Contribute.md Documents the new CI security audit behavior for react-frontend/ PRs.
.github/workflows/frontend-security-audit.yml Introduces a PR-scoped workflow that installs dependencies and runs npm audit for high/critical findings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/Contribute.md Outdated
Comment on lines +44 to +45
`npm audit --audit-level=high` and will block merging if any high or
critical severity vulnerabilities are introduced.
Comment thread docs/Contribute.md Outdated
3. For issues that can't be auto-fixed, update the affected dependency
manually or open a separate issue.


Comment on lines +1 to +6
name: Frontend Security Audit

on:
pull_request:
paths:
- 'react-frontend/**'

@vmuralictr vmuralictr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this — automated security scanning is a great addition! A few things to address before merging:

1. Existing vulnerabilities will block all contributors immediately
The PR description mentions existing vulnerabilities will be fixed in a follow-up PR, but until then this workflow will fail for every contributor from day one. Consider resolving the existing vulnerabilities first before merging this workflow.

2. No push trigger on main branch
The workflow only triggers on pull_request. If someone with direct push access pushes to master, the audit won't run. Consider adding a push trigger:

on:
  push:
    branches: [master]
    paths:
      - 'react-frontend/**'
  pull_request:
    paths:
      - 'react-frontend/**'

3. Dev dependencies included in the audit
npm audit scans dev dependencies by default, which don't affect production users. Consider adding --omit=dev to focus only on production dependencies:

run: npm audit --audit-level=high --omit=dev

4. Docs overstate enforcement
The docs say the pipeline "prevents merging" — this only happens if branch protection rules are configured to require this check. To avoid misleading contributors, consider updating the wording to: "will fail CI and may block merging when required checks are enforced"

5. Minor: trailing whitespace in Contribute.md
There are trailing spaces on the blank line before ## Note — worth cleaning up.

Overall this is a solid contribution — once the existing vulnerabilities are resolved first, this will be a great addition to the repo!

@vmuralictr

Copy link
Copy Markdown
Collaborator

Hi @TusharB-07 , just following up on the review comments left last week. Could you please take a look when you get a chance? Happy to help if you have any questions on the feedback!

Signed-off-by: TusharB-07 <tusharnbiswas07@gmail.com>
- fix existing moderate vulnerabilities via npm audit fix
- add push trigger on master branch to workflow
- add --omit=dev flag to npm audit command
- add permissions: contents: read to workflow
- fix Contribute.md wording (fail CI, not block merging)
- remove trailing whitespace in Contribute.md

Signed-off-by: TusharB-07 <tusharnbiswas07@gmail.com>
@TusharB-07
TusharB-07 force-pushed the feat/npm-audit-ci-check branch from 5ce67c8 to 847fbff Compare June 23, 2026 07:28
@TusharB-07

Copy link
Copy Markdown
Collaborator Author

Hi @vmuralictr, thanks for the detailed review

I've addressed all five points:

  1. Existing vulnerabilities — Ran npm audit fix. 2 moderate severity issues remain in styled-components → postcss but these do not trigger the --audit-level=high gate, so CI will pass correctly. Upgrading styled-components@latest causes a peer dependency conflict with react-native and @types/react that can't be auto-resolved without risking breakage. Happy to track this in a separate issue if that works for you.

  2. Push trigger — Added push on master to the workflow so direct pushes are also audited.

  3. Dev dependencies — Added --omit=dev to the npm audit command.

  4. Docs wording — Updated to "will fail CI and may block merging when required checks are enforced".

  5. Trailing whitespace — Cleaned up in Contribute.md.

Also added permissions: contents: read to the workflow.
Please take another look when you get a chance — happy to make any further changes!

@vmuralictr vmuralictr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR has one critical blocker: react-scripts@0.0.0 in package.json is an empty placeholder package that will break all build scripts (npm start, npm run build, npm test). Please revert to "5.0.1".

Additional issues noted in inline comments:

  • The audit will permanently fail from day one since react-scripts 5.0.1 already has known high/critical vulnerabilities — existing issues need to be fixed first
  • --omit=dev flag skips dev dependency audits
  • Workflow won't self-trigger when its own file changes

Also note there are merge conflicts that need to be resolved before this can be merged.

"react-paginate": "^8.2.0",
"react-router-dom": "^6.30.3",
"react-scripts": "5.0.1",
"react-scripts": "^0.0.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

react-scripts@0.0.0 is an empty placeholder on npm with no build scripts or dependencies. This will break npm start, npm run build, and npm test. Please revert to "5.0.1".

- 'react-frontend/**'
pull_request:
paths:
- 'react-frontend/**'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The paths filter doesn't include the workflow file itself, so changes to this workflow won't trigger the audit. This PR cannot self-verify. Consider adding .github/workflows/frontend-security-audit.yml to the paths list.

run: npm ci

- name: Run security audit
run: npm audit --audit-level=high --omit=dev

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--omit=dev skips auditing devDependencies. Vulnerabilities in build-time tools won't be caught. Consider removing this flag for full coverage, or add a comment explaining why dev vulnerabilities are intentionally excluded.

Comment thread docs/Contribute.md
## Security Policy for React Frontend

All pull requests that modify files under `react-frontend/` are subject
to an automated security audit via GitHub Actions. The CI pipeline runs `npm audit --audit-level=high` and will fail CI if any high or

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs say the CI "will fail if any high or critical vulnerabilities are introduced", but the workflow flags all existing ones too. Since react-scripts 5.0.1 already has known high/critical vulns, every PR touching react-frontend/ will fail CI immediately. Please fix existing vulnerabilities first or update the wording to reflect the actual behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add npm audit CI check to prevent future security vulnerabilities in react-frontend

3 participants