Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.h

Issue 1970823002: Remove the unused OffDomainInclusionDetector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove whole whitelist Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // The download whitelist is used for two purposes: a white-domain list of 151 // The download whitelist is used for two purposes: a white-domain list of
152 // sites that are considered to host only harmless binaries as well as a 152 // sites that are considered to host only harmless binaries as well as a
153 // whitelist of arbitrary strings such as hashed certificate authorities that 153 // whitelist of arbitrary strings such as hashed certificate authorities that
154 // are considered to be trusted. The two methods below let you lookup the 154 // are considered to be trusted. The two methods below let you lookup the
155 // whitelist either for a URL or an arbitrary string. These methods will 155 // whitelist either for a URL or an arbitrary string. These methods will
156 // return false if no match is found and true otherwise. This function is safe 156 // return false if no match is found and true otherwise. This function is safe
157 // to call from any thread. 157 // to call from any thread.
158 virtual bool ContainsDownloadWhitelistedUrl(const GURL& url) = 0; 158 virtual bool ContainsDownloadWhitelistedUrl(const GURL& url) = 0;
159 virtual bool ContainsDownloadWhitelistedString(const std::string& str) = 0; 159 virtual bool ContainsDownloadWhitelistedString(const std::string& str) = 0;
160 160
161 // Returns true if |url| is on the off-domain inclusion whitelist.
162 virtual bool ContainsInclusionWhitelistedUrl(const GURL& url) = 0;
163
164 // Returns true if the given module is on the module whitelist. 161 // Returns true if the given module is on the module whitelist.
165 virtual bool ContainsModuleWhitelistedString(const std::string& str) = 0; 162 virtual bool ContainsModuleWhitelistedString(const std::string& str) = 0;
166 163
167 // Populates |prefix_hits| with any prefixes in |prefixes| that have matches 164 // Populates |prefix_hits| with any prefixes in |prefixes| that have matches
168 // in the database, returning true if there were any matches. 165 // in the database, returning true if there were any matches.
169 // 166 //
170 // This function can ONLY be accessed from the creation thread. 167 // This function can ONLY be accessed from the creation thread.
171 virtual bool ContainsExtensionPrefixes( 168 virtual bool ContainsExtensionPrefixes(
172 const std::vector<SBPrefix>& prefixes, 169 const std::vector<SBPrefix>& prefixes,
173 std::vector<SBPrefix>* prefix_hits) = 0; 170 std::vector<SBPrefix>* prefix_hits) = 0;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 public: 345 public:
349 // Create a database with the stores below. Takes ownership of all store 346 // Create a database with the stores below. Takes ownership of all store
350 // objects handed to this constructor. Ignores all future operations on lists 347 // objects handed to this constructor. Ignores all future operations on lists
351 // for which the store is initialized to NULL. 348 // for which the store is initialized to NULL.
352 SafeBrowsingDatabaseNew( 349 SafeBrowsingDatabaseNew(
353 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, 350 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner,
354 SafeBrowsingStore* browse_store, 351 SafeBrowsingStore* browse_store,
355 SafeBrowsingStore* download_store, 352 SafeBrowsingStore* download_store,
356 SafeBrowsingStore* csd_whitelist_store, 353 SafeBrowsingStore* csd_whitelist_store,
357 SafeBrowsingStore* download_whitelist_store, 354 SafeBrowsingStore* download_whitelist_store,
358 SafeBrowsingStore* inclusion_whitelist_store,
359 SafeBrowsingStore* extension_blacklist_store, 355 SafeBrowsingStore* extension_blacklist_store,
360 SafeBrowsingStore* ip_blacklist_store, 356 SafeBrowsingStore* ip_blacklist_store,
361 SafeBrowsingStore* unwanted_software_store, 357 SafeBrowsingStore* unwanted_software_store,
362 SafeBrowsingStore* module_whitelist_store, 358 SafeBrowsingStore* module_whitelist_store,
363 SafeBrowsingStore* resource_blacklist_store); 359 SafeBrowsingStore* resource_blacklist_store);
364 360
365 ~SafeBrowsingDatabaseNew() override; 361 ~SafeBrowsingDatabaseNew() override;
366 362
367 // Implement SafeBrowsingDatabase interface. 363 // Implement SafeBrowsingDatabase interface.
368 void Init(const base::FilePath& filename) override; 364 void Init(const base::FilePath& filename) override;
(...skipping 10 matching lines...) Expand all
379 std::vector<SBFullHashResult>* cache_hits) override; 375 std::vector<SBFullHashResult>* cache_hits) override;
380 bool ContainsUnwantedSoftwareHashes( 376 bool ContainsUnwantedSoftwareHashes(
381 const std::vector<SBFullHash>& full_hashes, 377 const std::vector<SBFullHash>& full_hashes,
382 std::vector<SBPrefix>* prefix_hits, 378 std::vector<SBPrefix>* prefix_hits,
383 std::vector<SBFullHashResult>* cache_hits) override; 379 std::vector<SBFullHashResult>* cache_hits) override;
384 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes, 380 bool ContainsDownloadUrlPrefixes(const std::vector<SBPrefix>& prefixes,
385 std::vector<SBPrefix>* prefix_hits) override; 381 std::vector<SBPrefix>* prefix_hits) override;
386 bool ContainsCsdWhitelistedUrl(const GURL& url) override; 382 bool ContainsCsdWhitelistedUrl(const GURL& url) override;
387 bool ContainsDownloadWhitelistedUrl(const GURL& url) override; 383 bool ContainsDownloadWhitelistedUrl(const GURL& url) override;
388 bool ContainsDownloadWhitelistedString(const std::string& str) override; 384 bool ContainsDownloadWhitelistedString(const std::string& str) override;
389 bool ContainsInclusionWhitelistedUrl(const GURL& url) override;
390 bool ContainsModuleWhitelistedString(const std::string& str) override; 385 bool ContainsModuleWhitelistedString(const std::string& str) override;
391 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes, 386 bool ContainsExtensionPrefixes(const std::vector<SBPrefix>& prefixes,
392 std::vector<SBPrefix>* prefix_hits) override; 387 std::vector<SBPrefix>* prefix_hits) override;
393 bool ContainsMalwareIP(const std::string& ip_address) override; 388 bool ContainsMalwareIP(const std::string& ip_address) override;
394 bool ContainsResourceUrlPrefixes(const std::vector<SBPrefix>& prefixes, 389 bool ContainsResourceUrlPrefixes(const std::vector<SBPrefix>& prefixes,
395 std::vector<SBPrefix>* prefix_hits) override; 390 std::vector<SBPrefix>* prefix_hits) override;
396 391
397 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override; 392 bool UpdateStarted(std::vector<SBListChunkRanges>* lists) override;
398 void InsertChunks( 393 void InsertChunks(
399 const std::string& list_name, 394 const std::string& list_name,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 // will automatically handle thread-safety. 436 // will automatically handle thread-safety.
442 class ThreadSafeStateManager { 437 class ThreadSafeStateManager {
443 public: 438 public:
444 // Identifiers for stores held by the ThreadSafeStateManager. Allows helper 439 // Identifiers for stores held by the ThreadSafeStateManager. Allows helper
445 // methods to start a transaction themselves and keep it as short as 440 // methods to start a transaction themselves and keep it as short as
446 // possible rather than force callers to start the transaction early to pass 441 // possible rather than force callers to start the transaction early to pass
447 // a store pointer to the said helper methods. 442 // a store pointer to the said helper methods.
448 enum class SBWhitelistId { 443 enum class SBWhitelistId {
449 CSD, 444 CSD,
450 DOWNLOAD, 445 DOWNLOAD,
451 INCLUSION, 446 obsolete_INCLUSION,
Joe Mason 2016/05/15 16:44:59 Wasn't sure if it's safe to renumber this enum so
gab 2016/05/16 13:27:58 This enum is only used at runtime (not stored to d
Joe Mason 2016/05/16 14:18:52 Acknowledged. Couldn't tell from looking at the co
452 MODULE, 447 MODULE,
453 }; 448 };
454 enum class PrefixSetId { 449 enum class PrefixSetId {
455 BROWSE, 450 BROWSE,
456 UNWANTED_SOFTWARE, 451 UNWANTED_SOFTWARE,
457 }; 452 };
458 453
459 // Obtained through BeginReadTransaction(NoLockOnMainTaskRunner)?(): a 454 // Obtained through BeginReadTransaction(NoLockOnMainTaskRunner)?(): a
460 // ReadTransaction allows read-only observations of the 455 // ReadTransaction allows read-only observations of the
461 // ThreadSafeStateManager's state. The |prefix_gethash_cache_| has a special 456 // ThreadSafeStateManager's state. The |prefix_gethash_cache_| has a special
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 // Underlying persistent stores for chunk data: 697 // Underlying persistent stores for chunk data:
703 // - |browse_store_|: For browsing related (phishing and malware URLs) 698 // - |browse_store_|: For browsing related (phishing and malware URLs)
704 // chunks and prefixes. 699 // chunks and prefixes.
705 // - |download_store_|: For download related (download URL and binary hash) 700 // - |download_store_|: For download related (download URL and binary hash)
706 // chunks and prefixes. 701 // chunks and prefixes.
707 // - |csd_whitelist_store_|: For the client-side phishing detection 702 // - |csd_whitelist_store_|: For the client-side phishing detection
708 // whitelist chunks and full-length hashes. This list only contains 256 703 // whitelist chunks and full-length hashes. This list only contains 256
709 // bit hashes. 704 // bit hashes.
710 // - |download_whitelist_store_|: For the download whitelist chunks and 705 // - |download_whitelist_store_|: For the download whitelist chunks and
711 // full-length hashes. This list only contains 256 bit hashes. 706 // full-length hashes. This list only contains 256 bit hashes.
712 // - |inclusion_whitelist_store_|: For the inclusion whitelist. Same format
713 // as |download_whitelist_store_|.
714 // - |extension_blacklist_store_|: For extension IDs. 707 // - |extension_blacklist_store_|: For extension IDs.
715 // - |ip_blacklist_store_|: For IP blacklist. 708 // - |ip_blacklist_store_|: For IP blacklist.
716 // - |unwanted_software_store_|: For unwanted software list (format 709 // - |unwanted_software_store_|: For unwanted software list (format
717 // identical to browsing lists). 710 // identical to browsing lists).
718 // - |module_whitelist_store_|: For module whitelist. This list only 711 // - |module_whitelist_store_|: For module whitelist. This list only
719 // contains 256 bit hashes. 712 // contains 256 bit hashes.
720 // - |resource_blacklist_store_|: For script resource list (format identical 713 // - |resource_blacklist_store_|: For script resource list (format identical
721 // to browsing lists). 714 // to browsing lists).
722 // 715 //
723 // The stores themselves will be modified throughout the existence of this 716 // The stores themselves will be modified throughout the existence of this
724 // database, but shouldn't ever be swapped out (hence the const 717 // database, but shouldn't ever be swapped out (hence the const
725 // std::unique_ptr -- which could be swapped for C++11's std::optional when 718 // std::unique_ptr -- which could be swapped for C++11's std::optional when
726 // that's available). They are NonThreadSafe and should thus only be accessed 719 // that's available). They are NonThreadSafe and should thus only be accessed
727 // on the database's main thread as enforced by SafeBrowsingStoreFile's 720 // on the database's main thread as enforced by SafeBrowsingStoreFile's
728 // implementation. 721 // implementation.
729 const std::unique_ptr<SafeBrowsingStore> browse_store_; 722 const std::unique_ptr<SafeBrowsingStore> browse_store_;
730 const std::unique_ptr<SafeBrowsingStore> download_store_; 723 const std::unique_ptr<SafeBrowsingStore> download_store_;
731 const std::unique_ptr<SafeBrowsingStore> csd_whitelist_store_; 724 const std::unique_ptr<SafeBrowsingStore> csd_whitelist_store_;
732 const std::unique_ptr<SafeBrowsingStore> download_whitelist_store_; 725 const std::unique_ptr<SafeBrowsingStore> download_whitelist_store_;
733 const std::unique_ptr<SafeBrowsingStore> inclusion_whitelist_store_;
734 const std::unique_ptr<SafeBrowsingStore> extension_blacklist_store_; 726 const std::unique_ptr<SafeBrowsingStore> extension_blacklist_store_;
735 const std::unique_ptr<SafeBrowsingStore> ip_blacklist_store_; 727 const std::unique_ptr<SafeBrowsingStore> ip_blacklist_store_;
736 const std::unique_ptr<SafeBrowsingStore> unwanted_software_store_; 728 const std::unique_ptr<SafeBrowsingStore> unwanted_software_store_;
737 const std::unique_ptr<SafeBrowsingStore> module_whitelist_store_; 729 const std::unique_ptr<SafeBrowsingStore> module_whitelist_store_;
738 const std::unique_ptr<SafeBrowsingStore> resource_blacklist_store_; 730 const std::unique_ptr<SafeBrowsingStore> resource_blacklist_store_;
739 731
740 // Used to schedule resetting the database because of corruption. This factory 732 // Used to schedule resetting the database because of corruption. This factory
741 // and the WeakPtrs it issues should only be used on the database's main 733 // and the WeakPtrs it issues should only be used on the database's main
742 // thread. 734 // thread.
743 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_; 735 base::WeakPtrFactory<SafeBrowsingDatabaseNew> reset_factory_;
744 }; 736 };
745 737
746 } // namespace safe_browsing 738 } // namespace safe_browsing
747 739
748 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_ 740 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698