#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/feedback/redaction_tool/redaction_tool.h"
#include <algorithm>
#include <set>
#include <string_view>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "build/chromeos_buildflags.h"
#include "components/autofill/core/common/credit_card_number_validation.h"
#include "components/feedback/redaction_tool/ip_address.h"
#include "components/feedback/redaction_tool/pii_types.h"
#ifdef USE_SYSTEM_RE2
#include <re2/re2.h>
#else
#include "third_party/re2/src/re2/re2.h"
#endif
RE2;
IPAddress;
namespace redaction {
namespace features {
COMPONENT_EXPORT(REDACTION_TOOL)
BASE_FEATURE(kEnableCreditCardRedaction,
"EnableCreditCardRedaction",
base::FEATURE_ENABLED_BY_DEFAULT);
COMPONENT_EXPORT(REDACTION_TOOL)
BASE_FEATURE(kEnableIbanRedaction,
"EnableIbanRedaction",
base::FEATURE_ENABLED_BY_DEFAULT);
}
namespace {
CustomPatternWithAlias kCustomPatternsWithContext[] = …;
bool MaybeUnmapAddress(IPAddress* addr) { … }
bool MaybeUntranslateAddress(IPAddress* addr) { … }
bool MaybeTruncateIPv6(IPAddress* addr) { … }
std::string MaybeScrubIPAddress(const std::string& addr) { … }
bool ShouldSkipIPAddress(std::string_view skipped) { … }
#define NCG(x) …
#define OPT_NCG(x) …
#define UNRESERVED …
#define RESERVED …
#define SUB_DELIMS …
#define GEN_DELIMS …
#define DIGIT …
#define HEXDIG …
#define PCT_ENCODED …
#define DEC_OCTET …
#define IPV4ADDRESS …
#define H16 …
#define LS32 …
#define WB …
#define IPV6ADDRESS …
#define IPVFUTURE …
#define IP_LITERAL …
#define PORT …
#define SCHEME …
#define IPRIVATE …
#define UCSCHAR …
#define IUNRESERVED …
#define IPCHAR …
#define IFRAGMENT …
#define IQUERY …
#define ISEGMENT …
#define ISEGMENT_NZ …
#define ISEGMENT_NZ_NC …
#define IPATH_EMPTY …
#define IPATH_ROOTLESS …
#define IPATH_NOSCHEME …
#define IPATH_ABSOLUTE …
#define IPATH_ABEMPTY …
#define IPATH …
#define IREG_NAME …
#define IHOST …
#define IUSERINFO …
#define IAUTHORITY …
#define IRELATIVE_PART …
#define IRELATIVE_REF …
#define IHIER_PART …
#define ABSOLUTE_IRI …
#define IRI …
#define IRI_REFERENCE …
CustomPatternWithAlias kCustomPatternsWithoutContext[] = …;
bool FindAndConsumeAndGetSkippedN(std::string_view* input,
const re2::RE2& pattern,
std::string_view* skipped_input,
std::string_view* args[],
int argc) { … }
template <typename... Arg>
bool FindAndConsumeAndGetSkipped(std::string_view* input,
const re2::RE2& pattern,
std::string_view* skipped_input,
Arg*... match_groups) { … }
bool HasRepeatedChar(std::string_view text, char c) { … }
const char* const kUnredactedMacAddresses[] = …;
constexpr size_t kNumUnredactedMacs = …;
bool IsFeatureEnabled(const base::Feature& feature) { … }
}
RedactionTool::RedactionTool(const char* const* first_party_extension_ids)
: … { … }
RedactionTool::RedactionTool(
const char* const* first_party_extension_ids,
std::unique_ptr<RedactionToolMetricsRecorder> metrics_recorder)
: … { … }
RedactionTool::~RedactionTool() { … }
std::map<PIIType, std::set<std::string>> RedactionTool::Detect(
const std::string& input) { … }
std::string RedactionTool::Redact(const std::string& input,
const base::Location& location) { … }
std::string RedactionTool::RedactAndKeepSelected(
const std::string& input,
const std::set<PIIType>& pii_types_to_keep,
const base::Location& location) { … }
void RedactionTool::EnableCreditCardRedaction(const bool enabled) { … }
RE2* RedactionTool::GetRegExp(const std::string& pattern) { … }
std::string RedactionTool::RedactMACAddresses(
const std::string& input,
std::map<PIIType, std::set<std::string>>* detected) { … }
std::string RedactionTool::RedactHashes(
const std::string& input,
std::map<PIIType, std::set<std::string>>* detected) { … }
std::string RedactionTool::RedactAndroidAppStoragePaths(
const std::string& input,
std::map<PIIType, std::set<std::string>>* detected) { … }
std::string RedactionTool::RedactCreditCardNumbers(
const std::string& input,
std::map<PIIType, std::set<std::string>>* detected) { … }
std::string RedactionTool::RedactIbans(
const std::string& input,
std::map<PIIType, std::set<std::string>>* detected) { … }
std::string RedactionTool::RedactAndKeepSelectedCustomPatterns(
std::string input,
const std::set<PIIType>& pii_types_to_keep) { … }
void RedactionTool::DetectWithCustomPatterns(
std::string input,
std::map<PIIType, std::set<std::string>>* detected) { … }
RedactionToolCaller RedactionTool::GetCaller(const base::Location& location) { … }
std::string RedactionTool::RedactCustomPatternWithContext(
const std::string& input,
const CustomPatternWithAlias& pattern,
std::map<PIIType, std::set<std::string>>* detected) { … }
bool IsUrlExempt(std::string_view url,
const char* const* first_party_extension_ids) { … }
std::string RedactionTool::RedactCustomPatternWithoutContext(
const std::string& input,
const CustomPatternWithAlias& pattern,
std::map<PIIType, std::set<std::string>>* detected) { … }
RedactionToolContainer::RedactionToolContainer(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const char* const* first_party_extension_ids)
: … { … }
RedactionToolContainer::RedactionToolContainer(
scoped_refptr<base::SequencedTaskRunner> task_runner,
const char* const* first_party_extension_ids,
std::unique_ptr<RedactionToolMetricsRecorder> metrics_recorder)
: … { … }
RedactionToolContainer::~RedactionToolContainer() { … }
RedactionTool* RedactionToolContainer::Get() { … }
}