GithubHelp home page GithubHelp logo

magmanu / zaproxy-to-ghas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svanboxel/zaproxy-to-ghas

0.0 0.0 0.0 2.11 MB

Present ZAProxy results in GitHub Advanced Security

License: MIT License

JavaScript 3.31% TypeScript 96.69%

zaproxy-to-ghas's Introduction

Present ZAProxy results in GitHub Advanced Security

Use this GitHub Action together with GitHub Advanced Security to run a ZAProxy (DAST) scan on your application, and present the results in the GitHub Advanced Security UI.

This Action leverages the official zaproxy/action-baseline Action which supports various options like custom rule sets and target url.

Table of contents

Background

GitHub Advanced Security utilizes the SARIF (Static Analysis Results Interchange) format to present code scanning results of a wide range of static code analysis tools. As DAST scans are not static they can't be directly mapped to individual lines in the original source file but only to a specific URL or endpoint of the application.

This Actions maps the DAST results of ZAProxy to SARIF on a best effort basis to ensure developers get the DAST-related information they need to make informed decisions about the security risks in an application.

What is looks like

After the scan completes, all results are presented in the Security -> Code Scanning Alerts tab, which allows users to filter for specific security tools, rules, and branches:

Screenshot 2021-09-27 at 10 23 26

All results that fall under the same rule are captured within a single overview:

Screenshot 2021-09-27 at 10 23 52

๐Ÿ’ก Previews are not available as DAST scans can't map a scan result to a specific file in the repository.

Getting started

Required permissions

To use this Action you need to have the following permissions:

permissions:
  security_events: write
  repository_contents: read
  actions: read

Use with (public-facing) URLs

The easiest way to get started is by running this scan against a URL that is publicly available. Or, in case you use self-hosted Action runners, that is available within the network of your runner.

Example workflow:

name: ZAProxy scan

on:
  push:
    branches: [ main ]
  workflow_dispatch:

jobs:
  dast-scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: ZAP Scan
        uses: zaproxy/[email protected]
        with:
          target: 'https://www.zaproxy.org' # Target url for the scan
      - name: Create sarif file from zaproxy results
        uses: SvanBoxel/zaproxy-to-ghas@main
      - name: Upload SARIF file
        uses: github/codeql-action/upload-sarif@v1
        with:
          sarif_file: results.sarif

When running this workflow the following happens:

  • First, the code is checked out.
  • Then, it runs the ZAProxy scan on a defined target url.
  • After the scan completes, it runs this Action to map the ZAProxy results to SARIF.
  • Finally, it uploads the results to GitHub.

Results can be manually inspected by downloading the zap_scan artifact that contains the original scan results, and ZAProxy-sarif-report which contains the SARIF output of the scan.

Screenshot 2021-09-27 at 11 47 17

Use with containers

If your application leverages containers you have another option for deploying and scanning with DAST. After you deploy your docker to a container registry, you can use the image as a service in the context of your workflow.

Example workflow:

name: ZAProxy scan

on:
  push:
    branches: [ main ]
  workflow_dispatch:

jobs:
  build-image:
    ## Build your image here
  publish-image:
    ## Publish your image to a container registry here
  dast-scan:
    services:
      website:
        image: yeasy/simple-web # Point to the container image of your application
        ports:
          - 80:80
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: ZAP Scan
        uses: zaproxy/[email protected]
        with:
          target: 'http://localhost' # Runs within the context of your workflow
      - name: Create sarif file from zaproxy results
        uses: SvanBoxel/zaproxy-to-ghas@main
      - name: Upload SARIF file
        uses: github/codeql-action/upload-sarif@v1
        with:
          sarif_file: results.sarif

Use with Pull Requests

This Action offers you the ability to run the scan as part of a PR in the developer workflow. There are a couple of ways to do this. The easiest way is add the pull_request event to your workflow:

name: ZAProxy scan

on:
  push:
    branches: [ main ]
  pull_request: # Run on every pull request that targets the main branch
    branches: [ main ]
  workflow_dispatch:

jobs:
  # See examples in `Use with public-facing URLs` and `Use with containers`

After the scan completes, all results will be visible in the Checks tab of the scanned pull request:

Screenshot 2021-09-27 at 11 29 29

๐Ÿ’ก Alternatively you can hook into some of the other GitHub events to trigger a scan. Only want to run the DAST scan when a specific label is added? Use the label event.

Development

Contributions are always welcome. Please follow the steps below to get started.

Install the dependencies

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run package

Push the changes to your feature branch and wait for the tests to pass โœ”๏ธ

Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run ncc and push the results:

$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"

The action is now updated! ๐Ÿš€

zaproxy-to-ghas's People

Contributors

svanboxel avatar magmanu avatar dependabot[bot] avatar midwestkc-coder avatar tellierd 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.