Skip to content

feat(policy): safedep policy decision list - #69

Merged
abhisek merged 4 commits into
claude/pensive-sagan-3x8anyfrom
claude/pensive-sagan-3x8any-decision-list
Nov 5, 2026
Merged

abhisek merged 4 commits into
claude/pensive-sagan-3x8anyfrom
claude/pensive-sagan-3x8any-decision-list

Conversation

@abhisek

@abhisek abhisek commented Nov 4, 2026

Copy link
Copy Markdown
Member

Summary

This is the CLI part of safedep/control-tower#1636. safedep policy decision list lists the decisions that pmg and the pull request check made with the cloud policy: which rule or field decided, at which revision, and where. It reads PolicyService.ListPolicyDecisions from safedep/api#260. The server is in safedep/control-tower#1644.

This PR is stacked on #67, which adds the safedep policy tree. Merge #67 first. GitHub then moves the base of this PR to main.

Changes

  • SDK bump to the build of safedep/api#260 (20261104174030-9113dd6a8ea6), with the PolicyServiceClient mock made again by mockery. The move of GitRef to scm.v1 breaks nothing here, because the CLI does not use it.
  • duration.Window: audit event list and the new command share the --since and --until check. The audit messages and help text do not change, and a test asserts the help text.
  • safedep policy decision list:
Flag Meaning
--since, --until the time window, with the same rules as audit event list
--tool pmg, pull-request-check or vet
--outcome blocked, failed or allowed
--revision, --rule, --path parts of the citation
--override a name or an id. The CLI looks it up in the policy at --revision, or at head. The id of a deleted override goes to the server as it is.
--package a PURL with no version, such as pkg:npm/@acme/ui or pkg:maven/org.acme/core. The CLI takes the ecosystem from the PURL and keeps the name as the ecosystem stores it.
--project, --endpoint ids
--limit, --page-token paging, as in the sibling list commands

The CLI checks the length limits of the proto locally and names the flag in the error.

Output

Column Content
WHEN the humanized time
TOOL pmg, the pull request check or vet
PACKAGE eco/name@version
OUTCOME blocked, failed or allowed
DECIDED BY the rule or the field path, then override NAME, default policy or base
REV the tenant revision. When the default policy decided, the cell adds its revision, as in 47 · default 12.
WHERE pmg: the hostname and the user, plus one hint (the CI repository, else the Kubernetes workload, else the agent). Pull request check: repo#number. Scan: repo@ref.
LINK shown only when a row has a link

Plain output keeps exact values. JSON output gives the server messages as they are, with every field of the contract. The table and the plain output escape all server text.

Until safedep/control-tower#1644 is deployed, the server answers Unimplemented, and the command says that SafeDep Cloud does not have the decision log yet.

Review

A Fable review checked the branch three ways: adversarially, against the contract, and for clean code. It found one blocking defect: the CLI refused --override with the id of a deleted override. The last commit fixes it. The same commit also:

  • keeps package names exactly as each ecosystem stores them;
  • checks the length limits locally;
  • restores the audit help text;
  • builds the filters once.

Testing

  • The tests are table-driven and use the mocks. They cover:
    • each filter and each refusal;
    • unset flags, which send no Filters;
    • the deleted override id;
    • a cooldown decision with its path and the default revision;
    • each kind of place;
    • escaping;
    • an empty page and paging;
    • JSON output;
    • each error mapping.
  • make lint-conventions, make lint, make test and make build pass. The lint reports 0 issues.
  • No live test was run, because the server is not deployed yet.

Generated by Claude Code

The policy decision log needs the RPC ListPolicyDecisions of
PolicyService. The API build 20261104174030-9113dd6a8ea6 adds it. The
regenerated PolicyServiceClient mock gets the new method. The same build
moves GitRef to safedep.messages.scm.v1. The CLI does not use GitRef, so
no other code changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
audit event list turned --since and --until into a time range in its own
code. policy decision list needs the same flags with the same checks. The
logic now lives in duration.Window, so both commands refuse the same
input with the same message. The audit behavior does not change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
An admin who changes a rule, or who sees a blocked install, could not
ask which decisions a revision, an override or a rule made, and where.
The new command reads ListPolicyDecisions and lists the decisions of pmg
and the pull request check, newest first.

Each filter of the RPC has a flag: --since, --until, --tool, --outcome,
--revision, --rule, --override, --path, --package, --project and
--endpoint. --override takes a name or an id and resolves it in the
policy at --revision, or at head. --package takes a PURL with no version.

Each row shows the time, the tool, the package version, the outcome, the
rule or field with its layer or override, the revision, and the place.
The revision cell adds the default policy revision when the default
policy decided, so a cooldown block shows both. A pmg place is the
hostname and the user, with one hint: the CI repository, else the
Kubernetes workload, else the agent. A check shows the repository, the
pull request number and the link. A scan shows the repository and the
ref. The JSON output writes the messages of the server in protojson.

The errors map to a missing entitlement, a role that cannot read the
policy, a bad page token or filter, and a server without the RPC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
…lengths

A review of policy decision list found these problems:

- --override with the id of a deleted override failed with "no policy
  override is named". A stored decision keeps that id, and the server
  matches it. The command now sends a value with the shape of an
  override id ("ov_" and 8 to 64 Crockford base32 characters) as is when
  the policy does not have it. Other unknown values still fail.
- --package let the PURL parser change the name. The parser lowercases
  a PyPI name and drops the vendor of a Composer package, but the server
  compares the stored name exactly. The command now takes only the
  ecosystem from the parser and builds the name from the PURL as
  written: npm @scope/name, Maven group:artifact, the Go module path,
  Composer vendor/name. It refuses qualifiers and a subpath.
- The command did not check the length limits of the filters. It now
  refuses a --rule or --override over 64 characters, a --path over 256,
  a --project over 128, an --endpoint over 100 and a package name over
  255, with the flag name in the message.
- duration.Window changed the help of audit event list from "for the
  events" to "for the time". The caller now gives the noun, so the
  audit text is the same as before.
- The command built the filters three times. It now checks the flags
  once in Args and passes the result to the run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
@safedep

safedep Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

Package Details
Package Malware Vulnerability Risky License Report
icon buf.build/gen/go/safedep/api/grpc/go @ v1.6.2-20261104174030-9113dd6a8ea6.1
go.mod
ok icon
ok icon
ok icon
🔗
icon buf.build/gen/go/safedep/api/protocolbuffers/go @ v1.36.12-20261104174030-9113dd6a8ea6.2
go.mod
ok icon
ok icon
ok icon
🔗

View complete scan results →

This report is generated by SafeDep GitHub App

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 7978e52b-9b92-4940-af3b-cca6f8aa8096

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T19:02:02.179019Z ddaa59a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@abhisek
abhisek merged commit ddaa59a into claude/pensive-sagan-3x8any Nov 5, 2026
4 checks passed

abhisek commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

The author asked for one PR. The four commits of this PR are now on the branch of #67, with a fast-forward to ddaa59a, so #67 carries safedep policy decision list. This PR closes without a merge.


Generated by Claude Code

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