-
-
Notifications
You must be signed in to change notification settings - Fork 232
/
historySourceTagger.js
55 lines (52 loc) · 1.68 KB
/
historySourceTagger.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Running this script will cause ZAP to loop through all the entries in the history table.
// Entries in the table will be tagged (in the "tags" column) in the form:
// SRC_Proxied, SRC_Manual, SRC_Other
// The script can be run multiple times, history entries will only be tagged
// if they don't already have a tag that starts with TAG_PREFIX as defined below.
// Author: kingthorin
// 20160207: Initial release
extHist = control
.getExtensionLoader()
.getExtension(org.parosproxy.paros.extension.history.ExtensionHistory.NAME);
TAG_PREFIX = "SRC_";
if (extHist != null) {
i = org.zaproxy.zap.extension.script.ScriptVars.getGlobalVar("tagged_ref"); // Check for global reference
if (i == null) {
i = 1; // Global reference was null so 1
}
lastRef = extHist.getLastHistoryId(); // Get current max history reference
while (i <= lastRef) {
// Loop through the history table
hr = extHist.getHistoryReference(i);
if ((i % 10 == 0) | (i == 1) | (i == lastRef)) {
// Progress update first, every 10, and last
print("Checking " + i);
}
if (hr) {
switch (hr.getHistoryType()) {
case 1:
type = "Proxied";
break;
case 15:
type = "Manual";
break;
default:
type = "Other";
break;
}
newTag = TAG_PREFIX + type;
theTags = hr.getTags();
if (!theTags.contains(newTag)) {
hr.addTag(newTag);
try {
extHist.notifyHistoryItemChanged(hr); // Trigger GUI update
} catch (ex) {} //Ignore
}
}
i++;
}
org.zaproxy.zap.extension.script.ScriptVars.setGlobalVar(
"tagged_ref",
lastRef + 1
); // Set global reference
}