Software Component Analysis (SCA)
Maturity Model Level 1
Last updated
Maturity Model Level 1
Last updated
This analysis should run locally on each dev instance. How SCA tools work? SCA tools look for components/library/dependency files in the repository. Each dependency is crossed checked using its checksums with a database of vulnerable components. Every programming language has its own package/dependency manager and build tool.
Some build tools and dependency managers can be found in this table.
Language
Dependency Manager & Build tool
File
Python
pip
requirements.txt
node.js,
npm
package.json
java
rubygems
gemfile
java
maven
pom.xml
java
gradle
build.gradle
java
ant
.xml
haskell
cabal
.cabal
Fall under SAST. List available here and here:
We do not want to fail the builds in DevSecOps Maturity Levels 1 and 2. If a security tool fails a job, it won’t allow other DevOps jobs like release/deploy to run hence causing great distress to DevOps Team. Moreover, the security tools suffer from false positives. Failing a build on inaccurate data is a sure recipe for disaster. In gitlab pipelines one can use the allow_failure tag to not fail the build even though the tool found security issues.
Rule of thumb: only fail the build when CVSS score is lower than 7 and save the output preferably as JSON if available.
Let's play this locally: get the vulnerable web app on your machine/inside your container and enter its root folder
$ cd juice-shop
Install node js $
$ curl -sL https://deb.nodesource.com/setup_10.x | bash - $ apt install nodejs -y
Install the SCA tool
$ npm install -g retire
Run the scanner. The scanner will then scan the javascript libraries/depencies found in the package.json file:
$ cat package.json
Before running the scan, we need to install the npm packages available in the package.json file using the npm install command.
$ npm install
Run retire and store the result in a machine readable format.
$ retire --outputformat json --outputpath output.json
If that worked, we can now integrate the scanner into our build pipeline. We need to describe the steps we did locally in the build script. Note that we did not have to get an environment to run our tool locally, since it was our local computer. If we integrate the tool in a build pipeline we should get a docker image where we can run this tool. If you want, you can test this on your local machine first and do all of steps within a docker container. In the build script you need add a step to run the specific container first.
Integrate retirejs in the test stage of your build pipeline and allow failure. Create a .retireignore.json file in the root directory of your app if needed. If you don't have access to create it there you can pass a specific file using the option --ignorefile .myignorefile.json
Example of an integration in a gitlab CD/CI
We allow the failure in SCA analysis.
NPM has security build in since npm@6, this command allows you to analyze dependencies in your existing code to identify insecure dependencies, have a good security report, and also easy to implement it into CI/CD pipeline without install any packages except NPM itself.
install npm if not done
or update
install node js
apt install nodejs -y
npm audit --json > results.json
You should not run npm install before running the script because it will audit the package.js. If you want to break the build on failure you don't want to get the packages installed.
Safety is a SCA tool for python projects. Download a vulnerable python based webapp and enter the root older of project
git clone <your vulnerable web app> | cd <the root folder>
Install safety and tun checks
pip3 install safety
tee command to store the output in a file and print out simultaneously
safety check -r requirements.txt --json | tee safety_output.json
or only store in a file
safety check -r requirements.txt --json > safety_output.json
I did the practical devsecops certification and used their docker image to solve this.
If you choose to use open source scanners be sure they are safe.
To run the owasp tool you need the java runtime JRE on your executing machine. Install it if not existent.
export PATH=/opt/dependency-check/bin:$PATH
Run it
create a file inside the app repo and copy paste the following code to it
You'll execute the file within the test step in the pipeline:
auditjs audits npm packages and identifies outdated packages using the api from Sonatype.
Installation
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt install nodejs -y && npm install -g auditjs
Running the help tells us about different scans:
But before we can run it, we need to install the dependencies of the project with
npm install
auditjs ossi -q -j | tee auditjs-output.json
ls into the project folder of your ruby project and check the ruby version. You can use this app for testing git clone https://gitlab.practical-devsecops.training/pdso/rails.git webapp
cat Gemfile | grep "ruby"
Now install it according to your system. Don't forget to add ruby on your path with
Then install the gem for bundle-audit
Add bundle-audit to the path
Use it with
Ignore vulnerabilities with criticity high by adding .bundler-audit.yaml
to the repo
find the ruby version of your app and get a corresponding docker image on docker hub
Synk is a dependency analysis tool for many languages: Ruby, Python, NodeJS, Java, Go, .NET. You need to register an account in order to use it.
You can store it in the environment on your machine with
In your app folder, install the dependencies and then run the scan
Retire.js is a tool to analyse components in a nodejs project, by default based on the file package.json. The juiceshop application is based on nodejs. We'll use for SCA.
$ git clone
How can I be sure that my open source scanner does not contain malware? Either you rely on a community or you check-out the source code yourself and analyze the code. That's what github did
OWASP Dependency-Check is an open-source tool that checks dependencies for vulnerabilities of java projects. The tool is available on the owasp website here:
Checkout a vulnerability App written in Java.
Extract it and add the executable to the path so you can use it on the command line
Download sync at k and install it. Create an account and an auth token.