Skip to main content

Fully open-source security audit for project dependencies based on known vulnerabilities and advisories.

Project description

Introduction

  ___            _____ _                    _
 / _ \          |_   _| |                  | |
/ /_\ \_ __  _ __ | | | |__  _ __ ___  __ _| |_
|  _  | '_ \| '_ \| | | '_ \| '__/ _ \/ _` | __|
| | | | |_) | |_) | | | | | | | |  __/ (_| | |_
\_| |_/ .__/| .__/\_/ |_| |_|_|  \___|\__,_|\__|
      | |   | |
      |_|   |_|

dep-scan is a fully open-source security audit tool for project dependencies based on known vulnerabilities, advisories and license limitations. The output is compatible with grafeas. The tool is ideal for CI environments with built-in build breaker logic.

Docker Repository on Quay

Features

  • Package vulnerability scanning is performed locally and is quite fast. No server is used!
  • Configurable cache and sync functionality to manage local cache data
  • Pre-installed and integrated with sast-scan
  • (Alpha) Reports packages with license limitations (such as copyleft)

Known issue:

Usage

dep-scan is ideal for use during continuous integration (CI) and also as a tool for local development.

Use with sast-scan

dep-scan is integrated with sast-scan, a free and open-source SAST tool. To enable this feature simply pass depscan to the --type argument. See here for an example.

---
--type python,depscan,credscan

This approach should work for all CI environments supported by sast-scan.

Scanning projects locally (Python version)

npm install -g @appthreat/cdxgen
pip install appthreat-depscan

This would install two commands called cdxgen and scan.

You can invoke the scan command directly with the various options.

cd <project to scan>
scan --src $PWD --report_file $PWD/reports/depscan.json

Scanning projects locally (Docker container)

appthreat/dep-scan or quay.io/appthreat/dep-scan container image can be used to perform the scan.

To scan with default settings

docker run --rm -v $PWD:/app appthreat/dep-scan scan --src /app --report_file /app/reports/depscan.json

To scan with custom environment variables based configuration

docker run --rm \
    -e VULNDB_HOME=/db \
    -e NVD_START_YEAR=2010 \
    -e GITHUB_PAGE_COUNT=5 \
    -e GITHUB_TOKEN=<token> \
    -v /tmp:/db \
    -v $PWD:/app appthreat/dep-scan scan --src /app --report_file /app/reports/depscan.json

In the above example, /tmp is mounted as /db into the container. This directory is then specified as VULNDB_HOME for caching the vulnerability information. This way the database can be cached and reused to improve performance.

Supported languages and package format

dep-scan uses cdxgen command internally to create Software Bill-of-Materials (SBoM) file for the project. This is then used for performing the scans.

The following projects and package-dependency format is supported by cdxgen.

Language Package format
node.js package-lock.json
java (*) maven (pom.xml), gradle (build.gradle)
python requirements.txt, Pipfile.lock, poetry.lock
go go.sum, Gopkg.lock
rust Cargo.lock
.Net core .csproj

NOTE

The docker image for dep-scan currently doesn't bundle suitable java and maven commands required for bom generation. To workaround this limitation, you can -

  1. Use python-based execution from a VM containing the correct versions for java, maven and gradle.
  2. Generate the bom file by invoking cdxgen command locally and subsequently passing this to dep-scan via the --bom argument.

Integration with CI environments

Integration with Azure DevOps

Refer to this example yaml configuration for integrating dep-scan with Azure Pipelines. The build step would perform the scan and display the report inline as shown below:

Azure DevOps integration

Integration with GitHub Actions

This tool can be used with GitHub Actions using this action.

This repo self-tests itself with both sast-scan and dep-scan! Check the GitHub workflow file of this repo.

- name: Self dep-scan
  uses: AppThreat/dep-scan-action@master
  env:
    VULNDB_HOME: ${{ github.workspace }}/db
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Customisation through environment variables

The following environment variables can be used to customise the behaviour.

  • VULNDB_HOME - Directory to use for caching database. For docker based execution, this directory should get mounted as a volume from the host
  • NVD_START_YEAR - Default: 2018. Supports upto 2002
  • GITHUB_PAGE_COUNT - Default: 2. Supports upto 20

GitHub Security Advisory

To download security advisories from GitHub, a personal access token with the following scope is necessary.

  • read:packages
export GITHUB_TOKEN="<PAT token>"

License scan (alpha)

dep-scan can automatically scan the dependencies for any license limitations and report them directly on the console log. The licenses data is sourced from choosealicense.com and is quite limited. If the license of a given package cannot be reliably matched against this list it will get silently ignored to reduce any noise. This behaviour could change in the future once the detection logic gets improved.

License scan

Alternatives

Dependency Check is considered to be the industry standard for open-source dependency scanning. After personally using this great product for a number of years I decided to write my own from scratch partly as a dedication to this project. By using a streaming database based on msgpack and using json schema, dep-scan is more performant than dependency check in CI environments. Plus with support for GitHub advisory source and grafeas report export and submission, dep-scan is on track to become a next-generation dependency audit tool

There are a number of other tools that piggy back on Sonatype ossindex API server. For some reason, I always felt uncomfortable letting a commercial company track the usage of various projects across the world. dep-scan is therefore 100% private and guarantees never to perform any tracking!

Project details


Release history Release notifications | RSS feed

This version

1.2.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

appthreat-depscan-1.2.0.tar.gz (133.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

appthreat_depscan-1.2.0-py3-none-any.whl (179.4 kB view details)

Uploaded Python 3

File details

Details for the file appthreat-depscan-1.2.0.tar.gz.

File metadata

  • Download URL: appthreat-depscan-1.2.0.tar.gz
  • Upload date:
  • Size: 133.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for appthreat-depscan-1.2.0.tar.gz
Algorithm Hash digest
SHA256 876cd82df3f7b54e152b002935498bf1579f89eb861f43d5095234b6e7147041
MD5 b3cf7dc1d5262325f05fff84510679e0
BLAKE2b-256 22786157c482479f76ea9fd77c78e98ff4f1067c96af8b0cb18c8e70979f800c

See more details on using hashes here.

File details

Details for the file appthreat_depscan-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: appthreat_depscan-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 179.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for appthreat_depscan-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 891d165b12c1abd1b4ce0c01d63eb087c36c941838363f314ae1ee8cf48a7e52
MD5 db99cb7b1e2f1daf327c6d574d17ce2a
BLAKE2b-256 a5704fbec9e7359786e901bf16de6f8f9ca793daca8ef80f199ce57579e07a50

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page