Deploying AcuSensor for Node.js - AWS Elastic Beanstalk

AcuSensor Network Prerequisites

AcuSensor makes use of the AcuSensor Bridge. For more information, refer to the AcuSensor Bridge documentation.

This guide explains 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.

There are four steps to these instructions:

  1. Create your Target in Acunetix
  2. Create your application source code bundle
  3. Deploy your web application to AWS Elastic Beanstalk
  4. Test and scan your web application

Supported Servers and Frameworks

Before deploying AcuSensor, note the list of supported servers and frameworks available in the Deploying AcuSensor for Node.js documentation.

Step 1: Create your Target in Acunetix

For this example, we will assume that the URL for your Target is http://eb.acunetixexample.com.

  1. Create a Target in Acunetix with your URL. 
  2. Enable AcuSensor on the Target Settings page. 
  3. Download the AcuSensor agent file node-acusensor.tar and save this file for use later on.

Step 2: 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

  1. 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);

});

  1. 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"

  }

}

  1. Copy the node-acusensor.tar file you created earlier into ~/axexample-nodejs/node-acusensor.tar.

  1. Finally, build the source code bundle with:

cd ~/axexample-nodejs

zip -rq axexample-nodejs.zip .

  1. Download your acunetix-nodejs.zip file to your desktop and retain the zip file for the deployment steps below.

Step 3: Deploy your web application to AWS Elastic Beanstalk

  1. From your AWS Dashboard, navigate to Elastic Beanstalk > Environments.

  1. Click Create a new environment.

  1. Set your environment tier to Web server environment, then click Select.

  1. Set the Application name field to the name for your web application. (In this example we have used the name axexample-nodejs).

  1. Set the Platform dropdown to Node.js.

  1. Select the Upload your code option, then click Choose file.

  1. Select your source code bundle for upload and click Create environment. AWS Elastic Beanstalk will now create your environment. This can take a few minutes.

  1. 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.

  1. Create a CNAME for your URL to point to the new URL THAT was created automatically by AWS Elastic Beanstalk. In our example below we used the Namecheap cPanel interface to point  eb.acunetixexample.com to axexamplenodejs-env.eba-affkbc2q.us-east-1.elasticbeanstalk.com.

  1. 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).

Step 4: Test and scan your web application

  1. 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:

  1. Finally, run a scan on your Target. The Activity panel in the Scan Information will confirm that AcuSensor was detected and used for the scan.

 

« Back to the Acunetix Support Page