summaryrefslogtreecommitdiff
path: root/cmds/incident
diff options
context:
space:
mode:
author Yi Jin <jinyithu@google.com> 2017-09-05 13:44:22 -0700
committer Yi Jin <jinyithu@google.com> 2017-09-07 10:53:51 -0700
commit0f0471623e91c202fb7381a050cc331572fb439f (patch)
tree6c5b30199c6eea59c9a65743ad4767bc8f761aa7 /cmds/incident
parent99c248feb2d1f863b864bdfd1e3b37af17f18732 (diff)
Implement Pii Stripper Part 3
The incident request args sets privacy spec. Strip action is optimized to run once for each type of spec and ready for flush multiple times. Incident command is updated to take -p option to specify privacy spec. Bug: 64687253 Test: unit tests written, manually run incident command to test as well Change-Id: I6753df117f76dc1a5f4d2152baa3fbbf56b490e4
Diffstat (limited to 'cmds/incident')
-rw-r--r--cmds/incident/main.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/cmds/incident/main.cpp b/cmds/incident/main.cpp
index 47f1db89e1cb..519852dbe88b 100644
--- a/cmds/incident/main.cpp
+++ b/cmds/incident/main.cpp
@@ -25,6 +25,7 @@
#include <binder/IServiceManager.h>
#include <utils/Looper.h>
+#include <cstring>
#include <fcntl.h>
#include <getopt.h>
#include <stdio.h>
@@ -144,6 +145,16 @@ find_section(const char* name)
}
// ================================================================================
+static int
+get_dest(const char* arg)
+{
+ if (strcmp(arg, "LOCAL") == 0) return 0;
+ if (strcmp(arg, "EXPLICIT") == 0) return 1;
+ if (strcmp(arg, "AUTOMATIC") == 0) return 2;
+ return -1; // return the default value
+}
+
+// ================================================================================
static void
usage(FILE* out)
{
@@ -155,6 +166,7 @@ usage(FILE* out)
fprintf(out, " -b (default) print the report to stdout (in proto format)\n");
fprintf(out, " -d send the report into dropbox\n");
fprintf(out, " -l list available sections\n");
+ fprintf(out, " -p privacy spec, LOCAL, EXPLICIT or AUTOMATIC\n");
fprintf(out, "\n");
fprintf(out, " SECTION the field numbers of the incident report fields to include\n");
fprintf(out, "\n");
@@ -166,10 +178,11 @@ main(int argc, char** argv)
Status status;
IncidentReportArgs args;
enum { DEST_DROPBOX, DEST_STDOUT } destination = DEST_STDOUT;
+ int dest = -1; // default
// Parse the args
int opt;
- while ((opt = getopt(argc, argv, "bhdl")) != -1) {
+ while ((opt = getopt(argc, argv, "bhdlp:")) != -1) {
switch (opt) {
case 'h':
usage(stdout);
@@ -183,6 +196,9 @@ main(int argc, char** argv)
case 'd':
destination = DEST_DROPBOX;
break;
+ case 'p':
+ dest = get_dest(optarg);
+ break;
default:
usage(stderr);
return 1;
@@ -210,8 +226,7 @@ main(int argc, char** argv)
}
}
}
-
-
+ args.setDest(dest);
// Start the thread pool.
sp<ProcessState> ps(ProcessState::self());