summaryrefslogtreecommitdiff
path: root/cmds/incident_helper
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-08-25 18:11:58 -0700
committerYi Jin <jinyithu@google.com>2017-09-07 10:53:51 -0700
commit99c248feb2d1f863b864bdfd1e3b37af17f18732 (patch)
tree0b40559c26c16821354db6818cef59b15ed472f0 /cmds/incident_helper
parent10c41c2727aa5566ff6aed0c4709657c6517c855 (diff)
Implement PII Stripper, part 2
Implement EncodedBuffer that strip pii based on given privacy request. The reason to implement another buffer is the length-delimited field's size could change when its submessage gets stripped. It also intends to keep the orignal data around for other requests to consume it. In addition, the section implementation has adapted EncodedBuffer so write out to each request's fd could be request-specific. The next step is allow requests to set its privacy spec. Notice the current design set the privacy spec of dropbox to AUTOMATIC, this behavior might change in the future. Bug: 64687253 Test: unit tests are writtern, see README.md for how to run unit tests. Change-Id: I7ac236b8265ba9289dc6e17a8a5bf7f67ffb6bf5
Diffstat (limited to 'cmds/incident_helper')
-rw-r--r--cmds/incident_helper/IncidentHelper.cpp17
-rw-r--r--cmds/incident_helper/IncidentHelper.h11
-rw-r--r--cmds/incident_helper/main.cpp4
3 files changed, 30 insertions, 2 deletions
diff --git a/cmds/incident_helper/IncidentHelper.cpp b/cmds/incident_helper/IncidentHelper.cpp
index fba5e662b7c1..787d3a1557d6 100644
--- a/cmds/incident_helper/IncidentHelper.cpp
+++ b/cmds/incident_helper/IncidentHelper.cpp
@@ -61,6 +61,21 @@ SetTableField(::google::protobuf::Message* message, string field_name, string fi
}
// ================================================================================
+status_t NoopParser::Parse(const int in, const int out) const
+{
+ string content;
+ if (!ReadFdToString(in, &content)) {
+ fprintf(stderr, "[%s]Failed to read data from incidentd\n", this->name.string());
+ return -1;
+ }
+ if (!WriteStringToFd(content, out)) {
+ fprintf(stderr, "[%s]Failed to write data to incidentd\n", this->name.string());
+ return -1;
+ }
+ return NO_ERROR;
+}
+
+// ================================================================================
status_t ReverseParser::Parse(const int in, const int out) const
{
string content;
@@ -189,4 +204,4 @@ status_t ProcrankParser::Parse(const int in, const int out) const {
}
fprintf(stderr, "[%s]Proto size: %d bytes\n", this->name.string(), proto.ByteSize());
return NO_ERROR;
-} \ No newline at end of file
+}
diff --git a/cmds/incident_helper/IncidentHelper.h b/cmds/incident_helper/IncidentHelper.h
index f319c419fcd6..f6579a2d3736 100644
--- a/cmds/incident_helper/IncidentHelper.h
+++ b/cmds/incident_helper/IncidentHelper.h
@@ -36,6 +36,17 @@ public:
};
/**
+ * No op parser returns what it reads
+ */
+class NoopParser : public TextParserBase {
+public:
+ NoopParser() : TextParserBase(String8("NoopParser")) {};
+ ~NoopParser() {};
+
+ virtual status_t Parse(const int in, const int out) const;
+};
+
+/**
* This parser is used for testing only, results in timeout.
*/
class TimeoutParser : public TextParserBase {
diff --git a/cmds/incident_helper/main.cpp b/cmds/incident_helper/main.cpp
index 333344b8ce86..296d3001b7bb 100644
--- a/cmds/incident_helper/main.cpp
+++ b/cmds/incident_helper/main.cpp
@@ -41,9 +41,11 @@ static TextParserBase* selectParser(int section) {
case -1:
return new TimeoutParser();
case 0:
+ return new NoopParser();
+ case 1: // 1 is reserved for incident header so it won't be section id
return new ReverseParser();
/* ========================================================================= */
- // IDs larger than 0 are reserved in incident.proto
+ // IDs larger than 1 are section ids reserved in incident.proto
case 2000:
return new ProcrankParser();
case 2002: