-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
164 lines (112 loc) · 4.68 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Content Security Policy (CSP) demo</title>
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<h1>Content Security Policy (CSP) demo</h1>
<p> </p>
<div class="well">
Open the <code>Console</code> tab on <code>Developer Tools</code> to see CSP violations.
</div>
<p> </p>
<hr/>
<p> </p>
<h2>Stylesheets</h2>
<div class="alert alert-success">
The Bootstrap styles & fonts <strong>should load</strong> because <code>bootstrapcdn.com</code> and <code>*.bootstrapcdn.com</code>
are whitelisted on the <code>style-src</code> and <code>font-src</code> directives.
</div>
<p> </p>
<hr/>
<p> </p>
<h2>Scripts</h2>
<div class="alert alert-success">
The jQuery & Bootstrap scripts <strong>should load</strong> because <code>bootstrapcdn.com</code>, <code>*.bootstrapcdn.com</code>,
<code>googleapis.com</code>, and <code>*.googleapis.com</code> are whitelisted on the <code>style-src</code> and
<code>font-src</code> directives.
</div>
<p> </p>
<hr/>
<p> </p>
<h2>Images</h2>
<div class="alert alert-success">
The image below <strong>should load</strong> because <code>imgur.com</code> and <code>*.imgur.com</code> are
whitelisted on the <code>img-src</code> directive.
</div>
<img src="http://i.imgur.com/Qq74GNT.jpg" height="80" alt="Aladeen"/>
<p> </p>
<div class="alert alert-warning">
The image below <strong>should NOT load</strong> because <code>*.9cache.com</code> is not whitelisted on the
<code>img-src</code> directive.
</div>
<img src="https://img-9gag-fun.9cache.com/photo/axVWrDK_460s.jpg" height="80" alt="Godzilla vs King Kong"/>
<p> </p>
<hr/>
<p> </p>
<h2>Forms</h2>
<div class="alert alert-success">
The form below <strong>should submit</strong> because <code>'self'</code> is whitelisted on the
<code>form-action</code> directive.
</div>
<form action="/">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your name"/>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit" placeholder="Your name"/>
</div>
</form>
<p> </p>
<div class="alert alert-warning">
The form below <strong>should NOT submit</strong> because <code>*.google.com</code> is not whitelisted on the
<code>form-action</code> directive.
</div>
<form action="http://www.google.com/">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your name"/>
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Submit" placeholder="Your name"/>
</div>
</form>
<p> </p>
<hr/>
<p> </p>
<h2>IFrames</h2>
<div class="alert alert-warning">
This page <strong>should not be embeddable</strong> on other sources because <code>'none'</code> is the value
specified on the <code>frame-ancestors</code> directive.
</div>
<p> </p>
<hr/>
<p> </p>
<h2>AJAX</h2>
<div class="alert alert-success">
This button <strong>should get an API response</strong> because <code>pokeapi.co</code> is whitelisted the <code>connect-src</code> directive.
</div>
<button class="btn btn-info" id="pokeapi">Get a pokeapi.co API response</button>
<p> </p>
<div class="alert alert-warning">
This button <strong>should not get an API response</strong> because <code>swapi.co</code> is not
whitelisted on the <code>connect-src</code> directive.
</div>
<button class="btn btn-info" id="swapi">Get a swapi.co API response</button>
<p> </p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="./scripts.js"></script>
</body>
</html>