Deploying AcuSensor for Node.js - AWS Elastic Beanstalk
🔍 AcuSensor Network PreRequisites |
AcuSensor makes use of the AcuSensor Bridge. Read more information here. |
The following article shows you how you can run a Node.js application in AWS Elastic Beanstalk and then use AcuSensor to run an interactive application security testing (IAST) scan for that application.
🔍 Supported Servers and Frameworks |
See the manual page Deploying AcuSensor for .Node.js for information regarding supported servers and frameworks. |
Create your Target in Acunetix
For this example, we will assume that the URL for your target is http://eb.acunetixexample.com. Create a target with your URL, enable AcuSensor, download the AcuSensor agent file node-acusensor.tar, and save this file for use later on.
Create your application source code bundle
This simple web application will be defined through the following file structure:
~/axexample-nodejs/ ~/axexample-nodejs/app.js ~/axexample-nodejs/package.json ~/axexample-nodejs/node-acusensor.tar |
- Create your /axexample-nodejs/app.js file to read as follows:
const app = require('express')(); var port = process.env.PORT || 60000; app.get('/', function (req, res) { res.send( '<html><body>' + '<h1>Test Node.js Site Example for AWS Elastic Beanstalk</h1>' + '<br>' + 'Hello World! - Main Page' + '<br>' + '<a href="/page1">Goto Page 1</a>' + '</body></html>' ); }); app.get('/page1', function (req, res) { res.send( '<html><body>' + '<h1>Test Node.js Site Example for AWS Elastic Beanstalk</h1>' + '<br>' + 'Hello World! - Page 1' + '<br>' + '<a href="/">Goto Main Page</a>' + '</body></html>' ); }); app.listen(port, function(err){ if (err) console.log(err); console.log("Server listening on port: ", port); }); |
- Create your /axexample-nodejs/package.json file to read as follows:
{ "name": "axexample-nodejs", "version": "1.0.0", "dependencies": { "express": "*", "node-acusensor": "file:node-acusensor.tar" }, "scripts": { "start": "npx node-acusensor.tar app.js" } } |
- Copy the node-acusensor.tar file you created earlier into ~/axexample-nodejs/node-acusensor.tar.
- Finally, build the source code bundle with:
cd ~/axexample-nodejs zip -rq axexample-nodejs.zip . |
- Download your acunetix-nodejs.zip file to your desktop and retain your zip file for deployment steps below
Deploy your web application to AWS Elastic Beanstalk
- From your AWS Dashboard, navigate to Elastic Beanstalk -> Environments
- Click the Create a new environment button
- Set your environment tier to Web server environment
- Click the Select button
- In the Elastic Beanstalk -> Create environment page:
- Set the Application name field to the name for your web application; in this example you will use the name axexample-nodejs
- Set the Platform dropdown to Node.js
- Enable the Upload your code option and click the Choose file button
- Select your axexample-nodejs.zip source code bundle for upload and click the Create environment button
- AWS Elastic Beanstalk will now create your environment; this can take a few minutes
- When the process is complete you will be sent to your environment's dashboard
- Take note of your environment's new URL which was created automatically by AWS Elastic Beanstalk:
- you will need this to create a CNAME to point to this URL
- in this example, we would create a CNAME for eb.acunetixexample.com to point to axexamplenodejs-env.eba-affkbc2q.us-east-1.elasticbeanstalk.com; here is an example using the Namecheap cPanel interface:
- Once the CNAME record has been added (giving time for DNS records to propagate), you can see the web application you have created by browsing to your URL (in this example http://eb.acunetixexample.com):
Test and scan your web application
Point your browser to your web application - in this example http://eb.acunetixexample.com - to confirm it is running as intended; you will get the following:
Finally, run a scan on your target; the Activity panel will confirm that AcuSensor was detected and used for the scan.