forked from mirrors/gecko-dev
When full match is found in both v2 and v4, the threat types returned should also be the same. If threat types are different, the telemetry record this by setting a bit flags which indicates what threat types are being returned. If threat types are the same, this telemetry will record 0. MozReview-Commit-ID: Laz77yoCg00 --HG-- extra : rebase_source : 1bcace8464c9d6472a745f66fd547b186e5b3297
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* * License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "SBTelemetryUtils.h"
|
|
#include "mozilla/Assertions.h"
|
|
|
|
namespace mozilla {
|
|
namespace safebrowsing {
|
|
|
|
uint8_t
|
|
MatchResultToUint(const MatchResult& aResult)
|
|
{
|
|
MOZ_ASSERT(!(aResult & MatchResult::eTelemetryDisabled));
|
|
switch (aResult) {
|
|
case MatchResult::eNoMatch: return 0;
|
|
case MatchResult::eV2Prefix: return 1;
|
|
case MatchResult::eV4Prefix: return 2;
|
|
case MatchResult::eBothPrefix: return 3;
|
|
case MatchResult::eAll: return 4;
|
|
case MatchResult::eV2PreAndCom: return 5;
|
|
case MatchResult::eV4PreAndCom: return 6;
|
|
case MatchResult::eBothPreAndV2Com: return 7;
|
|
case MatchResult::eBothPreAndV4Com: return 8;
|
|
default:
|
|
MOZ_ASSERT_UNREACHABLE("Unexpected match result");
|
|
return 9;
|
|
}
|
|
}
|
|
|
|
MatchThreatType
|
|
TableNameToThreatType(bool aIsV2, const nsACString& aTable)
|
|
{
|
|
if (FindInReadable(NS_LITERAL_CSTRING("-phish-"), aTable)) {
|
|
return aIsV2 ? MatchThreatType::eV2Phishing : MatchThreatType::eV4Phishing;
|
|
} else if (FindInReadable(NS_LITERAL_CSTRING("-malware-"), aTable)) {
|
|
return aIsV2 ? MatchThreatType::eV2Malware : MatchThreatType::eV4Malware;
|
|
} else if (FindInReadable(NS_LITERAL_CSTRING("-unwanted-"), aTable)) {
|
|
return aIsV2 ? MatchThreatType::eV2Unwanted : MatchThreatType::eV4Unwanted;
|
|
}
|
|
return MatchThreatType::eIdentical;
|
|
}
|
|
|
|
} // namespace safebrowsing
|
|
} // namespace mozilla
|