-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New environment variable obfuscation functionality (#355)
* chore: New environment variable obfuscation functionality Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Update attestation/environment/obfuscate.go Co-authored-by: Kairo Araujo <kairo@kairo.eti.br> Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * feat: Change to default obfuscate and add cli flags. Adding flags to behave blocking or obfuscating and adding new keys. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * chore: Adjust naming to filter envs. Fix tests. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * chore: Making the environment test cases more robust. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * feat: Add exclude-sensitive-key flag. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Update attestation/environment/sensitive_env_vars.go Co-authored-by: Kairo Araujo <kairo@kairo.eti.br> Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * chore: Fix tests and command run. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * chore: Fix linux tracing in commandrun. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Refactor environment. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Add new environment to commandrun Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Add license headers Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Fix lint errors Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * WIP Linux tracing fix Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Update environment/sensitive_env_vars.go Co-authored-by: Tom Meadows <tom@tmlabs.co.uk> Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Add AttestationContextOption for Environment Caputurer. Signed-off-by: Matthias Glastra <matglas.git@gmail.com> * Fix format Signed-off-by: Matthias Glastra <matglas.git@gmail.com> --------- Signed-off-by: Matthias Glastra <matglas.git@gmail.com> Co-authored-by: Kairo Araujo <kairo@kairo.eti.br> Co-authored-by: Tom Meadows <tom@tmlabs.co.uk> Co-authored-by: Cole Kennedy <colek42@gmail.com>
- Loading branch information
1 parent
6756567
commit 4f862d4
Showing
11 changed files
with
579 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2024 The Witness Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package attestation | ||
|
||
import ( | ||
env "github.com/in-toto/go-witness/environment" | ||
) | ||
|
||
func (ctx *AttestationContext) EnvironmentCapturer() *env.Capture { | ||
return ctx.environmentCapturer | ||
} | ||
|
||
// WithEnvFilterVarsEnabled will make the filter (removing) of vars the acting behavior. | ||
// The default behavior is obfuscation of variables. | ||
func WithEnvFilterVarsEnabled() AttestationContextOption { | ||
return func(a *AttestationContext) { | ||
env.WithFilterVarsEnabled()(a.environmentCapturer) | ||
} | ||
} | ||
|
||
// WithEnvAdditionalKeys add additional keys to final list that is checked for sensitive variables. | ||
func WithEnvAdditionalKeys(additionalKeys []string) AttestationContextOption { | ||
return func(a *AttestationContext) { | ||
env.WithAdditionalKeys(additionalKeys)(a.environmentCapturer) | ||
} | ||
} | ||
|
||
// WithEnvExcludeKeys add additional keys to final list that is checked for sensitive variables. | ||
func WithEnvExcludeKeys(excludeKeys []string) AttestationContextOption { | ||
return func(a *AttestationContext) { | ||
env.WithExcludeKeys(excludeKeys)(a.environmentCapturer) | ||
} | ||
} | ||
|
||
// WithEnvDisableDefaultSensitiveList will disable the default list and only use the additional keys. | ||
func WithEnvDisableDefaultSensitiveList() AttestationContextOption { | ||
return func(a *AttestationContext) { | ||
env.WithDisableDefaultSensitiveList()(a.environmentCapturer) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.