Documentation
¶
Index ¶
- Constants
- func Exec(runner Runner, opts ...ExecOption) error
- func WrapTokens(c *UnredactTokensConfig)
- type CompositeTokenRedacter
- type CompositeTokenUnredacter
- type ExecConfig
- type ExecOption
- type NewToolConfig
- type NewToolOption
- type OnEnvChangeBehavior
- type Redacter
- type RegexTokenLocator
- type Runner
- type StringWrapper
- type TokenLocator
- type TokenRedacter
- type TokenRedacterUnredacter
- type TokenUnredacter
- type TokenWrapper
- type Tool
- type UnredactTokensConfig
- type UnredactTokensOption
- type Unredacter
Constants ¶
const ( DoNothing = OnEnvChangeBehavior(iota) // default: do nothing Stop Restart )
Available OnEnvChangeBehaviors
Variables ¶
This section is empty.
Functions ¶
func Exec ¶ added in v0.2.0
func Exec(runner Runner, opts ...ExecOption) error
Exec runs the Runner.
When called with the RestartIfEnvChanges or StopIfEnvChanges option, Exec will periodically re-evaluate the environment. If the environment has changed, Exec will restart or stop the runner as requested.
func WrapTokens ¶
func WrapTokens(c *UnredactTokensConfig)
WrapTokens requests that unredacted secrets be wrapped in secret envelopes (ideally in the format understood by the corresponding redacter)
For example, a secret unredacter might try to unredact the token:
secret-redacted:zzz:secret-redacted
Assuming "zzz" is an redacted version of "hunter2", then a regular, unwrapped output would be:
hunter2
With the WrapTokens option, the output should become:
secret:hunter2:secret
This is helpful when a user wants to see a reversible output, such as when users want to rotate secrets or keys.
Types ¶
type CompositeTokenRedacter ¶ added in v0.2.0
type CompositeTokenRedacter struct { Redacter Redacter Locator TokenLocator Wrapper TokenWrapper }
A CompositeTokenRedacter looks for secret tokens within text, and redacts them
func (*CompositeTokenRedacter) RedactTokens ¶ added in v0.2.0
func (e *CompositeTokenRedacter) RedactTokens(s string) (string, error)
RedactTokens looks for secret tokens within text, and redacts them
type CompositeTokenUnredacter ¶ added in v0.2.0
type CompositeTokenUnredacter struct { Unredacter Unredacter Locator TokenLocator Wrapper TokenWrapper }
A CompositeTokenUnredacter looks for redacted secret tokens within text, and unredacts them
func (*CompositeTokenUnredacter) UnredactTokens ¶ added in v0.2.0
func (d *CompositeTokenUnredacter) UnredactTokens(s string, opts ...UnredactTokensOption) (string, error)
UnredactTokens looks for redacted secret tokens within text, and unredacts them
type ExecConfig ¶ added in v0.2.0
type ExecConfig struct {
// contains filtered or unexported fields
}
ExecConfig is used to configure a call to Exec()
type ExecOption ¶ added in v0.2.0
type ExecOption func(*ExecConfig)
An ExecOption changes the way that Exec behaves
func RestartIfEnvChanges ¶ added in v0.2.0
func RestartIfEnvChanges(d time.Duration) ExecOption
RestartIfEnvChanges tells Exec to periodically re-check the configuration of the running command. If it changes, Exec will restart the command.
func StopIfEnvChanges ¶ added in v0.2.0
func StopIfEnvChanges(d time.Duration) ExecOption
StopIfEnvChanges tells Exec to periodically re-check the configuration of the running command. If it changes, Exec will stop the command.
type NewToolConfig ¶
type NewToolConfig struct {
// contains filtered or unexported fields
}
NewToolConfig is used to configure a Tool created by New()
type NewToolOption ¶
type NewToolOption func(*NewToolConfig)
NewToolOption configures a Tool on a call to New()
func AESKey ¶
func AESKey(key string) NewToolOption
AESKey sets the key used for AES encryption and decryption
type OnEnvChangeBehavior ¶ added in v0.2.0
type OnEnvChangeBehavior int8
OnEnvChangeBehavior determines the behavior of the Tool if it discovers that the environment has changed
type RegexTokenLocator ¶
A RegexTokenLocator locates tokens according to a regular expression (RE).
The regex should match a token envelope, and it should have one capturing group which captures the token payload. If the payload is the same as the envelope, the entire regex should be a capturing group.
func (*RegexTokenLocator) LocateTokens ¶
func (l *RegexTokenLocator) LocateTokens(s string) ([]struct{ EnvelopeStart, PayloadStart, PayloadEnd, EnvelopeEnd int }, error)
LocateTokens locates all tokens according to the embedded regular expression
type Runner ¶ added in v0.2.0
type Runner interface { // Run runs the command. The runner should replace // relevant values with the Replacer. For example, // a command-line runner may replace values in // the environment. Run() error // HasConfigurationChanged should re-evaluate any // dynamic configuration, and return true if that // configuration differs from the configuration // that was used to Run(). // // If the Runner is not running, it should // return false. HasConfigurationChanged() (bool, error) // Restart should restart the running runner. Restart() // Stop should stop the running Runner // Stop() }
A Runner runs.
type StringWrapper ¶
type StringWrapper struct {
Before, After string
}
StringWrapper wraps tokens by putting strings before and after each token
func (*StringWrapper) WrapToken ¶
func (w *StringWrapper) WrapToken(token, originalPayload, originalEnvelope string) string
WrapToken wraps the string with Before and After
type TokenLocator ¶
type TokenLocator interface {
LocateTokens(string) ([]struct{ EnvelopeStart, PayloadStart, PayloadEnd, EnvelopeEnd int }, error)
}
A TokenLocator locates tokens
Each token location is described by four indices, representing the start and end of the token (the envelope), and the start and end of the the token's payload.
type TokenRedacter ¶
type TokenRedacterUnredacter ¶
type TokenRedacterUnredacter interface { TokenRedacter TokenUnredacter }
A TokenRedacterUnredacter can redact and unredact tokens
type TokenUnredacter ¶
type TokenUnredacter interface {
UnredactTokens(string, ...UnredactTokensOption) (string, error)
}
type TokenWrapper ¶
A TokenWrapper wraps tokens
type Tool ¶
type Tool struct { SecretUnredacter TokenUnredacter VaultUnredacter TokenUnredacter SecretRedacter TokenRedacter VaultRedacter TokenRedacter }
A Tool can be used to redact and unredact secrets. If you want to use redactr as a library, you probably want to create and use a Tool.
func (*Tool) Exec ¶ added in v0.2.0
func (t *Tool) Exec(name string, args []string, opts ...ExecOption) error
Exec executes a command. It acts like os.Exec, but with a couple of features that are helpful when working with redacted secrets:
Before running the command, redacted secrets in the environment will be unredacted.
When called with the RestartIfEnvChanges or StopIfEnvChanges option, Exec will periodically re-evaluate the environment. If the environment has changed, Exec will restart or stop the command as requested.
func (*Tool) RedactTokens ¶
RedactTokens redacts all tokens in a string
func (*Tool) UnredactTokens ¶
func (t *Tool) UnredactTokens(s string, opts ...UnredactTokensOption) (string, error)
UnredactTokens unredacts all tokens in a string
type UnredactTokensConfig ¶
type UnredactTokensConfig struct {
// contains filtered or unexported fields
}
A UnredactTokensConfig configures a request to unredact tokens.
type UnredactTokensOption ¶
type UnredactTokensOption func(*UnredactTokensConfig)
A UnredactTokensOption configures a request to unredact tokens.
type Unredacter ¶
An Unredacter unredacts secrets
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package aes provides wrappers for AES-GCM encryption and decryption.
|
Package aes provides wrappers for AES-GCM encryption and decryption. |
fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
cmd
|
|
fakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
Code generated by counterfeiter.
|
Code generated by counterfeiter. |