All Projects → ForAllSecure → mapi-action

ForAllSecure / mapi-action

Licence: MIT license
🤖 Run a Mayhem for API scan in GitHub Actions

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to mapi-action

ochrona-cli
A command line tool for detecting vulnerabilities in Python dependencies and doing safe package installs
Stars: ✭ 46 (+187.5%)
Mutual labels:  devsecops
dataclasses-jsonschema
JSON schema generation from dataclasses
Stars: ✭ 145 (+806.25%)
Mutual labels:  openapi
httpyac
Command Line Interface for *.http and *.rest files. Connect with http, gRPC, WebSocket and MQTT
Stars: ✭ 103 (+543.75%)
Mutual labels:  postman
sbt-guardrail
Principled code generation from OpenAPI specifications
Stars: ✭ 24 (+50%)
Mutual labels:  openapi
postman-runtime
www.postman.com/downloads
Stars: ✭ 160 (+900%)
Mutual labels:  postman
postman-webex
Postman collections for Webex REST APIs
Stars: ✭ 97 (+506.25%)
Mutual labels:  postman
Ktor-OpenAPI-Generator
Ktor OpenAPI/Swagger 3 Generator
Stars: ✭ 203 (+1168.75%)
Mutual labels:  openapi
media-api-samples
Sample Code | Media APIs | Dolby.io
Stars: ✭ 20 (+25%)
Mutual labels:  postman
advanced-spring-scaffold
This project provides an advanced baseline to help you kick start a Spring project.
Stars: ✭ 21 (+31.25%)
Mutual labels:  openapi
apispec-webframeworks
Web framework plugins for apispec (formally in apispec.ext).
Stars: ✭ 25 (+56.25%)
Mutual labels:  openapi
prancer-compliance-test
This repository includes cloud security policies for IaC and live resources.
Stars: ✭ 32 (+100%)
Mutual labels:  devsecops
intercept
INTERCEPT / Policy as Code Static Analysis Auditing / SAST
Stars: ✭ 54 (+237.5%)
Mutual labels:  devsecops
PostmanCollection
PlayFab Postman Collection
Stars: ✭ 32 (+100%)
Mutual labels:  postman
swakka
A Scala library for creating Swagger definitions in a type-safe fashion wth Akka-Http
Stars: ✭ 74 (+362.5%)
Mutual labels:  openapi
postman-to-markdown
Generate documentation in markdown from postman documentation.
Stars: ✭ 30 (+87.5%)
Mutual labels:  postman
laravel-openapi
Generate OpenAPI specification for Laravel Applications
Stars: ✭ 269 (+1581.25%)
Mutual labels:  openapi
HibiAPI
一个实现了多种常用站点的易用化API的程序 / A program that implements easy-to-use APIs for a variety of commonly used sites.
Stars: ✭ 427 (+2568.75%)
Mutual labels:  openapi
yamlinc
Compose multiple YAML files into one with $include tag. Split Swagger/OpenAPI into multiple YAML files.
Stars: ✭ 103 (+543.75%)
Mutual labels:  openapi
OpenAlchemy
Define SQLAlchemy models using the OpenAPI specification.
Stars: ✭ 39 (+143.75%)
Mutual labels:  openapi
awesome-newman-html-template
😎 A newman html report very detailed
Stars: ✭ 63 (+293.75%)
Mutual labels:  postman

Mayhem for API GitHub Action

Mayhem for API

A GitHub Action for using Mayhem for API to check for reliability, performance and security issues in your APIs.

About Mayhem for API

🧪 Modern App Testing: Mayhem for API is a dynamic testing tool that catches reliability, performance and security bugs before they hit production.

🧑‍💻 For Developers, by developers: The engineers building software are the best equipped to fix bugs, including security bugs. As engineers ourselves, we're building tools that we wish existed to make our job easier!

🤖 Simple to Automate in CI: Tests belong in CI, running on every commit and PRs. We make it easy, and provide results right in your PRs where you want them. Adding Mayhem for API to a DevOps pipeline is easy.

Want to try it? Sign up for free today!

Usage

  1. Get a Mayhem for API token

    a. Sign up for Mayhem for API for free and install mapi

    b. Create a service account token using the Mayhem for API CLI

      mapi organization service-account create <your-org> <service-account-name>
    

    c. Add your service account token with name MAPI_TOKEN on your repository's GitHub page at SettingsSecretsNew repository secret

  2. Create a file in your GitHub repository at:

    .github/workflows/ForAllSecure-Mayhem-for-API.yml
  1. Add the following text to the file and tweak it for your codebase
name: Mayhem for API
on:
    push:
    pull_request:
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Start your API
      run: ./run_your_api.sh & # <----------------------------------- UPDATE THIS

    - name: Run Mayhem for API to check for vulnerabilities
      uses: ForAllSecure/mapi-action@v1
      with:
        mapi-token: ${{ secrets.MAPI_TOKEN }}
        api-url: http://localhost:8000 # <--------------------------- UPDATE THIS
        api-spec: your-openapi-spec-or-postman-collection.json # <--- UPDATE THIS
  1. Commit the new file and push it up to GitHub

  2. Your new Mayhem for API action will be visible at

    https://github.com/<USERNAME>/<REPO_NAME>/actions


This repo contains a full example for reference.

The action accepts the follow inputs:

Required Input Name Type Description Default
✔️ mapi-token string Mayhem for API service account token
✔️ api-url string URL to your running API. Example: http://localhost:8000/api/v1
✔️ api-spec string Path or URL to your Swagger spec, OpenAPI spec, or Postman collection.
target string The organization-scoped name of your target, such as forallsecure/mapi-action-example auto-generated from your GitHub Repository name
zap-api-scan boolean Include results from ZAP - API Scan false
duration number/string Duration of scan. 'auto' for automatic duration. Otherwise time (ie: '30sec', '5min', '1h', '1h30m') auto
html-report string Path to the generated SARIF report
sarif-report string Path to the generated HTML report
run-args string Additional arguments to provide to the mapi run command. Argument values should be separated on new lines.

e.g.
  run-args: |
# Basic Auth
--basic-auth
login:password

Continuing on error

The above examples will fail the workflow when issues are found. If you want to ensure the Action continues, even if Mayhem for API found issues, then continue-on-error can be used.

name: Mayhem for API
on:
    push:
    pull_request:
jobs:
  security:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Start your API
      run: ./run_your_api.sh &

    - name: Run Mayhem for API to check for vulnerabilities
      uses: ForAllSecure/mapi-action@v1
      continue-on-error: true # <-----------------------------------------------
      with:
        mapi-token: ${{ secrets.MAPI_TOKEN }}
        api-url: http://localhost:8000 # <- update this
        api-spec: your-openapi-spec-or-postman-collection.json
        # Additional 'mapi run' arguments
        run-args: |
          # Basic Auth
          --basic-auth
          login:password
          # Do not fuzz the '/logout' endpoint
          --ignore-endpoint
          /logout
          # Treat all warnings as errors
          --warnaserror

Reports

Mayhem for API generate reports when you pass sarif-report or html-report to the input. Make sure to pass continue-on-error to the Mayhem for API step if you want to process the reports in follow-up steps.

Artifact HTML Report

HTML Report

To artifact the report in your build, add this step to your pipeline:

- name: Run Mayhem for API to check for vulnerabilities
  uses: ForAllSecure/mapi-action@v1
  continue-on-error: true
  with:
    mapi-token: ${{ secrets.MAPI_TOKEN }}
    api-url: http://localhost:8000 # <- update this
    api-spec: your-openapi-spec-or-postman-collection.json # <- update this
    html-report: mapi.html

# Archive HTML report
- name: Archive Mayhem for API report
  uses: actions/upload-artifact@v2
  with:
    name: mapi-report
    path: mapi.html

GitHub Code Scanning support

Mayhem for API issue in your PR

Uploading SARIF reports to GitHub allows you to see any issue found by Mayhem for API right on your PR, as well as in the "Security" tab of your repository. This currently requires you to have a GitHub Enterprise Plan or have a public repository. To upload the SARIF report, add this step to your pipeline:

- name: Run Mayhem for API to check for vulnerabilities
  uses: ForAllSecure/mapi-action@v1
  continue-on-error: true
  with:
    mapi-token: ${{ secrets.MAPI_TOKEN }}
    api-url: http://localhost:8000 # <- update this
    api-spec: your-openapi-spec-or-postman-collection.json # <- update this
    sarif-report: mapi.sarif

# Upload SARIF file (only available on public repos or github enterprise)
- name: Upload SARIF file
  uses: github/codeql-action/upload-sarif@v1
  with:
    sarif_file: mapi.sarif

If your API server sends back stacktraces in the 500 Internal Server Error (only do this in a test environment -- never in production!), Mayhem for API will try to map issues it finds to the exact line of code that triggered the issue.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].