/* * Copyright (C) 2023 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "src/protozero/filtering/string_filter.h" #include <cstring> #include <regex> #include <string_view> #include "perfetto/base/compiler.h" #include "perfetto/base/logging.h" #include "perfetto/ext/base/string_view.h" #include "perfetto/public/compiler.h" namespace protozero { namespace { Matches; static constexpr std::string_view kRedacted = …; static constexpr char kRedactedDash = …; // Returns a pointer to the first character after the tgid pipe character in // the atrace string given by [ptr, end). Returns null if no such character // exists. // // Examples: // E|1024 -> nullptr // foobarbaz -> nullptr // B|1024|x -> pointer to x const char* FindAtracePayloadPtr(const char* ptr, const char* end) { … } bool StartsWith(const char* ptr, const char* end, const std::string& starts_with) { … } void RedactMatches(const Matches& matches) { … } } // namespace void StringFilter::AddRule(Policy policy, std::string_view pattern_str, std::string atrace_payload_starts_with) { … } bool StringFilter::MaybeFilterInternal(char* ptr, size_t len) const { … } } // namespace protozero