Apply redactions to snapshot metadata #813
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements consistent redaction behavior for both snapshot content and metadata, addressing a long-standing inconsistency where
Settings.add_redaction()worked for snapshot content but not for metadata set viaSettings.set_info().Problem
Previously, redactions were only applied to snapshot content during serialization, not to metadata. This created surprising behavior for users of libraries like
insta-cmdthat capture sensitive data (API keys, credentials, etc.) in snapshot metadata.Before this change:
After this change:
Implementation
Core Changes
Created shared redaction helper (
Redactions::apply_to_content())Modified
ActualSettings::info()to apply redactions to metadataUpdated documentation
set_info(): Documents that redactions are automatically appliedset_raw_info(): Documents that it does NOT apply redactions (low-level API)Test Coverage
Added two tests documenting the behavior:
test_metadata_redaction: Validatesset_info()applies redactionstest_metadata_raw_info_no_redaction: Validatesset_raw_info()does notSnapshots clearly show the difference:
Benefits
add_redaction()now applies to all serialized dataBreaking Changes
Low impact: Existing snapshots with sensitive data in metadata will change (values will become redacted). This is the intended behavior and improves security.
Migration: Users can either:
set_raw_info()for the low-level API that bypasses redactionsTesting
Related
Addresses the use case described in the proposal where libraries like
insta-cmdneed to redact environment variables captured in metadata.🤖 Generated with Claude Code