githubGitHub Actions

Introduction to GitHub Actions

GitHub Actionsarrow-up-right is a powerful automation tool that integrates directly with GitHub repositories to allow you to automate your workflow by setting up a series of commands (actions) that execute in response to specific GitHub events like a push or a pull request. These actions can be used for a variety of tasks, such as testing code, deploying applications and, in the case of Safety, scanning for vulnerabilities.

The Safety CLI Scanner GitHub Actionarrow-up-right enables automated scanning of your projects for vulnerabilities directly within your GitHub workflow.

Link to Safety GitHub Action: https://github.com/marketplace/actions/pyupio-safety-actionarrow-up-right

Setting Up the Safety GitHub Action

Step 1: Create a Safety Account and Obtain an API Key

Organization and User API Keys are available in Organization->API Keys

Step 2: Configure the GitHub Secret

  • After obtaining your Safety API key, go to your GitHub repository's settings.

  • Navigate to the 'Secretsarrow-up-right' section and add a new secret.

  • Name the secret (e.g., SAFETY_API_KEY) and paste your Safety API key as the value.

Add a new Secret to your Repo called SAFETY_API_KEY

Step 3: Set Up the Workflow File

  • You may need to create a Personal Access Token (PAT) with workflow permissions in order to push a workflow file to your repo. To do so, please refer to this guidearrow-up-right.

  • In your repository, create a new file in the .github/workflows directory. You can name this file according to its purpose (e.g., safety_scan.yml).

  • Add the following content to your workflow file:

Step 4: Activate the Workflow

  • Commit and push the workflow file to your repository.

  • The Safety CLI Scanner Action will run automatically on each push, scanning your Python project for any vulnerabilities.

Additional Configurations (Optional)

  • You can customize the behaviour of the Safety Action by using various properties.

  • You can also add arguments like --detailed-output to get more information from the scan:

Available Properties

Property
Default
Description

api-key

Your Safety API Key

output-format

screen

Options are: screen, json, html, spdx, none

args

Override the default arguments to Safety CLI 3.

For more detailed information about Safety's CLI and its functionalities, please refer to Safety 3 Documentationarrow-up-right or contact our Support Team.

Last updated

Was this helpful?