release the sensitive-info flag (#3369)

Not 100% happy with the flag name, and am open to suggestions.

---

#### Does this PR need a docs update or release note?

- [x]  Yes, it's included

#### Type of change

- [x] 🌻 Feature
- [x] 🗺️ Documentation

#### Test Plan

- [x] 💪 Manual
- [x]  Unit test
This commit is contained in:
Keepers 2023-05-10 22:35:53 -06:00 committed by GitHub
parent 3be3b72d0a
commit f2f76d932d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 25 deletions

View File

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] (beta) ## [Unreleased] (beta)
### Added ### Added
- Released the --mask-sensitive-data flag, which will automatically obscure private data in logs.
### Fixed ### Fixed
- Graph requests now automatically retry in case of a Bad Gateway or Gateway Timeout. - Graph requests now automatically retry in case of a Bad Gateway or Gateway Timeout.

View File

@ -34,20 +34,20 @@ const (
// flag names // flag names
const ( const (
DebugAPIFN = "debug-api-calls" DebugAPIFN = "debug-api-calls"
LogFileFN = "log-file" LogFileFN = "log-file"
LogLevelFN = "log-level" LogLevelFN = "log-level"
ReadableLogsFN = "readable-logs" ReadableLogsFN = "readable-logs"
SensitiveInfoFN = "sensitive-info" MaskSensitiveDataFN = "mask-sensitive-data"
) )
// flag values // flag values
var ( var (
DebugAPIFV bool DebugAPIFV bool
logFileFV = "" logFileFV = ""
LogLevelFV = "info" LogLevelFV = "info"
ReadableLogsFV bool ReadableLogsFV bool
SensitiveInfoFV = PIIPlainText MaskSensitiveDataFV bool
LogFile string // logFileFV after processing LogFile string // logFileFV after processing
) )
@ -83,9 +83,6 @@ func AddLoggingFlags(cmd *cobra.Command) {
//nolint:errcheck //nolint:errcheck
fs.MarkHidden(ReadableLogsFN) fs.MarkHidden(ReadableLogsFN)
// TODO(keepers): unhide when we have sufficient/complete coverage of PII handling
//nolint:errcheck
fs.MarkHidden(SensitiveInfoFN)
} }
// internal deduplication for adding flags // internal deduplication for adding flags
@ -106,11 +103,11 @@ func addFlags(fs *pflag.FlagSet, defaultFile string) {
false, false,
"minimizes log output for console readability: removes the file and date, colors the level") "minimizes log output for console readability: removes the file and date, colors the level")
fs.StringVar( fs.BoolVar(
&SensitiveInfoFV, &MaskSensitiveDataFV,
SensitiveInfoFN, MaskSensitiveDataFN,
PIIPlainText, false,
fmt.Sprintf("set the format for sensitive info in logs to %s|%s|%s", PIIHash, PIIMask, PIIPlainText)) "anonymize personal data in log output")
} }
// Settings records the user's preferred logging settings. // Settings records the user's preferred logging settings.
@ -136,7 +133,7 @@ func PreloadLoggingFlags(args []string) Settings {
ls := Settings{ ls := Settings{
File: "", File: "",
Level: LogLevelFV, Level: LogLevelFV,
PIIHandling: SensitiveInfoFV, PIIHandling: PIIPlainText,
} }
// parse the os args list to find the log level flag // parse the os args list to find the log level flag
@ -144,6 +141,10 @@ func PreloadLoggingFlags(args []string) Settings {
return ls return ls
} }
if MaskSensitiveDataFV {
ls.PIIHandling = PIIHash
}
// retrieve the user's preferred log level // retrieve the user's preferred log level
// automatically defaults to "info" // automatically defaults to "info"
levelString, err := fs.GetString(LogLevelFN) levelString, err := fs.GetString(LogLevelFN)
@ -165,7 +166,7 @@ func PreloadLoggingFlags(args []string) Settings {
// retrieve the user's preferred PII handling algorithm // retrieve the user's preferred PII handling algorithm
// automatically defaults to default log location // automatically defaults to default log location
pii, err := fs.GetString(SensitiveInfoFN) pii, err := fs.GetString(MaskSensitiveDataFN)
if err != nil { if err != nil {
return ls return ls
} }

View File

@ -33,7 +33,7 @@ func (suite *LoggerUnitSuite) TestAddLoggingFlags() {
assert.True(t, logger.DebugAPIFV, logger.DebugAPIFN) assert.True(t, logger.DebugAPIFV, logger.DebugAPIFN)
assert.True(t, logger.ReadableLogsFV, logger.ReadableLogsFN) assert.True(t, logger.ReadableLogsFV, logger.ReadableLogsFN)
assert.Equal(t, logger.LLError, logger.LogLevelFV, logger.LogLevelFN) assert.Equal(t, logger.LLError, logger.LogLevelFV, logger.LogLevelFN)
assert.Equal(t, logger.PIIMask, logger.SensitiveInfoFV, logger.SensitiveInfoFN) assert.True(t, logger.MaskSensitiveDataFV, logger.MaskSensitiveDataFN)
// empty assertion here, instead of matching "log-file", because the LogFile // empty assertion here, instead of matching "log-file", because the LogFile
// var isn't updated by running the command (this is expected and correct), // var isn't updated by running the command (this is expected and correct),
// while the logFileFV remains unexported. // while the logFileFV remains unexported.
@ -50,7 +50,7 @@ func (suite *LoggerUnitSuite) TestAddLoggingFlags() {
"--" + logger.LogFileFN, "log-file", "--" + logger.LogFileFN, "log-file",
"--" + logger.LogLevelFN, logger.LLError, "--" + logger.LogLevelFN, logger.LLError,
"--" + logger.ReadableLogsFN, "--" + logger.ReadableLogsFN,
"--" + logger.SensitiveInfoFN, logger.PIIMask, "--" + logger.MaskSensitiveDataFN,
}) })
err := cmd.Execute() err := cmd.Execute()
@ -68,7 +68,7 @@ func (suite *LoggerUnitSuite) TestPreloadLoggingFlags() {
"--" + logger.LogFileFN, "log-file", "--" + logger.LogFileFN, "log-file",
"--" + logger.LogLevelFN, logger.LLError, "--" + logger.LogLevelFN, logger.LLError,
"--" + logger.ReadableLogsFN, "--" + logger.ReadableLogsFN,
"--" + logger.SensitiveInfoFN, logger.PIIMask, "--" + logger.MaskSensitiveDataFN,
} }
settings := logger.PreloadLoggingFlags(args) settings := logger.PreloadLoggingFlags(args)
@ -77,5 +77,5 @@ func (suite *LoggerUnitSuite) TestPreloadLoggingFlags() {
assert.True(t, logger.ReadableLogsFV, logger.ReadableLogsFN) assert.True(t, logger.ReadableLogsFV, logger.ReadableLogsFN)
assert.Equal(t, "log-file", settings.File, "settings.File") assert.Equal(t, "log-file", settings.File, "settings.File")
assert.Equal(t, logger.LLError, settings.Level, "settings.Level") assert.Equal(t, logger.LLError, settings.Level, "settings.Level")
assert.Equal(t, logger.PIIMask, settings.PIIHandling, "settings.PIIHandling") assert.Equal(t, logger.PIIHash, settings.PIIHandling, "settings.PIIHandling")
} }

View File

@ -132,7 +132,13 @@ directory within the container.
Corso generates a unique log file named with its timestamp for every invocation. Corso generates a unique log file named with its timestamp for every invocation.
The default location of Corso's log file is shown below but the location can be overridden by using the `--log-file` flag. The default location of Corso's log file is shown below but the location can be overridden by using the `--log-file` flag.
The log file will be appended to if multiple Corso invocations are pointed to the same file. The log file will be appended to if multiple Corso invocations are pointed to the same file.
You can also use `stdout` or `stderr` as the `--log-file` location to redirect the logs to "stdout" and "stderr" respectively. You can also use `stdout` or `stderr` as the `--log-file` location to redirect the logs to "stdout" and "stderr" respectively.
This setting can cause logs to compete with progress bar displays in the terminal.
We suggest using the `--hide-progress` option if you plan to log to stdout or stderr.
Log entries, by default, include user names and file names. The `--mask-sensitive-data` option can be
used to replace this information with anonymized hashes.
<Tabs groupId="os"> <Tabs groupId="os">
<TabItem value="win" label="Windows"> <TabItem value="win" label="Windows">

View File

@ -55,3 +55,4 @@ Malbrough
lockdowns lockdowns
exfiltrate exfiltrate
deduplicating deduplicating
anonymized