fix: allow secure .npmrc files, validate for credentials#108
Merged
Conversation
- Remove .npmrc from blanket deny list - Add validate_npmrc() function to check file contents - Block .npmrc files containing auth tokens or credentials - Checks for: _authToken, _auth, _password patterns - Warn (but allow) .npmrc files missing 'ignore-scripts=true' - Provide helpful guidance for secure npm configuration Resolves issue where developers couldn't commit project .npmrc files with security controls (ignore-scripts, audit settings) because caulking blocked all .npmrc files regardless of content. Security rationale: - Project .npmrc with security settings is GOOD (prevents supply chain attacks) - User .npmrc with auth tokens is BAD (credentials in git history) - This change blocks the latter while allowing the former Co-authored-by: OpenCode Agent <agent@gsa.gov>
54fab94 to
c29c894
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Caulking currently blocks all
.npmrcfiles from being committed, even legitimate project-level configuration files that contain security controls.This is blocking developers who want to commit project
.npmrcfiles with recommended security settings like:ignore-scripts=true(prevents arbitrary script execution during npm install)audit=true(enables vulnerability scanning)Reported by: @AndrewBurnes (blocked on commit)
Current Behavior
$ git add .npmrc $ git commit -m "Add npm security config" ERROR: forbidden file staged: .npmrc Caulking blocked a forbidden file from being committed.Why This Is a Problem
Good .npmrc (should be allowed):
Bad .npmrc (should be blocked):
Caulking was treating both the same way — blocking everything.
Solution
Changes
Removed
.npmrcfrom blanket deny list.npmrcfiles unconditionallyAdded
validate_npmrc()functionCredential Detection
_authToken_auth_password:_authToken)Security Controls Validation
ignore-scripts=trueValidation Logic
Helpful Error Messages
When credentials detected:
Testing
✅ Test 1: Safe .npmrc (should pass)
✅ Test 2: .npmrc with credentials (should block)
✅ Test 3: .npmrc missing security controls (should warn)
✅ Shellcheck passes
✅ All pre-commit hooks pass
Security Rationale
Why This Is Safe
ignore-scripts=trueWhy This Is Important
Supply chain security best practice:
Blocking all
.npmrcfiles prevents teams from implementing this critical security control.Threat Model
Rollout
After merge:
make install(or pull and./install.sh).npmrc:Related
Resolves blocking issue for project-level npm security configurations.