#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "services/tracing/perfetto/privacy_filtering_check.h"
#include <string.h>
#include <sstream>
#include "base/check.h"
#include "base/check_op.h"
#include "base/logging.h"
#include "services/tracing/perfetto/privacy_filtered_fields-inl.h"
#include "third_party/perfetto/include/perfetto/protozero/proto_utils.h"
#include "third_party/perfetto/protos/perfetto/trace/interned_data/interned_data.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/trace.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/trace_packet.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/track_descriptor.pbzero.h"
#include "third_party/perfetto/protos/perfetto/trace/track_event/track_event.pbzero.h"
namespace tracing {
namespace {
InternedData;
TracePacket;
TrackDescriptor;
TrackEvent;
ProtoDecoder;
int FindIndexOfValue(const int* const arr, uint32_t value) { … }
#if DCHECK_IS_ON()
void LogDisallowedField(std::vector<uint32_t>* parent_ids, uint32_t field_id) { … }
#endif
uint8_t* OffsetToPtr(size_t offset, std::string& str) { … }
bool FilterProtoRecursively(const MessageInfo* root,
ProtoDecoder* proto,
std::vector<uint32_t>* parent_ids,
std::string& output) { … }
bool FilterProto(const std::string& serialized_trace_proto,
std::string& output) { … }
}
PrivacyFilteringCheck::PrivacyFilteringCheck() = default;
PrivacyFilteringCheck::~PrivacyFilteringCheck() = default;
void PrivacyFilteringCheck::RemoveBlockedFields(
std::string& serialized_trace_proto) { … }
void PrivacyFilteringCheck::CheckProtoForUnexpectedFields(
const std::string& serialized_trace_proto) { … }
}