Skip to content

Commit a9dc595

Browse files
Googlercopybara-github
Googler
authored andcommitted
LSC: Refactor Protobuf Message.toString calls that blocks[]
[] Background: Protobuf Message.toString() currently serializes all the fields in a proto into a human-readable representation, which has led to many privacy incidents where Message.toString() outputs containing sensitive fields (e.g. private keys) were accidentally logged. To prevent such privacy incidents, while minimizing reliability risks, we (orrery-debug-string@) are in the process of changing Protobuf Message.toString()’s output format in stages:[] PiperOrigin-RevId: 759759246 Change-Id: I4f36ad4fc23a4b805ab270d028f93eacbf0bf389
1 parent dd3991d commit a9dc595

File tree

2 files changed

+6
-2
lines changed
  • src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps

2 files changed

+6
-2
lines changed

src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,5 +329,8 @@ sh_test(
329329
java_binary(
330330
name = "DumpProto",
331331
srcs = ["DumpProto.java"],
332-
deps = ["//src/main/protobuf:deps_java_proto"],
332+
deps = [
333+
"//src/main/protobuf:deps_java_proto",
334+
"@com_google_protobuf//:protobuf_java",
335+
],
333336
)

src/java_tools/import_deps_checker/javatests/com/google/devtools/build/importdeps/DumpProto.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.devtools.build.importdeps;
1616

1717
import com.google.devtools.build.lib.view.proto.Deps.Dependencies;
18+
import com.google.protobuf.TextFormat;
1819
import java.io.BufferedInputStream;
1920
import java.nio.file.Files;
2021
import java.nio.file.Paths;
@@ -24,7 +25,7 @@ public class DumpProto {
2425
public static void main(String[] args) throws Exception {
2526
try (BufferedInputStream bis =
2627
new BufferedInputStream(Files.newInputStream(Paths.get(args[0])))) {
27-
System.out.print(Dependencies.parseFrom(bis));
28+
System.out.print(TextFormat.printer().printToString(Dependencies.parseFrom(bis)));
2829
}
2930
}
3031
}

0 commit comments

Comments
 (0)