Skip to content

Commit 8300aeb

Browse files
committed
Tests for InsecureHelmet
1 parent 3a885ea commit 8300aeb

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| InsecureHelmetBad.js:7:5:7:32 | content ... : false | Helmet route handler, called with $@ set to 'false' | InsecureHelmetBad.js:7:5:7:32 | content ... : false | contentSecurityPolicy |
2+
| InsecureHelmetBad.js:8:5:8:21 | frameguard: false | Helmet route handler, called with $@ set to 'false' | InsecureHelmetBad.js:8:5:8:21 | frameguard: false | frameguard |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE-693/InsecureHelmet.ql
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const express = require("express");
2+
const helmet = require("helmet");
3+
4+
const app = express();
5+
6+
app.use(helmet({
7+
contentSecurityPolicy: false, // BAD: switch off default CSP
8+
frameguard: false // BAD: switch off default frameguard
9+
}));
10+
11+
app.get("/", (req, res) => {
12+
res.send("Hello, world!");
13+
});
14+
15+
app.listen(3000, () => {
16+
console.log("App is listening on port 3000");
17+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const express = require("express");
2+
const helmet = require("helmet");
3+
4+
const app = express();
5+
6+
app.use(helmet()); // GOOD: use the defaults
7+
8+
app.get("/", (req, res) => {
9+
res.send("Hello, world!");
10+
});
11+
12+
app.listen(3000, () => {
13+
console.log("App is listening on port 3000");
14+
});

0 commit comments

Comments
 (0)