Skip to content

Commit 4bcdb6c

Browse files
committed
[BACKPORT 2024.1][PLAT-14788]mask SAS token in backup config response and logs
Summary: Original commit: 920989b/D37715 Redact SAS token in backup response and v1 backup logs. SAS token is basically a bunch of query params, eg `sp=racwdli&st=2024-09-02T08:35:05Z&se=2024-12-31T16:35:05Z&sv=2022-11-02&sr=c&sig=****`. In v1 backups we are logging this token without redacting the sig. Test Plan: Manually reproduced the issue by taking v1 backups on a universe. verfied the sig is redacted after my changes. Also verified that the SAS token is masked on backup config UI. Reviewers: #yba-api-review!, vkumar, amalyshev, svarshney Reviewed By: svarshney Subscribers: yugaware Differential Revision: https://phorge.dev.yugabyte.com/D37729
1 parent 1976b9a commit 4bcdb6c

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

managed/src/main/java/com/yugabyte/yw/common/RedactingService.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public class RedactingService {
2929
"$..ysqlCurrentPassword",
3030
"$..sshPrivateKeyContent");
3131

32+
public static final List<String> SECRET_QUERY_PARAMS_FOR_LOGS =
33+
ImmutableList.of(/* SAS Token */ "sig");
34+
3235
public static final List<String> SECRET_PATHS_FOR_LOGS =
3336
ImmutableList.<String>builder()
3437
.addAll(SECRET_PATHS_FOR_APIS)
@@ -131,6 +134,16 @@ public static String redactString(String input) {
131134
return output;
132135
}
133136

137+
public static String redactQueryParams(String input) {
138+
String output = input;
139+
for (String param : SECRET_QUERY_PARAMS_FOR_LOGS) {
140+
String regex = "([?&]" + param + "=)([^&]+)";
141+
String replacement = "$1" + SECRET_REPLACEMENT;
142+
output = output.replaceAll(regex, replacement);
143+
}
144+
return output;
145+
}
146+
134147
public enum RedactionTarget {
135148
LOGS,
136149
APIS;

managed/src/main/java/com/yugabyte/yw/common/ShellProcessHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ private String getOutputLines(BufferedReader reader, boolean logOutput) {
275275
.peek(
276276
line -> {
277277
if (logOutput) {
278-
log.debug(fileMarker, line);
278+
log.debug(fileMarker, RedactingService.redactQueryParams(line));
279279
}
280280
})
281281
.collect(Collectors.joining("\n"))
282282
.trim();
283283
if (logOutput && cloudLoggingEnabled && lines.length() > 0) {
284-
log.debug(consoleMarker, lines);
284+
log.debug(consoleMarker, RedactingService.redactQueryParams(lines));
285285
}
286286
return lines;
287287
}

managed/src/main/java/com/yugabyte/yw/models/helpers/CommonUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,14 @@ public class CommonUtils {
8484
// Sensisitve field substrings
8585
private static final List<String> sensitiveFieldSubstrings =
8686
Arrays.asList(
87-
"KEY", "SECRET", "CREDENTIALS", "API", "POLICY", "HC_VAULT_TOKEN", "vaultToken");
87+
"KEY",
88+
"SECRET",
89+
"CREDENTIALS",
90+
"API",
91+
"POLICY",
92+
"HC_VAULT_TOKEN",
93+
"vaultToken",
94+
"SAS_TOKEN");
8895
// Exclude following strings from being sensitive fields
8996
private static final List<String> excludedFieldNames =
9097
Arrays.asList(

0 commit comments

Comments
 (0)