-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
44 lines (41 loc) · 1.47 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; " />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CSP troubles</title>
</head>
<body>
<p>
Simple CSP policy, which allows to load scripts from origin and execute
all inline scripts
</p>
<code>default-src 'self'; script-src 'self' 'unsafe-inline'</code>
<p>Tip: Open DevTools on the Console tab</p>
<a href="csp-hashed-scripts.html">CSP hashed scripts page</a>
<h2>Demo</h2>
<form action="#" style="width: 250px;">
<fieldset>
<legend>inline script</legend>
<span id="inline-script" style="color: red;">disabled</span>
</fieldset>
<fieldset>
<legend>/root-script.js</legend>
<span id="root-external-script" style="color: red;">disabled</span>
</fieldset>
<fieldset>
<legend>/folder/non-root-script.js</legend>
<span id="non-root-external-script" style="color: red;">disabled</span>
</fieldset>
</form>
<script>
const el = document.getElementById("inline-script");
el.innerText = "Ok";
el.style.color = "green";
console.log("inline script is allowed!");
</script>
<script src="root-script.js"></script>
<script src="folder/non-root-script.js"></script>
</body>
</html>