Git Product home page Git Product logo

oligo-code-scanner's Introduction

Oligo Code Scanner

Scanning your project on each pull request can help you keep vulnerabilities out of your project.

This GitHub Action utilizes Grype to compare a vulnerability scan of the target branch to a vulnerability scan of the feature branch, and will fail if there are new vulnerabilities found which do not exist in the target branch.

You will be notified of any new vulnerabilities introduced through the feature branch. You can also choose to prevent merging if new vulnerabilities are introduced through the feature branch.

Usage

In your project repository, create a new file .github/workflows/oligo-scanner-pr.yml (Adding to an existing workflow file is also possible).

Include the following in the file:

name: Oligo Vulnerability Scanner

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events
  pull_request:
    branches:
      - '**'

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:
  
jobs:
  scan-pr:
    name: Scan comparing base and comment on pr
    runs-on: ubuntu-latest
    outputs:
      json: ${{ steps.display.outputs.json }}
    steps:
      - name: Checkout the main branch repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: recursive
          token: ${{ secret }}
          path: main

      - name: Checkout base branch repository
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: recursive
          ref: ${{ github.event.pull_request.base.ref }}
          token: ${{ secret }}
          path: base

      - name: Scan both feature & main branches and compare output differences
        id: scan
        uses: OligoCyberSecurity/[email protected]
        continue-on-error: true
        with:
          path: './main'
          base-path: './base'
          fail-build: true
          severity-cutoff: high
          output-format: json

Examples

Oligo scanner saves the results in the jobs's outputs variable in JSON, SARIF, MD formats. You can use the result of Oligo scanner in order to comment on the PR, upload to the workflow Artifacts, or even open new GitHub Issue in your account.

Commenting PR]

alt text

Adding the next code to your workflow file will comment the results of the action in the PR:

      - name: Add Oligo scanning results on Pull-request
        if: ${{ steps.scan.outcome != 'success' }}
        uses: mshick/add-pr-comment@v1
        with:
          message: |
            New vulnerabilites detected:
            ${{steps.scan.outputs.markdown}}
          repo-token: ${{ secret }}
          allow-repeats: false # Set to true to comment on every run

Prevent Merging PR

Setting fail-build to true will cause the action to fail. In order to block PR from being merged when there is a new vulnerability, you need to change your repository setting and add a new status check.

Arguments

Argument Description Default Required Options
only-fixed Specify whether to only report vulnerabilities that have a fix available. false false, true
severity-cutoff Optionally specify the minimum vulnerability severity to trigger an "error" level ACS result. Any vulnerability with a severity less than this value will lead to a "warning" result. Default is "medium". medium negligible, low, medium, high, critical
output-format Set the output parameter after successful action execution. json json, sarif, table
fail-build Set to false to avoid failing based on severity-cutoff. true true, false
path The path of the checked-out feature branch to scan. . Any valid path
base-path The path of the target branch to scan. This is the path that will be used to resolve the difference with the feature branch code. . Any valid path

oligo-code-scanner's People

Contributors

nirdshabo1988 avatar fingeromer avatar

Stargazers

 avatar Ran Elbaz avatar  avatar  avatar Natan Quibech avatar  avatar Matan Dan avatar

Watchers

Nir avatar

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.