Skip to content

fix: derive alert action from publicPolicy for public tokens#537

Merged
John-David Dalton (jdalton) merged 1 commit intomainfrom
fix/reshape-public-policy-action
Apr 2, 2026
Merged

fix: derive alert action from publicPolicy for public tokens#537
John-David Dalton (jdalton) merged 1 commit intomainfrom
fix/reshape-public-policy-action

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

Summary

  • Use publicPolicy map as source of truth for alert actions in reshapeArtifactForPublicPolicy, instead of trusting the server-assigned alert.action field
  • For public token users, action is now derived client-side via publicPolicy.get(alert.type), ensuring deterministic results regardless of server behavior
  • Reshaped alerts now include the derived action field in the output (e.g., malware → 'error', criticalCVE → 'warn')

Test plan

  • Updated test/unit/http-client.test.mts — action filtering and alert compaction tests use real publicPolicy alert types
  • Rewrote test/unit/reshape-artifact-public-policy.test.mts — all tests use real alert types (malware, criticalCVE, deprecated) and verify derived action field
  • Added edge case test for unknown alert types (action resolves to undefined, alert still passes through)
  • All 485 tests pass, build and type check clean

…cPolicy

Use the client-side publicPolicy map as the source of truth for alert
actions when reshaping artifacts for public token users, instead of
trusting the server-assigned alert.action field. This ensures
deterministic, policy-consistent results regardless of server behavior.
@jdalton John-David Dalton (jdalton) enabled auto-merge (squash) April 2, 2026 05:15
@jdalton
Copy link
Copy Markdown
Contributor Author

Note: PR #538 (checkMalware API) touches overlapping code. Whichever lands first will require a rebase of the other.

@jdalton John-David Dalton (jdalton) merged commit 5cbca82 into main Apr 2, 2026
10 checks passed
@jdalton John-David Dalton (jdalton) deleted the fix/reshape-public-policy-action branch April 2, 2026 12:27
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.

2 participants