Commit da549b9a authored by bryner@chromium.org's avatar bryner@chromium.org

Include the HTTP status code as a feature in the ClientPhishingRequest.

BUG=none
TEST=BrowserFeatureExtractorTest


Review URL: http://codereview.chromium.org/8400050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107867 0039d316-1c4b-4281-b951-d872f2087c98
parent 089e3035
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
namespace safe_browsing { namespace safe_browsing {
BrowseInfo::BrowseInfo() {} BrowseInfo::BrowseInfo() : http_status_code(0) {}
BrowseInfo::~BrowseInfo() {} BrowseInfo::~BrowseInfo() {}
...@@ -232,7 +232,9 @@ void BrowserFeatureExtractor::ExtractBrowseInfoFeatures( ...@@ -232,7 +232,9 @@ void BrowserFeatureExtractor::ExtractBrowseInfoFeatures(
static_cast<double>(info.unsafe_resource->threat_type), static_cast<double>(info.unsafe_resource->threat_type),
request); request);
} }
if (info.http_status_code != 0) {
AddFeature(features::kHttpStatusCode, info.http_status_code, request);
}
} }
void BrowserFeatureExtractor::StartExtractFeatures( void BrowserFeatureExtractor::StartExtractFeatures(
......
...@@ -49,6 +49,9 @@ struct BrowseInfo { ...@@ -49,6 +49,9 @@ struct BrowseInfo {
std::vector<GURL> host_redirects; std::vector<GURL> host_redirects;
std::vector<GURL> url_redirects; std::vector<GURL> url_redirects;
// The HTTP status code from this navigation.
int http_status_code;
BrowseInfo(); BrowseInfo();
~BrowseInfo(); ~BrowseInfo();
}; };
......
...@@ -272,6 +272,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) { ...@@ -272,6 +272,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) {
redirect_chain.push_back(GURL("http://somerandomwebsite.com/")); redirect_chain.push_back(GURL("http://somerandomwebsite.com/"));
redirect_chain.push_back(GURL("http://www.foo.com/")); redirect_chain.push_back(GURL("http://www.foo.com/"));
SetRedirectChain(redirect_chain, true); SetRedirectChain(redirect_chain, true);
browse_info_->http_status_code = 200;
NavigateAndCommit(GURL("http://www.foo.com/"), NavigateAndCommit(GURL("http://www.foo.com/"),
GURL("http://google.com/"), GURL("http://google.com/"),
content::PageTransitionFromInt( content::PageTransitionFromInt(
...@@ -299,6 +300,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) { ...@@ -299,6 +300,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) {
EXPECT_EQ(0.0, features[features::kHasSSLReferrer]); EXPECT_EQ(0.0, features[features::kHasSSLReferrer]);
EXPECT_EQ(2.0, features[features::kPageTransitionType]); EXPECT_EQ(2.0, features[features::kPageTransitionType]);
EXPECT_EQ(1.0, features[features::kIsFirstNavigation]); EXPECT_EQ(1.0, features[features::kIsFirstNavigation]);
EXPECT_EQ(200.0, features[features::kHttpStatusCode]);
request.Clear(); request.Clear();
request.set_url("http://www.foo.com/page.html"); request.set_url("http://www.foo.com/page.html");
...@@ -308,6 +310,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) { ...@@ -308,6 +310,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) {
redirect_chain.push_back(GURL("http://www.foo.com/second_redirect")); redirect_chain.push_back(GURL("http://www.foo.com/second_redirect"));
redirect_chain.push_back(GURL("http://www.foo.com/page.html")); redirect_chain.push_back(GURL("http://www.foo.com/page.html"));
SetRedirectChain(redirect_chain, false); SetRedirectChain(redirect_chain, false);
browse_info_->http_status_code = 404;
NavigateAndCommit(GURL("http://www.foo.com/page.html"), NavigateAndCommit(GURL("http://www.foo.com/page.html"),
GURL("http://www.foo.com"), GURL("http://www.foo.com"),
content::PageTransitionFromInt( content::PageTransitionFromInt(
...@@ -352,6 +355,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) { ...@@ -352,6 +355,7 @@ TEST_F(BrowserFeatureExtractorTest, BrowseFeatures) {
features[StringPrintf("%s%s", features[StringPrintf("%s%s",
features::kHostPrefix, features::kHostPrefix,
features::kIsFirstNavigation)]); features::kIsFirstNavigation)]);
EXPECT_EQ(404.0, features[features::kHttpStatusCode]);
request.Clear(); request.Clear();
request.set_url("http://www.bar.com/"); request.set_url("http://www.bar.com/");
......
...@@ -27,6 +27,7 @@ const char kRedirectUrlMismatch[] = "RedirectUrlMismatch"; ...@@ -27,6 +27,7 @@ const char kRedirectUrlMismatch[] = "RedirectUrlMismatch";
const char kRedirect[] = "Redirect"; const char kRedirect[] = "Redirect";
const char kSecureRedirectValue[] = "SecureRedirect"; const char kSecureRedirectValue[] = "SecureRedirect";
const char kBadIpFetch[] = "BadIpFetch="; const char kBadIpFetch[] = "BadIpFetch=";
const char kHttpStatusCode[] = "HttpStatusCode";
const char kSafeBrowsingMaliciousUrl[] = "SafeBrowsingMaliciousUrl="; const char kSafeBrowsingMaliciousUrl[] = "SafeBrowsingMaliciousUrl=";
const char kSafeBrowsingOriginalUrl[] = "SafeBrowsingOriginalUrl="; const char kSafeBrowsingOriginalUrl[] = "SafeBrowsingOriginalUrl=";
const char kSafeBrowsingIsSubresource[] = "SafeBrowsingIsSubresource"; const char kSafeBrowsingIsSubresource[] = "SafeBrowsingIsSubresource";
......
...@@ -71,6 +71,9 @@ extern const char kSecureRedirectValue[]; ...@@ -71,6 +71,9 @@ extern const char kSecureRedirectValue[];
// Resource was fetched from a known bad IP address. // Resource was fetched from a known bad IP address.
extern const char kBadIpFetch[]; extern const char kBadIpFetch[];
// The HTTP status code for the main document.
extern const char kHttpStatusCode[];
// SafeBrowsing related featues. Fields from the UnsafeResource if there is // SafeBrowsing related featues. Fields from the UnsafeResource if there is
// any. // any.
extern const char kSafeBrowsingMaliciousUrl[]; extern const char kSafeBrowsingMaliciousUrl[];
......
...@@ -324,6 +324,7 @@ void ClientSideDetectionHost::DidNavigateMainFramePostCommit( ...@@ -324,6 +324,7 @@ void ClientSideDetectionHost::DidNavigateMainFramePostCommit(
} }
browse_info_->host_redirects = cur_host_redirects_; browse_info_->host_redirects = cur_host_redirects_;
browse_info_->url_redirects = params.redirects; browse_info_->url_redirects = params.redirects;
browse_info_->http_status_code = details.http_status_code;
// Notify the renderer if it should classify this URL. // Notify the renderer if it should classify this URL.
classification_request_ = new ShouldClassifyUrlRequest(params, classification_request_ = new ShouldClassifyUrlRequest(params,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment