Bug 1203347 - Increase Safe Browsing debug logging around gethash (C++). r=gcp

This commit is contained in:
Francois Marier 2015-09-14 18:03:56 -07:00
parent ef41c4971f
commit aeb9dbcf18
3 changed files with 11 additions and 5 deletions

View File

@ -251,14 +251,12 @@ Classifier::Check(const nsACString& aSpec,
continue;
}
#if DEBUG
if (LOG_ENABLED()) {
nsAutoCString checking;
lookupHash.ToHexString(checking);
LOG(("Checking fragment %s, hash %s (%X)", fragments[i].get(),
checking.get(), lookupHash.ToUint32()));
}
#endif
for (uint32_t i = 0; i < cacheArray.Length(); i++) {
LookupCache *cache = cacheArray[i];

View File

@ -88,6 +88,7 @@ struct SafebrowsingHash
PL_Base64Encode((char*)buf, sHashSize, aStr.BeginWriting());
aStr.BeginWriting()[len] = '\0';
}
#endif
void ToHexString(nsACString& aStr) const {
static const char* const lut = "0123456789ABCDEF";
@ -101,7 +102,7 @@ struct SafebrowsingHash
aStr.Append(lut[c & 15]);
}
}
#endif
uint32_t ToUint32() const {
return *((uint32_t*)buf);
}

View File

@ -814,6 +814,8 @@ nsUrlClassifierLookupCallback::LookupComplete(nsTArray<LookupResult>* results)
NS_ENSURE_SUCCESS(rv, rv);
rv = listManager->GetGethashUrl(result.mTableName, gethashUrl);
NS_ENSURE_SUCCESS(rv, rv);
LOG(("The match from %s needs to be completed at %s",
result.mTableName.get(), gethashUrl.get()));
// gethashUrls may be empty in 2 cases: test tables, and on startup where
// we may have found a prefix in an existing table before the listmanager
// has registered the table. In the second case we should not call
@ -836,6 +838,8 @@ nsUrlClassifierLookupCallback::LookupComplete(nsTArray<LookupResult>* results)
// in 45 minutes.
if (result.Complete()) {
result.mFresh = true;
LOG(("Skipping completion in a table without a valid completer (%s).",
result.mTableName.get()));
} else {
NS_WARNING("Partial match in a table without a valid completer, ignoring partial match.");
}
@ -922,8 +926,11 @@ nsUrlClassifierLookupCallback::HandleResults()
// Leave out results that weren't confirmed, as their existence on
// the list can't be verified. Also leave out randomly-generated
// noise.
if (!result.Confirmed() || result.mNoise) {
LOG(("Skipping result from table %s", result.mTableName.get()));
if (!result.Confirmed()) {
LOG(("Skipping result from table %s (not confirmed)", result.mTableName.get()));
continue;
} else if (result.mNoise) {
LOG(("Skipping result from table %s (noise)", result.mTableName.get()));
continue;
}