0
0
Expressframework~10 mins

Helmet for security headers in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import Helmet in an Express app.

Express
const express = require('express');
const [1] = require('helmet');
const app = express();
Drag options to blanks, or click blank then click option'
Ahelmet
Bexpress
Ccors
Dmorgan
Attempts:
3 left
💡 Hint
Common Mistakes
Importing 'express' instead of 'helmet'.
Forgetting to assign the require to a variable.
2fill in blank
medium

Complete the code to use Helmet middleware in the Express app.

Express
const app = express();
app.[1](helmet());
Drag options to blanks, or click blank then click option'
Ause
Blisten
Cget
Dpost
Attempts:
3 left
💡 Hint
Common Mistakes
Using app.listen instead of app.use.
Trying to use app.get or app.post for middleware.
3fill in blank
hard

Fix the error in the code to correctly set Helmet's contentSecurityPolicy option.

Express
app.use(helmet({ contentSecurityPolicy: [1] }));
Drag options to blanks, or click blank then click option'
A{}
Bfalse
C'default-src self'
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of false.
Passing true which enables default policy.
4fill in blank
hard

Fill both blanks to configure Helmet to disable frameguard and enable hsts with maxAge 1 year.

Express
app.use(helmet({ frameguard: [1], hsts: { maxAge: [2] } }));
Drag options to blanks, or click blank then click option'
Afalse
Btrue
C31536000
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using true to disable frameguard.
Setting maxAge to 0 which disables hsts.
5fill in blank
hard

Fill all three blanks to create a Helmet config that disables dnsPrefetchControl, enables referrerPolicy with 'no-referrer', and sets crossOriginEmbedderPolicy to true.

Express
app.use(helmet({ dnsPrefetchControl: [1], referrerPolicy: { policy: '[2]' }, crossOriginEmbedderPolicy: [3] }));
Drag options to blanks, or click blank then click option'
Afalse
Bno-referrer
Ctrue
Dstrict-origin
Attempts:
3 left
💡 Hint
Common Mistakes
Using true to disable dnsPrefetchControl.
Using wrong string for referrerPolicy.
Setting crossOriginEmbedderPolicy to false.