Prevent stale npm metadata false positives in threat detection#35148
Merged
Conversation
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix threat detection for stale npm metadata
Prevent stale npm metadata false positives in threat detection
May 27, 2026
mnkiefer
approved these changes
May 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the threat-detection prompt to reduce stale npm metadata false positives when evaluating package-lock.json dependency updates, and adds a regression test to preserve that prompt contract.
Changes:
- Adds npm lockfile validation guidance requiring current registry metadata checks.
- Adds template assertions for the new npm validation guidance.
- Updates the generated compiler threat-spec optimizer lock workflow, including its schedule metadata.
Show a summary per file
| File | Description |
|---|---|
actions/setup/md/threat_detection.md |
Adds npm metadata validation instructions to the malicious dependency criteria. |
pkg/workflow/threat_detection_file_access_test.go |
Adds a test asserting the prompt contains the npm validation guidance. |
.github/workflows/daily-compiler-threat-spec-optimizer.lock.yml |
Refreshes generated workflow metadata and schedule output. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 2
…ge validation Add registry.npmjs.org to the threat-detection ecosystem domains so that detection runs can perform read-only npm package validation (e.g. verifying lockfile integrity hashes via `npm view`). This does not permit registry access for installs — only metadata lookups during threat analysis. Update the GetThreatDetectionAllowedDomains comment and tests accordingly. Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Collaborator
|
@copilot Revert changes to |
…inal state Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Contributor
Author
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.
Threat detection was classifying some npm dependency updates as malicious using stale registry assumptions (e.g., version non-existence). This change updates the malicious-patch criteria so npm lockfile alerts require validation against current npm metadata, including tarball URL and integrity consistency.
Threat detection prompt hardening (
actions/setup/md/threat_detection.md)npm view <package>@<version> --jsonor equivalent registry endpoint).resolvedmatches official tarball URL,integritymatches official hash.npm registry domain allowlist (
pkg/workflow/data/ecosystem_domains.json,pkg/workflow/domains.go)registry.npmjs.orgto thethreat-detectionecosystem domains so detection runs can reach the npm registry for read-only package validation (npm view, integrity/tarball checks).Regression guard on template contract (
pkg/workflow/threat_detection_file_access_test.go,pkg/workflow/domains_test.go)registry.npmjs.orgis now a required detection domain.