Skip to content

Commit 1d19f4c

Browse files
authored
Merge pull request #246 from psiinon/scan/wavsep
Scan wavsep
2 parents 444a15a + 2b0f42b commit 1d19f4c

File tree

10 files changed

+357
-1006
lines changed

10 files changed

+357
-1006
lines changed

.github/workflows/zap-vs-wavsep-live.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/zap-vs-wavsep-st-high.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/zap-vs-wavsep.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,61 @@
1-
name: ZAP vs Wavsep - Default
1+
name: ZAP vs Wavsep
22

33
on:
4+
# Enable once we've checked its working well
5+
# schedule:
6+
# - cron: '40 3 * * 1' # 4:30 am every Monday
47
workflow_dispatch:
58

69
jobs:
710
scan:
8-
runs-on: [ubuntu-latest]
11+
runs-on: ubuntu-latest
912
steps:
10-
- name: Start wavsep
11-
run: docker run --rm -d -p 8080:8080 owaspvwad/wavsep &
12-
- name: Start ZAP
13-
run: docker run --rm -d -p 8090:8090 --network host ghcr.io/zaproxy/zaproxy:weekly zap-x.sh -daemon -host localhost -port 8090 -addonupdate -addoninstall domxss -config "api.addrs.addr.name=.*" -config api.addrs.addr.regex=true -config api.disablekey=true &
14-
- name: Run ZAP API script
15-
env:
16-
GITHUB_TOKEN: ${{ secrets.ZAPBOT_TOKEN }}
17-
run: docker run --rm --network host --env ZAPBOT_TOKEN=${{ secrets.ZAPBOT_TOKEN }} zaproxy/zap-testing ./zap-vs-wavsep-1.5.sh -e 61 -n wavsep-1.5-weekly-RBJ-M-M -t "Rel, Beta, DomXSS"
13+
- name: Clone zap-mgmt-scripts and zaproxy-website
14+
run: |
15+
# Setup git details
16+
export GITHUB_USER=zapbot
17+
export GITHUB_TOKEN=${{ secrets.ZAPBOT_TOKEN }}
18+
git config --global user.email "12745184+zapbot@users.noreply.github.com"
19+
git config --global user.name $GITHUB_USER
20+
git clone https://github.com/$GITHUB_USER/zap-mgmt-scripts.git
21+
22+
git clone https://github.com/$GITHUB_USER/zaproxy-website.git
23+
24+
# Update to the latest upstream
25+
cd zaproxy-website
26+
git remote set-url origin https://$GITHUB_USER:$GITHUB_TOKEN@github.com/$GITHUB_USER/zaproxy-website.git
27+
git remote add upstream https://github.com/zaproxy/zaproxy-website.git
28+
git checkout -B wavsep
29+
git pull upstream main
30+
git reset --hard upstream/main
31+
git push --set-upstream origin wavsep --force
32+
33+
- name: Scan Wavsep
34+
run: |
35+
# start Wavsep
36+
docker run --rm -it -p 8080:8080 -p 3306:3306 zaproxy/wavsep
37+
38+
cd zap-mgmt-scripts/scans/wavsep
39+
# Need to do this so the zap user in docker can write to the directory
40+
mkdir res
41+
chmod a+w res
42+
docker run -v $(pwd):/zap/wrk/:rw --network host -t ghcr.io/zaproxy/zaproxy:nightly zap.sh -cmd -silent -autorun /zap/wrk/wavsep.yaml
43+
cp res/*.yml ../../../zaproxy-website/site/data/scans/wavsep/
44+
45+
- name: Raise a PR on the website
46+
run: |
47+
cd zaproxy-website
48+
49+
# Update the index to be sure git is aware of changes
50+
git update-index -q --refresh
51+
## If there are changes: comment, commit, PR
52+
if ! git diff-index --quiet HEAD --; then
53+
54+
git add site/data/scans/wavsep/*
55+
git commit -s -m "Updated WAVSEP Results"
56+
git push origin
57+
58+
echo ${{ secrets.ZAPBOT_TOKEN }} | gh auth login --with-token
59+
gh pr create --fill
60+
61+
fi

crontab.i18n

Lines changed: 0 additions & 3 deletions
This file was deleted.

crontab.test

Lines changed: 0 additions & 25 deletions
This file was deleted.

scans/wavsep/wavsep-score.js

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
// Score ZAP against WAVSEP
2+
3+
var DIR = "/zap/wrk/res/";
4+
var IGNORE_PATHS = [];
5+
6+
// Polyfill for Nashorn c/o https://stackoverflow.com/questions/47543566/scriptengine-javascript-doesnt-support-includes
7+
if (!Array.prototype.includes) {
8+
Object.defineProperty(Array.prototype, 'includes', {
9+
value: function(valueToFind, fromIndex) {
10+
if (this == null) {
11+
throw new TypeError('\"this\" is null or not defined');
12+
}
13+
var o = Object(this);
14+
var len = o.length >>> 0;
15+
if (len === 0) { return false; }
16+
var n = fromIndex | 0;
17+
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
18+
function sameValueZero(x, y) { return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y)); }
19+
while (k < len) { if (sameValueZero(o[k], valueToFind)) { return true; } k++; } return false;
20+
}
21+
});
22+
}
23+
24+
var totalUrls;
25+
var totalAlerts;
26+
27+
var FileWriter = Java.type('java.io.FileWriter');
28+
var PrintWriter = Java.type('java.io.PrintWriter');
29+
30+
root = org.parosproxy.paros.model.Model.getSingleton().
31+
getSession().getSiteTree().getRoot();
32+
33+
function nodeHasAlert(node, rules) {
34+
var alerts = node.getAlerts();
35+
for (var a in alerts) {
36+
var pluginId = alerts.get(a).getPluginId();
37+
if (rules.includes(pluginId)) {
38+
return pluginId;
39+
}
40+
}
41+
return null;
42+
}
43+
44+
function listChildren(pw, node, type, rules) {
45+
var j;
46+
for (j=0;j<node.getChildCount();j++) {
47+
var child = node.getChildAt(j);
48+
if (child.getChildCount() == 0) {
49+
var path = child.getHierarchicNodeName();
50+
if (path.indexOf(type) > -1 && path.indexOf("Case") > -1) {
51+
// All good
52+
} else {
53+
continue;
54+
}
55+
if (path.indexOf("POST") > -1 && child.getNodeName().startsWith("GET")) {
56+
continue;
57+
}
58+
if (! IGNORE_PATHS.includes(path)) {
59+
totalUrls++;
60+
pw.println('- path: ' + path);
61+
var pluginId = nodeHasAlert(child, rules);
62+
// Following test is JS equiv of XOR
63+
if (path.indexOf("FalsePositives") > 0 ? !pluginId : pluginId) {
64+
totalAlerts++;
65+
pw.println(' result: Pass');
66+
pw.println(' rule: ' + pluginId);
67+
} else {
68+
pw.println(' result: FAIL');
69+
pw.println(' rule: ' + rules[0]);
70+
}
71+
}
72+
} else {
73+
listChildren(pw, child, type, rules);
74+
}
75+
}
76+
}
77+
78+
function scoreChildren(file, name, type, rules) {
79+
var YAML_FILE = DIR + "/" + file + ".yml";
80+
var fw = new FileWriter(YAML_FILE);
81+
var pw = new PrintWriter(fw);
82+
83+
pw.println('section: ' + name);
84+
pw.println('url: ' + type);
85+
pw.println('details:');
86+
87+
totalUrls = 0;
88+
totalAlerts = 0;
89+
90+
91+
listChildren(pw, root, type, rules);
92+
93+
pw.println('tests: ' + totalUrls);
94+
pw.println('passes: ' + totalAlerts);
95+
pw.println('fails: ' + (totalUrls - totalAlerts));
96+
pw.println('score: ' + Math.round(totalAlerts * 100 / totalUrls) + '%');
97+
98+
pw.close();
99+
}
100+
101+
scoreChildren("dom-xss-get-exp", "DOM XSS GET Experimental", "/DXSS-Detection-Evaluation-GET-Experimental/", [40026]);
102+
103+
scoreChildren("lfi-get-200-err", "Local File Include GET 200 Error", "/LFI-Detection-Evaluation-GET-200Error/", [6]);
104+
scoreChildren("lfi-get-200-id", "Local File Include GET 200 Identical", "/LFI-Detection-Evaluation-GET-200Identical/", [6]);
105+
scoreChildren("lfi-get-200-valid", "Local File Include GET 200 Valid", "/LFI-Detection-Evaluation-GET-200Valid/", [6]);
106+
scoreChildren("lfi-get-302-redir", "Local File Include GET 302 Redirect", "/LFI-Detection-Evaluation-GET-302Redirect/", [6]);
107+
scoreChildren("lfi-get-400-err", "Local File Include GET 404 Error", "/LFI-Detection-Evaluation-GET-404Error/", [6]);
108+
scoreChildren("lfi-get-500-err", "Local File Include GET 500 Error", "/LFI-Detection-Evaluation-GET-500Error/", [6]);
109+
scoreChildren("lfi-post-200-err", "Local File Include POST 200 Error", "/LFI-Detection-Evaluation-POST-200Error/", [6]);
110+
scoreChildren("lfi-post-200-id", "Local File Include POST 200 Identical", "/LFI-Detection-Evaluation-POST-200Identical/", [6]);
111+
scoreChildren("lfi-post-200-valid", "Local File Include POST 200 Valid", "/LFI-Detection-Evaluation-POST-200Valid/", [6]);
112+
scoreChildren("lfi-post-302-redir", "Local File Include POST 302 Redirect", "/LFI-Detection-Evaluation-POST-302Redirect/", [6]);
113+
scoreChildren("lfi-post-404-err", "Local File Include POST 404 Error", "/LFI-Detection-Evaluation-POST-404Error/", [6]);
114+
scoreChildren("lfi-post-500-err", "Local File Include POST 500 Error", "/LFI-Detection-Evaluation-POST-500Error/", [6]);
115+
scoreChildren("lfi-get-fp", "Local File Include GET False Positives ", "/LFI-FalsePositives-GET/", [6]);
116+
117+
scoreChildren("rfi-get-200-err", "Remote File Include GET 200 Error", "/RFI-Detection-Evaluation-GET-200Error/", [7]);
118+
scoreChildren("rfi-get-200-id", "Remote File Include GET 200 Identical", "/RFI-Detection-Evaluation-GET-200Identical/", [7]);
119+
scoreChildren("rfi-get-200-valid", "Remote File Include GET 200 Valid", "/RFI-Detection-Evaluation-GET-200Valid/", [7]);
120+
scoreChildren("rfi-get-302-redir", "Remote File Include GET 302 Redirect", "/RFI-Detection-Evaluation-GET-302Redirect/", [7]);
121+
scoreChildren("rfi-get-404-err", "Remote File Include GET 404 Error", "/RFI-Detection-Evaluation-GET-404Error/", [7]);
122+
scoreChildren("rfi-get-500-err", "Remote File Include GET 500 Error", "/RFI-Detection-Evaluation-GET-500Error/", [7]);
123+
scoreChildren("rfi-post-200-err", "Remote File Include POST 200 Error", "/RFI-Detection-Evaluation-POST-200Error/", [7]);
124+
scoreChildren("rfi-post-200-id", "Remote File Include POST 200 Identical", "/RFI-Detection-Evaluation-POST-200Identical/", [7]);
125+
scoreChildren("rfi-post-200-valid", "Remote File Include POST 200 Valid", "/RFI-Detection-Evaluation-POST-200Valid/", [7]);
126+
scoreChildren("rfi-post-302-redir", "Remote File Include POST 302 Redirect", "/RFI-Detection-Evaluation-POST-302Redirect/", [7]);
127+
scoreChildren("rfi-post-400-err", "Remote File Include POST 404 Error", "/RFI-Detection-Evaluation-POST-404Error/", [7]);
128+
scoreChildren("rfi-post-402-err", "Remote File Include POST 500 Error", "/RFI-Detection-Evaluation-POST-500Error/", [7]);
129+
scoreChildren("rfi-get-fp", "Remote File Include GET False Positives", "/RFI-FalsePositives-GET/", [7]);
130+
131+
scoreChildren("rxss-cookie-exp", "Reflected XSS Cookie Experimental", "/RXSS-Detection-Evaluation-COOKIE-Experimental/", [40012]);
132+
scoreChildren("rxss-get", "Reflected XSS GET", "/RXSS-Detection-Evaluation-GET/", [40012]);
133+
scoreChildren("rxss-get-exp", "Reflected XSS GET Experimental", "/RXSS-Detection-Evaluation-GET-Experimental/", [40012]);
134+
scoreChildren("rxss-post", "Reflected XSS POST", "/RXSS-Detection-Evaluation-POST/", [40012]);
135+
scoreChildren("rxss-post-exp", "Reflected XSS POST Experimental", "/RXSS-Detection-Evaluation-POST-Experimental/", [40012]);
136+
scoreChildren("rxss-fps", "Reflected XSS GET False Positives", "/RXSS-FalsePositives-GET/", [40012]);
137+
138+
scoreChildren("sqli-get-200-err", "SQL Injection GET 200 Error", "/SInjection-Detection-Evaluation-GET-200Error/", [40018]);
139+
scoreChildren("sqli-get-200-err-exp", "SQL Injection GET 200 Error Experimental", "/SInjection-Detection-Evaluation-GET-200Error-Experimental/", [40018]);
140+
scoreChildren("sqli-get-200-id", "SQL Injection GET 200 Identical", "/SInjection-Detection-Evaluation-GET-200Identical/", [40018]);
141+
scoreChildren("sqli-get-200-valid", "SQL Injection GET 200 Valid", "/SInjection-Detection-Evaluation-GET-200Valid/", [40018]);
142+
scoreChildren("sqli-get-500-err", "SQL Injection GET 500 Error", "/SInjection-Detection-Evaluation-GET-500Error/", [40018]);
143+
scoreChildren("sqli-post-200-err", "SQL Injection POST 200 Error", "/SInjection-Detection-Evaluation-POST-200Error/", [40018]);
144+
scoreChildren("sqli-post-200-err-exp", "SQL Injection POST 200 Error Experimental", "/SInjection-Detection-Evaluation-POST-200Error-Experimental/", [40018]);
145+
scoreChildren("sqli-post-200-id", "SQL Injection POST 200 Identical", "/SInjection-Detection-Evaluation-POST-200Identical/", [40018]);
146+
scoreChildren("sqli-post-200-valid", "SQL Injection POST 200 Valid", "/SInjection-Detection-Evaluation-POST-200Valid/", [40018]);
147+
scoreChildren("sqli-post-500-err", "SQL Injection POST 500 Error", "/SInjection-Detection-Evaluation-POST-500Error/", [40018]);
148+
scoreChildren("sqli-get-fp", "SQL Injection GET False Positives", "/SInjection-FalsePositives-GET/", [40018]);
149+
150+
scoreChildren("redir-get-302", "Unvalidated Redirect GET 200", "/Redirect-Detection-Evaluation-GET-302Redirect/", [20019]);
151+
scoreChildren("redir-post-302", "Unvalidated Redirect POST 302", "/Redirect-Detection-Evaluation-POST-302Redirect/", [20019]);
152+
scoreChildren("redir-get-fp", "Unvalidated Redirect GET False Positives", "/Redirect-FalsePositives-GET/", [20019]);
153+
scoreChildren("redir-get-200-valid", "Unvalidated Redirect GET 200 Valid", "/Redirect-JavaScript-Detection-Evaluation-GET-200Valid/", [20019]);
154+
scoreChildren("redir-post-200-valid", "Unvalidated Redirect POST 200 Valid", "/Redirect-JavaScript-Detection-Evaluation-POST-200Valid/", [20019]);
155+
156+
print('Done');

0 commit comments

Comments
 (0)