Giter Club home page Giter Club logo

owasp-orb's Introduction

owasp-orb

A Circle CI orb using OWASP Dependency Check to check for components with known security-vulnerablities. Supported variants:

Usage

Import the orb

orbs:
  owasp: entur/[email protected]

where x is the latest version from the orb registry.

Default executor

To use the default executor, Docker Hub credentials must be set as the environment variables $DOCKERHUB_LOGIN and $DOCKERHUB_PASSWORD.

Gradle

Configure a job

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/gradle_owasp_dependency_check:
          executor: java_17
          context: global

Then add OWASP Gradle Plugin to your gradle build:

plugins {
    id 'org.owasp.dependencycheck' version '9.0.2'
}

dependencyCheck {
    analyzedTypes = ['jar'] // the default artifact types that will be analyzed.
    format = 'ALL' // CI-tools usually needs XML-reports, but humans needs HTML.
    failBuildOnCVSS = 7 // Specifies if the build should be failed if a CVSS score equal to or above a specified level is identified.
    suppressionFiles = ["$rootDir/owasp_suppressions.xml"] // specify a list of known issues which contain false-positives
    nvd {  
        apiKey = "${project.properties['NVD_API_KEY'] ?: System.env.NVD_API_KEY}"  
    }
}

where

  • suppressions (false positives) are assumed to be in owasp_suppressions.xml in the root of the project.
  • NVD_API_KEY is assumed to contain the NVD API Key via
    • ~/.gradle/gradle.properties, or
    • environment variable, or
    • command line parameter

Details

The default OWASP plugin task is dependencyCheckAnalyze, for using other tasks, add a task parameter as so:

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/gradle_owasp_dependency_check:
          executor: java_17
          context: global
          task: dependencyCheckAggregate

where task is one of dependencyCheckAnalyze, dependencyCheckAggregate, dependencyCheckUpdate, and dependencyCheckPurge.

Alternatively, use the wrapped_gradle_steps command to customize further.

Maven

Configure a job

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/maven_owasp_dependency_check:
          executor: java_17
          context: global

Then add OWASP Maven Plugin to your Maven build:

<plugin>
    <groupId>org.owasp</groupId>
    <artifactId>dependency-check-maven</artifactId>
    <version>9.0.2</version>
    <configuration>
        <format>all</format>
        <failBuildOnCVSS>7</failBuildOnCVSS>
        <nvdApiKey>${NVD_API_KEY}</nvdApiKey>
        <suppressionFiles>  
            <suppresionFile>${basedir}/owasp_suppressions.xml</suppresionFile>  
        </suppressionFiles>        
    </configuration>
    <executions>
        <execution>
            <!-- run only using explicit command -->
            <id>check</id>
            <phase>none</phase>
        </execution>
    </executions>
</plugin>
  • suppressions (false positives) are assumed to be in owasp_suppressions.xml in the root of the project.
  • NVD_API_KEY is assumed to contain the NVD API via
    • ~/.m2/settings.xml, or
    • environment variable, or
    • command line parameter

Configure NVD API Key on local machine

In ~/.m2/settings.xml, add

<profiles>
  <!-- ... -->
  <profile>
    <id>properties</id>
    <properties>
      <!-- other properties -->
      <NVD_API_KEY>YOUR KEY HERE</NVD_API_KEY>
    </properties>
  </profile>
</profiles>    

with

<activeProfiles>
  <!-- ... -->
  <activeProfile>properties</activeProfile>
</activeProfiles>

Details

The default OWASP plugin task is check, for using other tasks, add a task parameter as so:

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/maven_owasp_dependency_check:
          executor: java_17
          task: aggregate
          context: global

Maven multi-module projects

The dependency plugin currently is not able to resolve artifacts before they are built. If internal submodule dependencies cannot reached in the build, add a few wrapped_pre_steps to do so.

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/maven_owasp_dependency_check:
          executor: java_17
          context: global
          wrapped_pre_steps:
            - run:  mvn install -Dmaven.test.skip=true

Alternatively, use the wrapped_maven_steps command to customize further.

Command Line Tool

Configure a job

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/commandline_owasp_dependency_check:
          executor: java_17
          context: global

Details

The default OWASP arguments is --scan ./, for using other commands, add an arguments parameter as so:

workflows:
  version: 2.1
  build:
    jobs:
      - owasp/commandline_owasp_dependency_check:
          executor: java_17
          arguments: "--scan ./ --failOnCVSS 7 --suppression ./dependency-check-suppressions.xml --nvdApiKey $NVD_API_KEY"
          context: global

See the arguments page for further details. Note that --format, --data and --noupdate arguments are already appended by this orb (updating the database is performed in an individual previous step).

Use no_output_timeout parameter to avoid "Too long with no output (exceeded 10m0s): context deadline exceeded" error

Caching

The OWASP plugin checks for updates to its database every four hours, and the database is cached by the orb like so:

  • Year
  • Quarter (12 weeks)
  • Month (4 weeks)
  • Week
  • Day
  • 12 hours
  • 4 hours

So for each working day, the first builds (in the morning) will check for updates, and last for four hours with potential cache refreshes every four clock hours (at 9, 13, 17, 21 and so on). In other words, the OWASP plugin will check for updates whenever four hours have passed, and will be able to persist those updates to CircleCI cache in maximum four hours - a compromise between time spent saving cache and time spent checking for updates.

Data directory

Use the orb parameter cve_data_directory to configure non-standard data directory. Note that for Gradle builds this is necessary for plugin version <= 5.1.0.

Configuration examples (using default directories):

Gradle

dependencyCheck {
    data {
        // must correspond with CircleCI-configuration
        directory = System.properties['user.home'] + "/.gradle/dependency-check-data" 
    }
}

for cve_data_directory parameter value ~/.gradle/dependency-check-data.

Maven

<configuration>
    <!-- must correspond with CircleCI-configuration -->
    <dataDirectory>${user.home}/.m2/repository/org/owasp/dependency-check-data</dataDirectory>
</configuration>

for cve_data_directory parameter value ~/.m2/repository/org/owasp/dependency-check-data.

Further reading

See the orb source or CircleCI orb registry for further details.

owasp-orb's People

Contributors

paul-r0ss avatar pavloro avatar skjolber avatar tommybo-entur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owasp-orb's Issues

Support command-line equivalent

Dependency-check also has a command-line variant: https://jeremylong.github.io/DependencyCheck/dependency-check-cli/index.html

Support download of the latest version and running a scan; caching both the executable itself and data directory. Get latest executable doing something like

# Inspired by https://hub.docker.com/r/owasp/dependency-check/dockerfile
name: Install Owasp dependency check
working_directory: ~/
environment:
  OWASP_VERSION_URL: 'https://jeremylong.github.io/DependencyCheck/current.txt'
  OWASP_DOWNLOAD_URL: 'https://dl.bintray.com/jeremy-long/owasp'
command: |
  version=$(curl --silent $OWASP_VERSION_URL)
  wget -O owasp.zip "$OWASP_DOWNLOAD_URL/dependency-check-${version}-release.zip"
  unzip owasp.zip

Filter reports

Do NOT save empty or otherwise uninteresting reports as artifacts, if possible.

  • identify empty reports:
    • check csv number of lines
    • check for text string in html files
      • Check for "Vulnerable Dependencies: 0"
  • add option to only save HTML files as artifacts (no JSON, CSV etc)

JDK 17 support

Hi there,

Please add examples in the documentation in how to override the default JDK 11 configuration to supply JDK 17 and above.

Update: I did figure out how to define custom executors.

Please close, still think more info would help people who just want their stuff to keep running without circle-ci deep dive :)

Kind regards,

Cannot download Dependency-Check executable

When tried to use owasp/commandline_owasp_dependency_check, the following error was found and stopped the pipeline.

Downloading Dependency-Check executable version 6.1.2 from https://dl.bintray.com/jeremy-long/owasp/dependency-check-6.1.2-release.zip ..

Exited with code exit status 8
CircleCI received exit code 8

When tried to retrieve that URL, 404 is returned. It seems the binary is hosted on GitHub instead of Bintray, as in https://jeremylong.github.io/DependencyCheck/dependency-check-cli/index.html

In addition, I have tried to override executable_url with, then the orbs command can be executed successfully:

echo 'export executable_url=https://github.com/jeremylong/DependencyCheck/releases/download/vVERSION/dependency-check-VERSION-release.zip' >> $BASH_ENV

Allow additional steps run before dependency-check

When trying to scan JavaScript project with package-lock.json in the repository, run the commandline_owasp_dependency_check job makesdependency-check warn the absence of node_modules directory, as below:

[WARN] Analyzing `/home/circleci/project/package-lock.json` - however, the node_modules directory does not exist. Please run `npm install` prior to running dependency-check

It would be preferable to allow additional steps run before the command dependency-check.sh so that the node_modules directory can be populated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.