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

Unified Diff: chrome/renderer/safe_browsing/features.cc

Issue 2878046: Add an extractor for DOM features to be used for client side phishing detection. (Closed)
Patch Set: address marria's comments Created 10 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/safe_browsing/features.h ('k') | chrome/renderer/safe_browsing/features_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/safe_browsing/features.cc
diff --git a/chrome/renderer/safe_browsing/features.cc b/chrome/renderer/safe_browsing/features.cc
index 47a093cfbfae3e15e64185ff0506dba891f2e637..4d67cf34517f927ca8bec513545e6f1d371a1873 100644
--- a/chrome/renderer/safe_browsing/features.cc
+++ b/chrome/renderer/safe_browsing/features.cc
@@ -15,6 +15,10 @@ FeatureMap::FeatureMap() {}
FeatureMap::~FeatureMap() {}
bool FeatureMap::AddBooleanFeature(const std::string& name) {
+ return AddRealFeature(name, 1.0);
+}
+
+bool FeatureMap::AddRealFeature(const std::string& name, double value) {
if (features_.size() >= kMaxFeatureMapSize) {
// If we hit this case, it indicates that either kMaxFeatureMapSize is
// too small, or there is a bug causing too many features to be added.
@@ -25,7 +29,16 @@ bool FeatureMap::AddBooleanFeature(const std::string& name) {
UMA_HISTOGRAM_COUNTS("SBClientPhishing.TooManyFeatures", 1);
return false;
}
- features_[name] = 1.0;
+ // We only expect features in the range [0.0, 1.0], so fail if the feature is
+ // outside this range.
+ if (value < 0.0 || value > 1.0) {
+ LOG(ERROR) << "Not adding feature: " << name << " because the value "
+ << value << " is not in the range [0.0, 1.0].";
+ UMA_HISTOGRAM_COUNTS("SBClientPhishing.IllegalFeatureValue", 1);
+ return false;
+ }
+
+ features_[name] = value;
return true;
}
@@ -47,5 +60,25 @@ const char kUrlNumOtherHostTokensGTThree[] = "UrlNumOtherHostTokens>3";
// URL path features
const char kUrlPathToken[] = "UrlPathToken=";
+// DOM HTML form features
+const char kPageHasForms[] = "PageHasForms";
+const char kPageActionOtherDomainFreq[] = "PageActionOtherDomainFreq";
+const char kPageHasTextInputs[] = "PageHasTextInputs";
+const char kPageHasPswdInputs[] = "PageHasPswdInputs";
+const char kPageHasRadioInputs[] = "PageHasRadioInputs";
+const char kPageHasCheckInputs[] = "PageHasCheckInputs";
+
+// DOM HTML link features
+const char kPageExternalLinksFreq[] = "PageExternalLinksFreq";
+const char kPageLinkDomain[] = "PageLinkDomain=";
+const char kPageSecureLinksFreq[] = "PageSecureLinksFreq";
+
+// DOM HTML script features
+const char kPageNumScriptTagsGTOne[] = "PageNumScriptTags>1";
+const char kPageNumScriptTagsGTSix[] = "PageNumScriptTags>6";
+
+// Other DOM HTML features
+const char kPageImgOtherDomainFreq[] = "PageImgOtherDomainFreq";
+
} // namespace features
} // namespace safe_browsing
« no previous file with comments | « chrome/renderer/safe_browsing/features.h ('k') | chrome/renderer/safe_browsing/features_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698