Information Security with HelmetJS - Install and Require Helmet

**Tell us what’s happening: **

I’m afraid I don’t know where to start. I’ve imported the project into Replit, “Use Run Command” was already selected, so I clicked “Done”. That’s when I first started having problems figuring out what to do next. I looked into some of the other posts and came across a response to type “npm install” into the console, so that’s what I did. I also accessed the replit of the woman that posted that same inquiry and copied her code into my Replit. My URL still fails the test. I’m stuck at this point.

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.69

Challenge: Information Security with HelmetJS - Install and Require Helmet

Link to the challenge:

That is not how you bring in dependencies. Use require as it is done with the express dependency.

const express = require('express');

Replace the variable and string with helmet

const someVariable = require('somePackageName');

Also, post your Replit when asking for help.

Ok. I tried that, but my URL is still failing. Here’s what it shows after I replaced the variable and string with ‘helmet’.

boilerplate-infosec (2) - Replit

Your repl is now throwing an error because you’re no longer using require to bring in your express dependency.
You need to require both express and helmet, separately.

Read the error message. How are you supposed to call express when it doesn’t exist in the code?

There is nothing magical about import/export. The export exports out some code, and the import (or require) brings in that code. You can not reference a function that doesn’t exist in the code.


As said, you need to require both express and helmet to be able to use them.

Still not working. Never mind. I appreciate the help guys.

Please update your Replit with your latest code. What you have now in the Replit you linked to is still not correct.

Added Helmet dependency - Run - Done - no vulnerabilities.

Is that the “working demo” that needs to be “hosted somewhere public” ? … and the URL to it submitted in the “Solution Link” field?

If so, how do I get the “working demo” hosted? Does it require some paid deployment - which in essence means whilst the challenge is free to do, it cannot be completed unless deployed (paid) - otherwise no URL to submit in the “Solution Link” field - is this interpretation correct?

If not, what needs to be done to get a “working demo” without deployment so it can be uploaded to some server visible online? …and then be able to put the URL to it in that Solution Link field to complete the challenge.

Any insight/help/answer is greatly appreciated.
Thanks.

Use the Replit boilerplate linked to in the challenge.

Add your code and run it. Now click the “New tab” button in the top right of the preview window. Use that URL for the submission.

Thanks for the tip.

Used Replit - Run - returns 0 vulnerabilities - looked for “New tab” (does nothing other than open a tab) - used the URL that was currently in the URL field of the browser when the project was “Run” in Replit and pasted that into the Solution Link field - clicked “…completed challenge” and the test result below that flagged the error as shown - says ’ helmet version 3.21.3 should be in package.json - but it is, has always been … came with the boiler-plate!

(please see attached pic)

Should be a straightforward 1-2-3 step if all it required was to embed the Helmet dependency in “myApp.js” and then Run it - turns out to be quite a challenge - maybe we missed something - grateful for any other insight/help into this. Thanks.

You will have to post a link to your Replit if you need help with the code.

Check the version didn’t change and maybe make sure the version number does not have any tilde (~) or caret (^) in front of it (can’t remember if it matters or not, but it might).

First, thank you for taking the time to look at this.

As mentioned earlier, the Helmet dependency (and version) was already in package.json as-is - came with the boiler-plate; the only ‘coding’ done was to call it (require) in myApp.js which was done (could be where the mistake is) - can you take a look at the screenshots attached.

Thanks a bundle! Have a nice weekend!

I know this is a very late reply.

You can’t redeclare app and app should be express, not helmet.

You should not run helmet. In the next challenges you will use it as middleware app.use(someMiddleware()). All you have to do is require it for now.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.