Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 6007: Add temporary fingerprinting exception for 1password.com #3425

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions common/shield_exceptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,32 @@ bool IsBlockedResource(const GURL& gurl) {

bool IsWhitelistedFingerprintingException(const GURL& firstPartyOrigin,
const GURL& subresourceUrl) {
static std::map<GURL, std::vector<URLPattern> > whitelist_patterns = {
static std::map<URLPattern, std::vector<URLPattern> > whitelist_patterns = {
{
GURL("https://uphold.com/"),
URLPattern(URLPattern::SCHEME_ALL, "https://uphold.com/"),
std::vector<URLPattern>({URLPattern(URLPattern::SCHEME_ALL,
"https://uphold.netverify.com/*")})
},
{
GURL("https://sandbox.uphold.com/"),
URLPattern(URLPattern::SCHEME_ALL, "https://sandbox.uphold.com/"),
std::vector<URLPattern>({URLPattern(URLPattern::SCHEME_ALL,
"https://*.netverify.com/*")})
},
{
URLPattern(URLPattern::SCHEME_ALL, "https://*.1password.com/*"),
std::vector<URLPattern>({URLPattern(URLPattern::SCHEME_ALL,
"https://map.1passwordservices.com/*")})
}
};
std::map<GURL, std::vector<URLPattern> >::iterator i =
whitelist_patterns.find(firstPartyOrigin);
if (i == whitelist_patterns.end()) {
return false;
for (const auto whitelist : whitelist_patterns) {
if (whitelist.first.MatchesURL(firstPartyOrigin)) {
return std::any_of(whitelist.second.begin(), whitelist.second.end(),
[&subresourceUrl](const URLPattern& pattern) {
return pattern.MatchesURL(subresourceUrl);
});
}
}
std::vector<URLPattern> &exceptions = i->second;
return std::any_of(exceptions.begin(), exceptions.end(),
[&subresourceUrl](const URLPattern& pattern) {
return pattern.MatchesURL(subresourceUrl);
});
return false;
}

} // namespace brave
25 changes: 25 additions & 0 deletions common/shield_exceptions_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,31 @@ TEST_F(BraveShieldsExceptionsTest, IsWhitelistedFingerprintingException) {
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("http://www.sandbox.uphold.com/"),
GURL("https://netverify.com/iframe")));

EXPECT_TRUE(IsWhitelistedFingerprintingException(
GURL("https://brave.1password.com"),
GURL("https://map.1passwordservices.com/iframe")));
EXPECT_TRUE(IsWhitelistedFingerprintingException(
GURL("https://brave.1password.com/randompath"),
GURL("https://map.1passwordservices.com/")));
EXPECT_TRUE(IsWhitelistedFingerprintingException(
GURL("https://1password.com/"),
GURL("https://map.1passwordservices.com/")));
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("https://11password.com/"),
GURL("http://map.1passwordservices.com/")));
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("https://map.1passwordservices.com/"),
GURL("https://map.1passwordservices.com/")));
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("http://brave.1password.com/"),
GURL("https://map.1passwordservices.com/iframe")));
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("https://1password.1passwordservices.com/"),
GURL("https://map.1passwordservices.com/")));
diracdeltas marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_FALSE(IsWhitelistedFingerprintingException(
GURL("https://brave.1password.com/"),
GURL("https://randompath.1passwordservices.com/")));
}

} // namespace