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

Side by Side Diff: components/data_reduction_proxy/browser/data_reduction_proxy_tamper_detect.h

Issue 338483002: Chrome Participated Tamper Detect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed most of comments Created 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_TAMPER_DETE CT_H_
6 #define COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_TAMPER_DETE CT_H_
7
8 #include <map>
9
10 #include "components/data_reduction_proxy/common/data_reduction_proxy_headers.h"
11
12 #include "net/http/http_response_headers.h"
13
14 //namespace net {
bengr 2014/07/07 17:01:33 Remove dead code. Though I think you need this for
xingx 2014/07/08 00:22:25 Done.
15 //class HttpResponseHeaders;
16 //}
17
18 namespace data_reduction_proxy {
19
20 // Two fingerprints will be added to Chrome-Proxy header.
bengr 2014/07/07 17:01:34 Fill the comment out to 80 characters on each line
xingx 2014/07/08 00:22:26 Done.
21 // One starts with |kTamperDetectFingerprintChromeProxy|, which is the
22 // fingerprint for Chrome-Proxy header.
bengr 2014/07/07 17:01:33 for the
xingx 2014/07/08 00:22:26 Done.
23 // The other one starts with |kTamperDetectFingerprint|, which includes
24 // all other fingerprints.
25 extern const char kTamperDetectFingerprint[];
26 extern const char kTamperDetectFingerprintChromeProxy[];
27
28 // Fingerprint |kTamperDetectFingerprint| contains multiple
29 // fingerprints, each starts with a tag followed by "=" and its fingerprint
30 // value. Three fingerprints and their respective tags are defined below.
31 extern const char kTamperDetectFingerprintVia[];
bengr 2014/07/07 17:01:35 Do these really need to be visible to the entire n
xingx 2014/07/08 00:22:25 Done.
32 extern const char kTamperDetectFingerprintOther[];
33 extern const char kTamperDetectFingerprintContengLength[];
34
35 // Utility function, exposed for unittest.
36 // Check whether values of a header field |values| contains the Chrome-Proxy
37 // header's fingerprint (starts with |kTamperDetectFingerprintChromeProxy|).
38 // If there is, return true, and save Chrome-Proxy header's fingerprint to
bengr 2014/07/07 17:01:33 If there is --> If it does
xingx 2014/07/08 00:22:26 Done.
39 // |chrome_proxy_fingerprint|;
40 // also save other fingerprints (starts with |kTamperDetectFingerprintOther|)
41 // to |other_fingerprints|.
42 // Return false if there is no Chrome-Proxy header's fingerprint found.
bengr 2014/07/07 17:01:34 header's -> header
xingx 2014/07/08 00:22:26 Done.
43 bool ContainsTamperDetectFingerprints(std::vector<std::string>& values,
bengr 2014/07/07 17:01:33 Make this a private or protected static member and
44 std::string& chrome_proxy_fingerprint,
bengr 2014/07/07 17:01:34 Do not use non-const references.
xingx 2014/07/08 00:22:27 Will discuss with you.
45 std::string& other_fingerprints);
46
47 // The main function for detecting tamper. It takes two parameters as input,
bengr 2014/07/07 17:01:33 tamper -> tampering.
xingx 2014/07/08 00:22:26 Done.
48 // 1. a pointer to HttpResponseHeaders,
49 // 2. a boolean variable indicates whether the connection
bengr 2014/07/07 17:01:34 variable indicates -> variable that indicates
xingx 2014/07/08 00:22:27 Done.
50 // between Chrome and data reduction proxy is on HTTPS or not.
51 // For such response, the function checks whether there is a tamper detect
bengr 2014/07/07 17:01:34 What is "such response"? Be clearer
xingx 2014/07/08 00:22:26 Done.
52 // request (contains fingerprints) from data reduction proxy, if so, it checks
53 // whether there are tampers and report the results to UMA.
54 void CheckResponseFingerprint(const net::HttpResponseHeaders*, const bool);
55
56 //extern enum FingerprintCode;
57 enum FingerprintCode { CHROMEPROXY, VIA, OTHERHEADERS,
bengr 2014/07/07 17:01:33 Put each value on a separate line.
xingx 2014/07/08 00:22:26 Done.
58 CONTENTLENGTH, NONEXIST };
59
60 // The class for detecting tamper.
bengr 2014/07/07 17:01:34 tampering.
xingx 2014/07/08 00:22:26 Done.
61 // It wraps up the functionalities for tamper detection.
bengr 2014/07/07 17:01:35 Remove this line. It doesn't add anything. Try to
xingx 2014/07/08 00:22:25 Done.
62 // For each fingerprint, we need to implement two functions:
63 // * checking function: returns tamper or not for such fingerprint;
64 // (function name starts with Check...)
65 // * reporting function: reporting results to corresponding UMA
66 // when there are tampers detected.
67 // (function name starts with Report...)
68 class DataReductionProxyTamperDetect {
69 public:
70 DataReductionProxyTamperDetect(const net::HttpResponseHeaders*, const bool,
bengr 2014/07/07 17:01:33 provide variable names.
xingx 2014/07/08 00:22:26 Done.
71 const unsigned, std::vector<std::string>*);
bengr 2014/07/07 17:01:34 Don't make the bool and the unsigned const. I don'
xingx 2014/07/08 00:22:26 Done.
72 virtual ~DataReductionProxyTamperDetect();
73
74 // Returns true if Chrome-Proxy has been tampered.
bengr 2014/07/07 17:01:33 what is the parameter?
bengr 2014/07/07 17:01:34 if Chrome-Proxy --> if the Chrome-Proxy header
xingx 2014/07/08 00:22:25 Done.
xingx 2014/07/08 00:22:25 Done.
xingx 2014/07/08 00:22:26 Done.
xingx 2014/07/08 00:22:26 Done.
75 bool CheckHeaderChromeProxy(const std::string&) const;
bengr 2014/07/07 17:01:35 variable name
bengr 2014/07/07 17:01:35 Rename as IsChromeProxyHeaderModified(const std::s
xingx 2014/07/08 00:22:26 Done.
xingx 2014/07/08 00:22:27 Done.
76
77 // Returns true if Via has been tampered.
bengr 2014/07/07 17:01:34 if Via --> if the Via header
xingx 2014/07/08 00:22:26 Done.
78 bool CheckHeaderVia(const std::string&) const;
bengr 2014/07/07 17:01:34 rename as IsViaHeaderModified(const std::string& h
bengr 2014/07/07 17:01:35 variable name
xingx 2014/07/08 00:22:25 Done.
xingx 2014/07/08 00:22:26 Done.
xingx 2014/07/08 00:22:26 Done.
79 // Report UMA for tampering of Via header.
80 void ReportHeaderVia() const;
bengr 2014/07/07 17:01:34 suggest ReportViaHeaderTamperedUMA()
xingx 2014/07/08 00:22:26 Done.
81
82 // Returns true if other headers (a list of headers) hav been tampered.
83 bool CheckHeaderOtherHeaders(const std::string&) const;
bengr 2014/07/07 17:01:34 What is the parameter? The concatenation of all ot
xingx 2014/07/08 00:22:26 Done.
84 // Report UMA for tampering of values of the list of headers.
85 void ReportHeaderOtherHeaders() const;
bengr 2014/07/07 17:01:35 ReportOtherHeadersTamperedUMA()
xingx 2014/07/08 00:22:26 Done.
86
87 // Returns true if Content-Length has been tampered.
88 bool CheckHeaderContentLength(const std::string&) const;
89 // Report UMA for tampering of Content-Length.
90 void ReportHeaderContentLength() const;
bengr 2014/07/07 17:01:34 ReportContentLengthHeaderTamperedUMA()
xingx 2014/07/08 00:22:25 Done.
91
92 // Return string of sorted values of |values|.
93 static std::string ValuesToSortedString(std::vector<std::string> &values);
bengr 2014/07/07 17:01:33 Why does this (and many of these functions) need t
xingx 2014/07/08 00:22:25 Done.
94
95 // Return MD5 hash value for a given string |input|.
bengr 2014/07/07 17:01:34 Return --> Returns Add to the comment why you can
xingx 2014/07/08 00:22:26 Done.
96 static std::string GetMD5(const std::string& input);
97
98 // Return all the values of a header field |header_name| of the
99 // response header |headers|, as a vector.
100 static std::vector<std::string> GetHeaderValues(
101 const net::HttpResponseHeaders* headers, const std::string& header_name);
102
103 // Return fingerprint code (enum) for the given fingerprint tag.
104 FingerprintCode GetFingerprintCode(const std::string&);
bengr 2014/07/07 17:01:33 provide a variable name here and everywhere.
xingx 2014/07/08 00:22:26 Done.
105
106 private:
107 // Response header.
108 const net::HttpResponseHeaders* response_headers;
109
110 // HTTPS or HTTP.
111 const bool is_secure_scheme;
112
113 // Carrier ID.
114 const unsigned mcc_mnc;
115
116 // Values for Chrome-Proxy header, with |kTamperDetectFingerprintChromeProxy|
117 // removed. Save it as temporary result so we don't need to parse
118 // Chrome-Proxy header twice.
119 std::vector<std::string>* clean_chrome_proxy_header_values;
120
121 // Map a fingerprint tag (string) to a fingerprint code (enum).
122 std::map<std::string, FingerprintCode> fingperprint_tag_code_map;
123 };
124
125 } // namespace data_reduction_proxy
126 #endif // COMPONENTS_DATA_REDUCTION_PROXY_BROWSER_DATA_REDUCTION_PROXY_TAMPER_D ETECT_H_
OLDNEW
« no previous file with comments | « components/data_reduction_proxy.gypi ('k') | components/data_reduction_proxy/browser/data_reduction_proxy_tamper_detect.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698