Skip to content

Commit

Permalink
PII filtering: Correctly handle secondary lines that were not analyzed
Browse files Browse the repository at this point in the history
In some edge cases, for example unknown CONTEXT patterns, we may not
detect the contents of a secondary line. If filtering of unidentified
content is enabled, such lines need to be redacted.
  • Loading branch information
lfittl committed Jan 7, 2025
1 parent e8b078c commit 440484c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion logs/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ReplaceSecrets(logLines []state.LogLine, filterLogSecret []state.LogSecretK
}
}
for idx, logLine := range logLines {
if filterUnidentified && logLines[idx].Classification == 0 && logLines[idx].ParentUUID == uuid.Nil {
if filterUnidentified && (!logLine.ReviewedForSecrets || (logLine.Classification == 0 && logLines[idx].ParentUUID == uuid.Nil)) {
logLines[idx].Content = replacement + "\n"
} else {
sort.Slice(logLine.SecretMarkers, func(i, j int) bool {
Expand Down
5 changes: 5 additions & 0 deletions logs/replace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ var replaceTests = []replaceTestpair{
input: "2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:ERROR: division by zero\n2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:ERROR: Unknown Data\n",
output: "division by zero\n[redacted]\n",
},
{
filterLogSecret: "statement_parameter, unidentified",
input: "2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:LOG: duration: 2007.111 ms plan:\n{\"Query Text\": \"SELECT * FROM x WHERE y = $1 LIMIT $2\", \"Plan\": { } }\n2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:CONTEXT: some new context we do not know with a secret\n",
output: "duration: 2007.111 ms plan:\n{\"Query Text\": \"SELECT * FROM x WHERE y = $1 LIMIT $2\", \"Plan\": { } }\n[redacted]\n",
},
{
filterLogSecret: "statement_text, statement_parameter, unidentified",
input: "2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:LOG: duration: 4079.697 ms execute <unnamed>: \nSELECT * FROM x WHERE y = $1 LIMIT $2\n2018-03-11 20:00:02 UTC:1.1.1.1(2):a@b:[3]:DETAIL: parameters: $1 = 'long string', $2 = '1'\n",
Expand Down

0 comments on commit 440484c

Please sign in to comment.