Commit 47f41e3b authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Parse removal index

parent f8d9c9e2
......@@ -90,6 +90,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
additionList.append(tmp);
QVector<WebEngineViewer::Removal> removalList;
WebEngineViewer::Removal tmpRemoval;
tmpRemoval.indexes = QList<int>() << 0 << 2 << 4;
removalList.append(tmpRemoval);
value.minimumWaitDuration = QStringLiteral("593.440s");
value.threatType = QStringLiteral("MALWARE");
......@@ -99,7 +100,7 @@ void CreatePhishingUrlDataBaseJobTest::shouldParseResult_data()
value.newClientState = QStringLiteral("ChAIBRADGAEiAzAwMSiAEDABEAFGpqhd");
value.sha256 = QStringLiteral("YSgoRtsRlgHDqDA3LAhM1gegEpEzs1TjzU33vqsR8iM=");
value.additionList = additionList;
//value.removalList = removalList;
value.removalList = removalList;
QTest::newRow("test1") << QStringLiteral("test1.json") << WebEngineViewer::CreatePhishingUrlDataBaseJob::ValidData << value;
}
......
......@@ -219,9 +219,23 @@ QVector<Removal> CreatePhishingUrlDataBaseJob::parseRemovals(const QVariantList
mapIt.next();
const QString keyStr = mapIt.key();
if (keyStr == QLatin1String("compressionType")) {
//Add ??
} else if (keyStr == QLatin1String("rawIndices")) {
const QVariantMap map = mapIt.value().toMap();
QMapIterator<QString, QVariant> rawIndicesIt(map);
while (rawIndicesIt.hasNext()) {
rawIndicesIt.next();
if (rawIndicesIt.key() == QStringLiteral("indices")) {
const QVariantList lst = rawIndicesIt.value().toList();
QList<int> indexList;
Q_FOREACH(const QVariant &var, lst) {
indexList.append(var.toInt());
}
tmp.indexes = indexList;
} else {
qDebug() << "rawIndicesIt.key() unknown " << rawIndicesIt.key();
}
}
} else {
qDebug() << " CreatePhishingUrlDataBaseJob::parseRemovals unknown mapIt.key() " << keyStr;
}
......@@ -260,14 +274,12 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
mapIt.next();
const QString mapKey = mapIt.key();
if (mapKey == QLatin1String("additions")) {
qDebug() << " additions" << mapIt.value().typeName();
const QVariantList lst = mapIt.value().toList();
const QVector<Addition> addList = parseAdditions(lst);
if (!addList.isEmpty()) {
databaseInfo.additionList.append(addList);
}
} else if (mapKey == QLatin1String("removals")) {
qDebug() << " removals items " << mapIt.value().typeName();
const QVariantList lst = mapIt.value().toList();
const QVector<Removal> removeList = parseRemovals(lst);
if (!removeList.isEmpty()) {
......@@ -278,26 +290,20 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
while (mapCheckSum.hasNext()) {
mapCheckSum.next();
if (mapCheckSum.key() == QLatin1String("sha256")) {
qDebug() << " sha256 value " << mapCheckSum.value().toString();
databaseInfo.sha256 = mapCheckSum.value().toString();
} else {
qDebug() << "Invalid checksum key" << mapCheckSum.key();
}
}
} else if (mapKey == QLatin1String("newClientState")) {
qDebug() << " newClientState " << mapIt.value().toString();
databaseInfo.newClientState = mapIt.value().toString();
} else if (mapKey == QLatin1String("platformType")) {
qDebug() << " platformType " << mapIt.value().toString();
databaseInfo.platformType = mapIt.value().toString();
} else if (mapKey == QLatin1String("responseType")) {
qDebug() << " responseType " << mapIt.value().toString();
databaseInfo.responseType = mapIt.value().toString();
} else if (mapKey == QLatin1String("threatEntryType")) {
qDebug() << " threatEntryType " << mapIt.value().toString();
databaseInfo.threatEntryType = mapIt.value().toString();
} else if (mapKey == QLatin1String("threatType")) {
qDebug() << " threatType " << mapIt.value().toString();
databaseInfo.threatType = mapIt.value().toString();
} else {
qDebug() << " unknow key " << mapKey;
......@@ -306,7 +312,6 @@ void CreatePhishingUrlDataBaseJob::parseResult(const QByteArray &value)
}
}
} else if (i.key() == QLatin1String("minimumWaitDuration")) {
qDebug() << " minimumWaitDuration " << i.value().toString();
databaseInfo.minimumWaitDuration = i.value().toString();
} else {
qDebug() <<" map key unknown " << i.key();
......
Supports Markdown
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