Skip to content

feat: Add Secret redaction functionality with content-based hashing#1230

Open
John-Lin wants to merge 6 commits intoint128:mainfrom
John-Lin:feat/secret-redact
Open

feat: Add Secret redaction functionality with content-based hashing#1230
John-Lin wants to merge 6 commits intoint128:mainfrom
John-Lin:feat/secret-redact

Conversation

@John-Lin
Copy link
Copy Markdown

@John-Lin John-Lin commented Aug 1, 2025

This PR introduces Secret redaction functionality to the Kustomize action.

Screenshot 2025-08-01 at 17 35 37

Changes

  • New Feature: Implements Secret resource redaction with content-based hashing to ensure consistent
    output while protecting sensitive data
  • Robust YAML Processing: Integrates js-yaml library for reliable parsing, replacing manual string
    manipulation

Files Modified

  • Added src/redact.ts with core redaction logic
  • Updated action configuration and dependencies
  • Added comprehensive test suite with fixtures
  • Updated documentation

John-Lin and others added 5 commits August 1, 2025 14:58
- Add redact-secrets input parameter to action.yaml (default: false)
- Implement Secret redaction logic in src/redact.ts
- Redact data and stringData fields in Kubernetes Secret resources
- Handle multiline values, special characters, and various Secret types
- Add comprehensive test suite with 20 test cases covering edge cases
- Update README.md with usage documentation and examples
- Integrate redaction step after kustomize build in processing pipeline

This feature allows users to safely redact sensitive data from Kubernetes
Secrets in generated manifests, preventing accidental exposure in CI/CD logs
or artifact storage while preserving the structure of non-sensitive resources.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Generate deterministic hash-based redacted values for better diff visibility
- Maintain consistent redaction for identical content across runs
- Improve test coverage with hash validation and edge cases
- Preserve original security while enabling change detection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix skipMultilineValue state not resetting when encountering new key-value pairs
- Add comprehensive edge case tests for redaction failure scenarios
- Ensure proper redaction of fields following multiline values
- Validate handling of comments, indentation, and API version edge cases

This resolves the issue where sso-issuer and similar fields were not being
redacted when they appeared after multiline values in Secret data fields.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Move js-yaml from devDependencies to dependencies
- Add @types/js-yaml for TypeScript support
- Replace complex 198-line manual parsing with js-yaml.load/dump
- Simplify redactSecretInDocument function (-59 lines, 30% reduction)
- Remove redactDataField function entirely
- Improve handling of YAML with comments and edge cases
- Update test expectation for improved comment handling
- Maintain all existing functionality and test coverage

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@John-Lin
Copy link
Copy Markdown
Author

John-Lin commented Aug 5, 2025

@int128 Hi, Thank you so much for creating and maintaining this GitHub Actions project. it has been incredibly helpful in my workflow and has saved me a lot of time. I really appreciate your work!

I’ve opened this PR to contribute a small improvement that I believe could be useful for others as well. When you have time, I’d be grateful if you could take a look and consider reviewing or merging it.

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