-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecurity-check.sh
More file actions
executable file
·85 lines (73 loc) · 2.53 KB
/
Copy pathsecurity-check.sh
File metadata and controls
executable file
·85 lines (73 loc) · 2.53 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/sh
set -eu
cd "$(dirname "$0")"
node --check app.js
html_files="$(find . -maxdepth 1 -name "*.html" -type f | sort)"
css_files="$(find . -maxdepth 1 -name "*.css" -type f | sort)"
if find . -maxdepth 2 \( \
-name ".DS_Store" -o \
-name ".env" -o \
-name ".env.*" -o \
-name ".playwright-cli" -o \
-name ".wrangler" -o \
-name "output" -o \
-name "*.crt" -o \
-name "*.key" -o \
-name "*.log" -o \
-name "*.pem" -o \
-name "*.trace" -o \
-name "*.zip" \
\) | grep -q .; then
echo "Security check failed: local artifacts or secret-like files found in deploy directory."
exit 1
fi
if rg -n '<script(?! src=)|<style>|\son[a-z]+=' $html_files --pcre2; then
echo "Security check failed: inline executable content found."
exit 1
fi
if rg -n 'fetch\(|XMLHttpRequest|WebSocket|EventSource|sendBeacon|localStorage|sessionStorage|indexedDB|document\.cookie|serviceWorker|clipboard\.read|innerHTML|outerHTML|insertAdjacentHTML|eval\(|new Function|postMessage|BroadcastChannel|SharedWorker|Worker\(' app.js; then
echo "Security check failed: forbidden network, storage, or clipboard-read API found."
exit 1
fi
if rg -n 'https?://|//[a-z0-9.-]+\.[a-z]{2,}' $html_files $css_files --ignore-case \
| rg -v 'https://wrapdeck\.app(/|")'; then
echo "Security check failed: unexpected remote asset or URL found in runtime files."
exit 1
fi
if rg -n "unsafe-inline|unsafe-eval|data:|blob:" $html_files _headers; then
echo "Security check failed: CSP contains an unsafe source."
exit 1
fi
for required in \
"default-src 'none'" \
"script-src 'self'" \
"style-src 'self'" \
"connect-src 'none'" \
"frame-ancestors 'none'" \
"Cache-Control: no-store" \
"no-transform" \
"Cross-Origin-Embedder-Policy: require-corp" \
"X-Content-Type-Options: nosniff" \
"X-Frame-Options: DENY" \
"Referrer-Policy: no-referrer" \
"Permissions-Policy:" \
"X-Robots-Tag: noindex"; do
if ! grep -Fq "$required" _headers; then
echo "Security check failed: missing header: $required"
exit 1
fi
done
if [ ! -f ".well-known/security.txt" ]; then
echo "Security check failed: missing .well-known/security.txt"
exit 1
fi
for required_security_txt in \
"Contact: https://wrapdeck.app/security.html" \
"Policy: https://wrapdeck.app/security.html" \
"Canonical: https://wrapdeck.app/.well-known/security.txt"; do
if ! grep -Fq "$required_security_txt" .well-known/security.txt; then
echo "Security check failed: missing security.txt field: $required_security_txt"
exit 1
fi
done
echo "WrapDeck security checks passed."