Skip to content

Add safedep workload commands for providers, trust rules and exchanges - #80

Merged
Sahilb315 merged 5 commits into
mainfrom
claude/pensive-sagan-3x8any-wi-workload
Nov 24, 2026
Merged

Sahilb315 merged 5 commits into
mainfrom
claude/pensive-sagan-3x8any-wi-workload

Conversation

@abhisek

@abhisek abhisek commented Nov 23, 2026

Copy link
Copy Markdown
Member

Closes #77. Part of safedep/control-tower#1691.

An admin needs a CLI to let CI jobs call SafeDep Cloud with their GitHub Actions identity instead of an API key. These commands call WorkloadAdminService on control-tower.

Commands

  • safedep workload provider list: the workload identity providers of the tenant, with the KIND:ACCOUNT name that --provider takes, such as github-actions:acme.
  • safedep workload rule create NAME --provider P --grant tool [--repository OWNER/NAME...] [--ref REF...] [--event EVENT...] [--project-binding auto|manual] [--max-lifetime DURATION].
    • --provider is required, also for a tenant with one provider. Without it, the command fails and lists the providers.
    • A rule with no --repository covers every repository of the account, and the command says so.
    • A --ref that ends in /* is a prefix condition. A rule cannot mix prefix refs and full refs.
    • --project-binding and --max-lifetime stay unset unless given, so the server default applies.
    • The command checks the name, grant, repositories and refs with the server's patterns before any RPC.
  • safedep workload rule list | show | delete. RULE is a rule id, or the name of a live rule. rule delete asks for confirmation in a terminal and needs --yes when no terminal is present. The question says that the rule's CI jobs lose access to SafeDep Cloud, and for a rule with no repository, that it covers every repository of the account.
  • safedep workload exchange list [--denied] [--since 7d] [--rule RULE].

Lists print a table, --output plain or --output json. A JSON list is an object with the items and next_page_token. Each leaf command has a page in docs/.

Server errors

Each refusal of rule create has its own message:

  • a repository outside the GitHub App installation, with each repository that the server named;
  • a suspended installation;
  • an unlinked provider;
  • a duplicate name;
  • an invalid claim;
  • a caller that is not an Admin;
  • an Unavailable error.

Other changes

  • The SafeDep API SDK moves to build 20261120125025-1b99964cacca, which holds WorkloadAdminService. go.mod has no connectrpc module, so two modules move.
  • internal/rpcerror now holds the gRPC status text helpers that were in internal/cmd/policy/errors.go, because command packages cannot import each other. The policy commands keep their messages and codes. Their generic test cases moved to internal/rpcerror.

Test plan

  • make build, go test ./..., make lint-conventions (golangci-lint v2.12.1) pass.
  • Unit tests cover provider resolution, the create request, the server error mappings, the flag checks, FuzzRefCondition, rule lookup by name over many pages, the delete confirmation, the exchange filters and the output of each list.
  • Each new test fails when the code it guards is removed.

Generated by Claude Code

The workload commands need WorkloadAdminService and its messages, which the
build 20261120125025-1b99964cacca holds. The grpc and protocolbuffers modules
move to that build. The CLI does not use the connectrpc module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
The workload commands show server errors with the same text as the policy
commands: the status message without the service prefix, and each field
violation with a readable field path. Sibling command packages cannot import
each other, so the helpers move to internal/rpcerror. The policy package
keeps its document paths and duration text on top of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
Admins need a CLI for workload identity, so a GitHub Actions job can call
SafeDep Cloud with no API key. The new commands call WorkloadAdminService:

- safedep workload provider list
- safedep workload rule create NAME --provider PROVIDER --grant tool
  [--repository OWNER/NAME...] [--ref REF...] [--event EVENT...]
- safedep workload rule list | show | delete
- safedep workload exchange list [--denied] [--since D] [--rule RULE]

rule create never picks a provider. With no --provider, or an unknown one, it
fails and lists the providers of the tenant. --provider takes a provider id or
KIND:ACCOUNT, as in github-actions:acme. The command prints the rule with the
numeric id of each repository that the server stored, and warns when the rule
covers every repository of the account. A repository that the installation
cannot see fails with each repository that the server named. rule show,
rule delete and exchange list --rule take a rule id or a rule name.

Each leaf command has a doc page, and the README links to each one.

Closes #77

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MhRi597EX9odoSDXbVBsxz
internal/rpcerror had no test of its own, so the policy tests guarded it.
The cases that do not depend on the policy document paths move to
TestDescribe, which calls Describe directly. The policy tests keep the
cases of the document paths.

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

rule delete asks in a terminal and needs --yes with no terminal, as policy
rule delete does. The question says that the CI jobs of the rule lose access
to SafeDep Cloud, and that a rule with no repository covers every repository
of the account.

rule create takes --project-binding auto|manual and --max-lifetime from 1m
to 6h. Each stays unset unless given, so the server default applies.

Other fixes:

- A KIND:ACCOUNT that names two providers now suggests a provider id, not
  the same name again.
- exchange list says when --rule names no live rule and no exchange
  matches, because the value went to the server as a rule id.
- An UNAVAILABLE on rule create shows the server message. A transport
  failure or a gateway also sends that code, so the text does not blame
  GitHub.
- --repository uses the pattern, length and count limits of the API, so
  a value such as "acme/web app" fails at the flag.

The tests cover a name on a second page of rules and of providers, the
three list renderers, and rule list with a provider id.

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

safedep Bot commented Nov 23, 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-20261120125025-1b99964cacca.1
go.mod
ok icon
ok icon
ok icon
🔗
icon buf.build/gen/go/safedep/api/protocolbuffers/go @ v1.36.12-20261120125025-1b99964cacca.2
go.mod
ok icon
ok icon
ok icon
🔗

View complete scan results →

This report is generated by SafeDep GitHub App

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T09:38:51.512252Z d4a2992 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.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

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: 3a90ca8c-68d1-4b85-bc7b-64f7eda5c296
Commits

Reviewing files that changed from the base of the PR and between 199b10b and d4a2992.

Files ignored due to path filters: 1

  • go.sum is excluded by !**/*.sum
Files selected for processing: 33

  • .mockery.yml
  • README.md
  • docs/cmd/workload-exchange-list.md
  • docs/cmd/workload-provider-list.md
  • docs/cmd/workload-rule-create.md
  • docs/cmd/workload-rule-delete.md
  • docs/cmd/workload-rule-list.md
  • docs/cmd/workload-rule-show.md
  • go.mod
  • internal/cmd/policy/editor.go
  • internal/cmd/policy/errors.go
  • internal/cmd/policy/errors_test.go
  • internal/cmd/safedep.go
  • internal/cmd/workload/cmd.go
  • internal/cmd/workload/errors.go
  • internal/cmd/workload/exchange.go
  • internal/cmd/workload/exchange_test.go
  • internal/cmd/workload/exchange_view.go
  • internal/cmd/workload/fixtures_test.go
  • internal/cmd/workload/mocks/WorkloadAdminServiceClient_mock.go
  • internal/cmd/workload/provider.go
  • internal/cmd/workload/provider_resolve.go
  • internal/cmd/workload/render_test.go
  • internal/cmd/workload/rule_create.go
  • internal/cmd/workload/rule_create_test.go
  • internal/cmd/workload/rule_delete.go
  • internal/cmd/workload/rule_input.go
  • internal/cmd/workload/rule_list.go
  • internal/cmd/workload/rule_show.go
  • internal/cmd/workload/rule_test.go
  • internal/cmd/workload/rule_view.go
  • internal/rpcerror/rpcerror.go
  • internal/rpcerror/rpcerror_test.go
  • 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

@Sahilb315
Sahilb315 merged commit 603b708 into main Nov 24, 2026
7 checks passed
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.

[Workload Identity] safedep workload provider, rule and exchange commands

3 participants