summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-17 06:19:42 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-17 06:19:42 (GMT)
commit47f41e3b296850f3670cc5a189760959394342c0 (patch)
tree6e3bd7ca990abd073bbd361bc8f1cbdc29548086
parentf8d9c9e291be6a484cc688f705721548bd4b999f (diff)
Parse removal index
-rw-r--r--webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp3
-rw-r--r--webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp27
2 files changed, 18 insertions, 12 deletions
diff --git a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
index 5183284..85fd591 100644
--- a/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
+++ b/webengineviewer/src/checkphishingurl/autotests/createphishingurldatabasejobtest.cpp
@@ -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;
}
diff --git a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
index 39b3147..b7cbff1 100644
--- a/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
+++ b/webengineviewer/src/checkphishingurl/createphishingurldatabasejob.cpp
@@ -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();