| 237 | const char kToken[] = "admin"; |
| 238 | |
| 239 | ABSL_ATTRIBUTE_NOINLINE |
| 240 | bool NativeCheck(absl::btree_map<std::string, std::string>& attributes, |
| 241 | const absl::flat_hash_set<std::string>& denylists, |
| 242 | const absl::flat_hash_set<std::string>& allowlists) { |
| 243 | auto& ip = attributes["ip"]; |
| 244 | auto& path = attributes["path"]; |
| 245 | auto& token = attributes["token"]; |
| 246 | if (denylists.find(ip) != denylists.end()) { |
| 247 | return false; |
| 248 | } |
| 249 | if (absl::StartsWith(path, "v1")) { |
| 250 | if (token == "v1" || token == "v2" || token == "admin") { |
| 251 | return true; |
| 252 | } |
| 253 | } else if (absl::StartsWith(path, "v2")) { |
| 254 | if (token == "v2" || token == "admin") { |
| 255 | return true; |
| 256 | } |
| 257 | } else if (absl::StartsWith(path, "/admin")) { |
| 258 | if (token == "admin") { |
| 259 | if (allowlists.find(ip) != allowlists.end()) { |
| 260 | return true; |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | void BM_PolicyNative(benchmark::State& state) { |
| 268 | const auto denylists = |