Skip to content

Commit da9e1e6

Browse files
committed
Moved examples into separate files
1 parent 7ee5655 commit da9e1e6

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

javascript/ql/src/Security/CWE-693/InsecureHelmet.qhelp

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,38 +51,19 @@ data:
5151
The following code snippet demonstrates Helmet configured in an insecure manner:
5252
</p>
5353

54-
<pre>
55-
const helmet = require('helmet');
56-
app.use(helmet({
57-
frameguard: false,
58-
contentSecurityPolicy: false
59-
}));
60-
</pre>
54+
<sample src="examples/helmet_insecure.js" />
6155

6256
<p>
6357
In this example, the defaults are used, which enables frame protection and a default Content Security Policy.
6458
</p>
6559

66-
<pre>
67-
app.use(helmet());
68-
</pre>
60+
<sample src="examples/helmet_default.js" />
6961

7062
<p>
7163
You can also enable a custom Content Security Policy by passing an object to the <code>contentSecurityPolicy</code> key. For example, taken from the <a href="https://helmetjs.github.io/#content-security-policy">Helmet docs</a>:
7264
</p>
7365

74-
<pre>
75-
app.use(
76-
helmet({
77-
contentSecurityPolicy: {
78-
directives: {
79-
"script-src": ["'self'", "example.com"],
80-
"style-src": null,
81-
},
82-
},
83-
})
84-
);
85-
</pre>
66+
<sample src="examples/helmet_custom.js" />
8667

8768
</example>
8869
<references>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
app.use(
2+
helmet({
3+
contentSecurityPolicy: {
4+
directives: {
5+
"script-src": ["'self'", "example.com"],
6+
"style-src": null,
7+
},
8+
},
9+
})
10+
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app.use(helmet());
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const helmet = require('helmet');
2+
3+
app.use(helmet({
4+
frameguard: false,
5+
contentSecurityPolicy: false
6+
}));

0 commit comments

Comments
 (0)