Skip to content

Commit e429708

Browse files
committed
added functionality to sanitize user data using xss-clean and used helmet's contentSecurityPolicy to mitigate cross-site-scripting
1 parent 51c4ef5 commit e429708

File tree

3 files changed

+2041
-2
lines changed

3 files changed

+2041
-2
lines changed

app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ require("dotenv").config();
77
const tasks = require("./routes/api/tasks");
88
const users = require("./routes/api/users");
99
const auth = require("./routes/api/auth");
10-
10+
const xss = require("xss-clean");
11+
const helmet = require("helmet");
1112
const app = express();
1213

1314
/* ------------- Middleware ----------------*/
15+
app.use(helmet.contentSecurityPolicy());
1416
app.use(bodyParser.urlencoded({ extended: false }));
1517
app.use(bodyParser.json());
1618
app.use(cors());
19+
app.use(xss());
1720

1821
/*---------- A simple CORS implementation ---------------------*/
1922
// app.use((req, res, next) => {

0 commit comments

Comments
 (0)