-
Notifications
You must be signed in to change notification settings - Fork 1
move npm-security container from private repo #23
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR introduces a security-focused Docker container that validates NPM dependencies by running npm install in an isolated environment and scanning for known malicious files associated with the Sha1-Hulud malware (documented from Nov 24, 2025).
Key changes:
- Creates a containerized security scanner with malware hash detection
- Implements GitHub token validation to prevent write-access tokens
- Provides a reusable GitHub Actions workflow for CI/CD integration
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| npm-security/entrypoint.sh | Main security validation script with token checks, npm install, and hash-based malware detection |
| npm-security/README.md | Comprehensive documentation covering usage, security features, and integration examples |
| npm-security/Dockerfile | Alpine-based Node.js container configuration running as non-root user |
| npm-security/.npmrc | NPM configuration for GitHub Package Registry authentication |
| .github/workflows/verify-npm-security.yml | Reusable workflow for automated NPM security verification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [ -f /app/package.json ] ; then cp /app/package.json ~/test/package.json; fi | ||
| if [ -f /app/package-lock.json ] ; then cp /app/package-lock.json ~/test/package-lock.json; fi |
Copilot
AI
Dec 7, 2025
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.
The working directory is set to /home/node/test in the Dockerfile, but these commands copy to ~/test/. Since the script runs as the 'node' user, ~ expands to /home/node/, making the destination /home/node/test/. However, the source path /app/ doesn't align with the /home/node/test working directory. The volume mount is expected at /app, but the script should work within the current directory. Consider using cp /app/package*.json . or clarifying the directory structure.
| if [ -f /app/package.json ] ; then cp /app/package.json ~/test/package.json; fi | |
| if [ -f /app/package-lock.json ] ; then cp /app/package-lock.json ~/test/package-lock.json; fi | |
| if [ -f /app/package.json ] ; then cp /app/package.json ./package.json; fi | |
| if [ -f /app/package-lock.json ] ; then cp /app/package-lock.json ./package-lock.json; fi |
|
|
||
| if [ -f /app/package.json ] ; then cp /app/package.json ~/test/package.json; fi | ||
| if [ -f /app/package-lock.json ] ; then cp /app/package-lock.json ~/test/package-lock.json; fi | ||
| if [ -f /.env ] ; then echo ".env file found. Exiting"; exit $EXIT_INSTALLATION_ERROR; fi |
Copilot
AI
Dec 7, 2025
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.
The path /.env checks for a .env file in the root directory, but based on the volume mount at /app and working directory structure, this should likely be /app/.env or ./.env to check in the project directory. The current path would only catch a .env file in the container's root filesystem.
| if [ -f /.env ] ; then echo ".env file found. Exiting"; exit $EXIT_INSTALLATION_ERROR; fi | |
| if [ -f /app/.env ] ; then echo ".env file found. Exiting"; exit $EXIT_INSTALLATION_ERROR; fi |
| # Exit if malicious files found | ||
| [ -n "$SUSPICIOUS_FILES" ] && { | ||
| echo "SECURITY ALERT: Malicious files detected!" | ||
| echo "$SUSPICIOUS_FILES" |
Copilot
AI
Dec 7, 2025
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.
[nitpick] The suspicious files output should be formatted for better readability and actionability. Consider iterating over the results to show the file path and hash separately, making it easier to identify which specific files triggered the alert.
| echo "$SUSPICIOUS_FILES" | |
| echo "The following suspicious files were found:" | |
| echo "$SUSPICIOUS_FILES" | while read -r line; do | |
| HASH=$(echo "$line" | awk '{print $1}') | |
| FILE=$(echo "$line" | awk '{print $2}') | |
| echo " File: $FILE" | |
| echo " Hash: $HASH" | |
| echo "-----------------------------" | |
| done |
|
For better maintainability for future threats:
Separate thought: An agent can create PRs to malicious checksums & patterns based on information from daily security feeds. |
Description
Moves NPM security container from private repo, to run
npm iin an isolated container first.