Skip to content

feat(cli): add sensitive flag annotation to DocFlag#3457

Merged
alkalescent merged 3 commits into
mainfrom
DSPX-2900/sensitive-flag-annotations
May 11, 2026
Merged

feat(cli): add sensitive flag annotation to DocFlag#3457
alkalescent merged 3 commits into
mainfrom
DSPX-2900/sensitive-flag-annotations

Conversation

@alkalescent
Copy link
Copy Markdown
Contributor

@alkalescent alkalescent commented May 11, 2026

Proposed Changes

  • Add Sensitive bool field to DocFlag struct with YAML support
  • Add MarkSensitiveFlags() method that propagates sensitive annotations to pflag via SetAnnotation
  • Mark wrapping-key and private-key-pem as sensitive in KAS key create/import/rotate man docs
  • Call MarkSensitiveFlags() in KAS key command setup

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

Run go test ./otdfctl/pkg/man/... -race -count=1

Summary by CodeRabbit

  • New Features

    • KAS key management commands (create, rotate, import) now properly mark --wrapping-key and --private-key-pem flags as sensitive inputs, ensuring the CLI framework handles secret material appropriately.
  • Documentation

    • Updated KAS key rotate command documentation to clarify wrapping-key and private-key-pem flag specifications for sensitive inputs.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Warning

Rate limit exceeded

@alkalescent has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 22 minutes and 45 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f41d1f4a-b2c0-47c2-bdbf-032e2ebfc720

📥 Commits

Reviewing files that changed from the base of the PR and between 73ed6f4 and 78a77b5.

📒 Files selected for processing (6)
  • otdfctl/cmd/policy/kasKeys.go
  • otdfctl/docs/man/policy/kas-registry/key/create.md
  • otdfctl/docs/man/policy/kas-registry/key/import.md
  • otdfctl/docs/man/policy/kas-registry/key/rotate.md
  • otdfctl/pkg/man/docflags.go
  • otdfctl/pkg/man/docflags_test.go
📝 Walkthrough

Walkthrough

This PR introduces infrastructure to mark CLI flag values as sensitive secrets across KAS key management commands. It adds a Sensitive boolean field to the documentation flag model, implements MarkSensitiveFlags() to apply pflag annotations, documents the sensitive flags in command schemas, and integrates the marking calls into create, rotate, and import commands to prevent secret values from appearing in logs.

Changes

Sensitive CLI Flags for KAS Key Commands

Layer / File(s) Summary
Data Model and Annotation Infrastructure
otdfctl/pkg/man/docflags.go
Added SensitiveAnnotationKey constant and Sensitive bool field to DocFlag to enable marking flags whose values should be treated as secrets in the documentation.
Flag Marking Method
otdfctl/pkg/man/docflags.go
Implemented (*Doc).MarkSensitiveFlags() to iterate over documented flags and apply pflag annotations for entries marked sensitive.
Sensitivity Tests
otdfctl/pkg/man/docflags_test.go
Three tests validate YAML parsing of the Sensitive field, annotation application to registered sensitive flags, and safe handling of unregistered sensitive flag entries.
Command Documentation Updates
otdfctl/docs/man/policy/kas-registry/key/create.md, otdfctl/docs/man/policy/kas-registry/key/import.md, otdfctl/docs/man/policy/kas-registry/key/rotate.md
Updated KAS key command docs to mark wrapping-key and private-key-pem flags as sensitive: true; rotate.md also corrects wrapping-key encoding description from base64 to hex.
Command Flag Marking Integration
otdfctl/cmd/policy/kasKeys.go
Added MarkSensitiveFlags() calls to create, rotate, and import KAS key commands after flag registration.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hopping through flags with care and grace,
Wrapping keys in a safe place,
Marked as sensitive, secrets hide,
No logs to leak what we confide!
CLI commands now more wise, 🔐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding sensitive flag annotation capability to the DocFlag structure and applying it to KAS key commands.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-2900/sensitive-flag-annotations

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the CLI security by introducing a mechanism to mark specific flags as sensitive. By adding a 'Sensitive' annotation to the documentation metadata, the system can now automatically propagate these settings to the underlying pflag configuration, ensuring that sensitive information like cryptographic keys is properly handled and protected from being exposed in logs or process listings.

Highlights

  • Sensitive Flag Annotation: Introduced a 'Sensitive' field to the 'DocFlag' struct and added a 'MarkSensitiveFlags' method to propagate this metadata to pflag annotations.
  • Documentation Updates: Updated KAS key command documentation to mark 'wrapping-key' and 'private-key-pem' as sensitive.
  • Command Integration: Integrated 'MarkSensitiveFlags' into the KAS key command setup to ensure sensitive data is correctly identified for security purposes.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


A flag is marked with secret care, / To keep the keys from public air. / With annotations set in place, / No sensitive data leaves a trace.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to mark sensitive CLI flags (like cryptographic keys) using documentation metadata, ensuring they are annotated for secure handling in logs. Feedback focuses on ensuring MarkSensitiveFlags is called after all flags are registered, correcting an encoding description in the documentation from base64 to hex, and enhancing security by panicking on annotation failures instead of ignoring them.

Comment thread otdfctl/cmd/policy/kasKeys.go Outdated
Comment thread otdfctl/cmd/policy/kasKeys.go Outdated
Comment thread otdfctl/cmd/policy/kasKeys.go Outdated
Comment thread otdfctl/docs/man/policy/kas-registry/key/rotate.md Outdated
Comment thread otdfctl/pkg/man/docflags.go Outdated
Comment thread otdfctl/pkg/man/docflags_test.go Outdated
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 195.403004ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 90.965782ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 453.56162ms
Throughput 220.48 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.660498924s
Average Latency 435.355837ms
Throughput 114.52 requests/second

@alkalescent alkalescent force-pushed the DSPX-2900/sensitive-flag-annotations branch from 4ab0dce to 73ed6f4 Compare May 11, 2026 19:20
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 195.35592ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 99.190207ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 420.409181ms
Throughput 237.86 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.199855928s
Average Latency 430.517735ms
Throughput 115.74 requests/second

@alkalescent alkalescent marked this pull request as ready for review May 11, 2026 19:30
@alkalescent alkalescent requested a review from a team as a code owner May 11, 2026 19:30
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@otdfctl/docs/man/policy/kas-registry/key/rotate.md`:
- Line 34: The docs show the `wrapping-key` example value in
policy/kas-registry/key/rotate.md still using a base64-like string
(`YWVzIGtleQ==`) while the field description requires hex-encoded AES key;
update the example under the `wrapping-key` entry to a valid hex-encoded AES key
(e.g., 32-byte key = 64 hex chars for AES-256) so the example matches the
description and will work in `mode: local` usage of the rotation command.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab5958cc-b230-4237-98c9-674673e36fb6

📥 Commits

Reviewing files that changed from the base of the PR and between 69a6210 and 73ed6f4.

📒 Files selected for processing (6)
  • otdfctl/cmd/policy/kasKeys.go
  • otdfctl/docs/man/policy/kas-registry/key/create.md
  • otdfctl/docs/man/policy/kas-registry/key/import.md
  • otdfctl/docs/man/policy/kas-registry/key/rotate.md
  • otdfctl/pkg/man/docflags.go
  • otdfctl/pkg/man/docflags_test.go

Comment thread otdfctl/docs/man/policy/kas-registry/key/rotate.md
Add a `sensitive` field to DocFlag and a MarkSensitiveFlags method that
propagates the annotation to pflag, enabling downstream tools (e.g. MCP
servers) to redact sensitive values from logs without hardcoding flag names.

Signed-off-by: Krish Suchak <ksuchak@virtru.com>
Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
Move MarkSensitiveFlags() after injectLabelFlags() so annotations run
after all flags are registered. Fix pre-existing "base64" → "hex" typo
in rotate.md wrapping-key description.

Signed-off-by: Krish Suchak <ksuchak@virtru.com>
Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@alkalescent alkalescent force-pushed the DSPX-2900/sensitive-flag-annotations branch from 73ed6f4 to 78a77b5 Compare May 11, 2026 20:07
@github-actions
Copy link
Copy Markdown
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 205.408569ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 100.054814ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 414.020049ms
Throughput 241.53 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.568460295s
Average Latency 443.907505ms
Throughput 112.19 requests/second

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

@alkalescent alkalescent added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit 98f48d2 May 11, 2026
39 checks passed
@alkalescent alkalescent deleted the DSPX-2900/sensitive-flag-annotations branch May 11, 2026 21:06
JBCongdon pushed a commit to JBCongdon/platform that referenced this pull request May 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.32.0](opentdf/platform@otdfctl/v0.31.0...otdfctl/v0.32.0)
(2026-05-19)


### Features

* **cli:** Add better unit testing.
([opentdf#3378](opentdf#3378))
([3ad33dc](opentdf@3ad33dc))
* **cli:** Add interactive review for prune plans
([opentdf#3421](opentdf#3421))
([c11680b](opentdf@c11680b))
* **cli:** Add prune confirmation.
([opentdf#3469](opentdf#3469))
([c6d47ec](opentdf@c6d47ec))
* **cli:** Add prune planner.
([opentdf#3411](opentdf#3411))
([3e294e6](opentdf@3e294e6))
* **cli:** Add prune summary information
([opentdf#3456](opentdf#3456))
([c900c53](opentdf@c900c53))
* **cli:** add sensitive flag annotation to DocFlag
([opentdf#3457](opentdf#3457))
([98f48d2](opentdf@98f48d2))
* **cli:** Confirm and execute pruning of legacy objects
([opentdf#3458](opentdf#3458))
([24c09dd](opentdf@24c09dd))
* **cli:** Print report on failure
([opentdf#3365](opentdf#3365))
([05a4473](opentdf@05a4473))
* **cli:** Sort parameters.
([opentdf#3478](opentdf#3478))
([73ad878](opentdf@73ad878))
* **policy:** Add FQN to RegisteredResourceValues
([opentdf#3446](opentdf#3446))
([3199583](opentdf@3199583))
* **policy:** Add resource mapping group FQNs
([opentdf#3447](opentdf#3447))
([6a0b3c6](opentdf@6a0b3c6))


### Bug Fixes

* **cli:** Prune was not classifying multi-namespaced RRs properly.
([opentdf#3488](opentdf#3488))
([eae8645](opentdf@eae8645))
* **cli:** support json profile output
([opentdf#3448](opentdf#3448))
([61f194c](opentdf@61f194c))
* **deps:** bump github.com/opentdf/platform/lib/identifier from 0.3.0
to 0.4.0 in /otdfctl
([opentdf#3367](opentdf#3367))
([aa23179](opentdf@aa23179))
* **deps:** bump github.com/opentdf/platform/protocol/go from 0.27.0 to
0.28.0 in /otdfctl
([opentdf#3419](opentdf#3419))
([c80374f](opentdf@c80374f))
* **deps:** bump github.com/opentdf/platform/sdk from 0.16.0 to 0.17.0
in /otdfctl ([opentdf#3397](opentdf#3397))
([bb9fcd6](opentdf@bb9fcd6))
* **deps:** bump go.opentelemetry.io/otel from 1.40.0 to 1.41.0 in
/otdfctl ([opentdf#3400](opentdf#3400))
([5631c37](opentdf@5631c37))
* **deps:** bump module protocol/go to v0.30.0 throughout
([opentdf#3459](opentdf#3459))
([8eaa502](opentdf@8eaa502))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Co-authored-by: Chris Reed <87077975+c-r33d@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants