1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Utilities for the SafeBrowsing DB code.
#ifndef COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_UTIL_H_
#define COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_UTIL_H_
#include <stdint.h>
#include <cstring>
#include <memory>
#include <set>
#include <string>
#include "base/containers/flat_map.h"
#include "base/trace_event/traced_value.h"
#include "components/safe_browsing/core/browser/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
namespace safe_browsing {
// Metadata that indicates what kind of URL match this is.
enum class ThreatPatternType : int {
NONE = 0, // Pattern type didn't appear in the metadata
MALWARE_LANDING = 1, // The match is a malware landing page
MALWARE_DISTRIBUTION = 2, // The match is a malware distribution page
SOCIAL_ENGINEERING_ADS = 3, // The match is a social engineering ads page
SOCIAL_ENGINEERING_LANDING = 4, // The match is a social engineering landing
// page
PHISHING = 5, // The match is a phishing page
THREAT_PATTERN_TYPE_MAX_VALUE
};
enum class SubresourceFilterType : int { ABUSIVE = 0, BETTER_ADS = 1 };
enum class SubresourceFilterLevel : int { WARN = 0, ENFORCE = 1 };
using SubresourceFilterMatch =
base::flat_map<SubresourceFilterType, SubresourceFilterLevel>;
// Metadata that was returned by a GetFullHash call. This is the parsed version
// of the PB (from Pver3, or Pver4 local) or JSON (from Pver4 via GMSCore).
// Some fields are only applicable to certain lists.
// When adding elements to this struct, make sure you update ToTracedValue.
struct ThreatMetadata {
ThreatMetadata();
ThreatMetadata(const ThreatMetadata& other);
ThreatMetadata(ThreatMetadata&& other);
ThreatMetadata& operator=(const ThreatMetadata& other);
ThreatMetadata& operator=(ThreatMetadata&& other);
~ThreatMetadata();
friend bool operator==(const ThreatMetadata&,
const ThreatMetadata&) = default;
// Returns the metadata in a format tracing can support.
std::unique_ptr<base::trace_event::TracedValue> ToTracedValue() const;
// Type of blocklisted page. Used on malware and UwS lists.
// This will be NONE if it wasn't present in the reponse.
ThreatPatternType threat_pattern_type;
// Set of permissions blocked. Used with threat_type API_ABUSE.
// This will be empty if it wasn't present in the response.
std::set<std::string> api_permissions;
// Map of list sub-types related to the SUBRESOURCE_FILTER threat type.
// Used instead of ThreatPatternType to allow multiple types at the same time.
SubresourceFilterMatch subresource_filter_match;
};
} // namespace safe_browsing
#endif // COMPONENTS_SAFE_BROWSING_CORE_BROWSER_DB_UTIL_H_
|