fix(CostTracker): stop false BYPASS alerts on manifests + fix dead x-api-key detector#1321
Open
ugiya wants to merge 1 commit into
Open
fix(CostTracker): stop false BYPASS alerts on manifests + fix dead x-api-key detector#1321ugiya wants to merge 1 commit into
ugiya wants to merge 1 commit into
Conversation
…ifier Reworks the manifest false-positive fix after two review passes: - Exempt dependency manifests/lockfiles ONLY for SDK-dependency patterns (kind-gated), so `--bare`/raw-HTTP inside a manifest's scripts still classify as bypass (the v1 fix masked them). - Fix the x-api-key RISK_PATTERN regex: `\\|` was a literal pipe, not alternation, so the detector never matched real code -> x-api-key.*(anthropic|sk-ant). - Raw-HTTP patterns now classify bypass, not unknown. - Stable id+kind per RISK_PATTERN; baseline keyed on file:line:patternId so note/classification changes no longer churn the baseline. - Exact-basename manifest match (not endsWith); drop dead bun.lockb; exclude config-with-scripts files (deno.json/composer.json); LEGIT_HINTS win before the manifest check. - Add CostTracker.test.ts (bun test, 13 cases) incl. the --bare-in-package.json regression, baseline-key stability, and the regex fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What you see (the symptom)
On a normal PAI install, the hourly CostTracker cron pops a macOS cost alert (#1319) for
package.jsondependency declarations, while a broken detector regex silently misses real rawx-api-keycalls (#1320). This PR fixes both and hardens the classifier.What this changes
package.json/lockfile dependency declarations classifylegit, but--bare/raw-HTTP inside a manifest's scripts still classifybypass(an earlier naive fix masked them).x-api-keyregex —\|(literal pipe) →(anthropic|sk-ant)alternation; the detector was matching nothing.bypass, notunknown.id+kindper RISK_PATTERN; baseline keyed onfile:line:patternIdso note/classification changes no longer churn the baseline ("phantom NEW").endsWith); drop deadbun.lockb; exclude config-with-scripts (deno.json/composer.json);LEGIT_HINTSwin before the manifest check.CostTracker.test.ts(bun test, 13 cases) incl. the--bare-in-package.jsonregression, baseline-key stability, and the regex fix.Verification
bun test→ 13 pass / 0 fail. Localscan→ bypass 0;alert-check→ no alerts.Not in this PR (follow-ups)
Fixes #1319
Fixes #1320
🤖 Generated with Claude Code