How to Scan a Node.js App for Security Vulnerabilities with Code Risk Analyzer

2 min read

In this article, we'll show you how you can quickly set up Code Risk Analyzer to scan a simple Node.js app in your Git repo.

Code Risk Analyzer — a part of IBM Cloud Continuous Delivery — takes all of your Git-based code, configurations and deployment artifacts, builds a dependency graph and runs a pipeline of regulatory compliance control checks. It is embedded into existing development workflows, such as creating a change request or promoting a code change into the main development branch. It integrates the comprehensive security coverage and rich threat intelligence provided by Snyk and other sources to help developers automatically find, prioritize and fix vulnerabilities in open-source dependencies and containers, early in their workflow.

Setting up your toolchain

Code Risk Analyzer supports the Java™, Node.js and Python languages. For Node.js, dependencies are calculated by using the following files:

  • package-lock.json: The purpose of the file is to provide a manifest that calls out the exact version of every package in your tree the last time you ran npm install. It's this file that Code Risk Analyzer uses to identify package dependencies in your code.
  • deployment.yml: This file specifies all the parameters involved in deploying your application to the Kubernetes cluster. This file is scanned for any misconfigurations or potential security or compliance issues, based on community and industry standards.
  • dockerfile: A dockerfile is a recipe for building Docker images, and the act of running a build command produces the image from that recipe. Code Risk Analyzer scans the dockerfile for OS and image dependencies which are then checked against known vulnerabilities.

To scan your repository, follow these steps (for more details, see the Code Risk Analyzer documentation):

  1. Use the Build your own toolchain template to create an empty toolchain. Note that currently, Code Risk Analyzer is available only in the Dallas region.
  2. Add the DevOps Insights tool integration to the toolchain.
  3. Add the code repo that contains the code you want to scan to the toolchain. For example, add a GitHub or GitLab repo.
  4. Create an API key to authenticate with Code Risk Analyzer.
  5. Create and configure a Tekton pipeline.
  6. Create a new Merge/Pull request in your repo. When the request is submitted, Code Risk Analyzer will automatically run a Tekton delivery pipeline to scan your repo. 
  7. Results of the scan will be shown in your Merge/Pull Request. 

Watch the how-to video

More resources and getting started

Code Risk Analyzer is included as part of IBM Cloud Continuous Delivery and is available in the IBM Cloud Dallas (US-South) region.

  • Read the IBM Research blog on Code Risk Analyzer.
  • For more information on Code Risk Analyzer, see the documentation
  • If you have any questions, get help directly from the IBM Cloud development teams by joining us on Slack.

Be the first to hear about news, product updates, and innovation from IBM Cloud