Skip to main content

PR Check

This guide helps you integrate Vault++ into your pull request pipeline to detect secret leaks and display warnings.

Prerequisites

  1. Have a Vault++ account.
  2. Have a git repository.

1. Create a PR service account

A dedicated service account with no access to live environments is required to securely scan secrets in PR pipelines. Follow these steps to create one:

  1. Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.

  2. Find the Service Accounts section and click the Add () button.

  3. Enter a descriptive label, for example PR Scan, then press Enter.

  4. A dialog will display the private key and an encryption password. Do not close the dialog as you cannot access these credentials again after closing.

  1. In a new browser tab, open your GitHub repository and click the Settings tab.

  2. In the left sidebar, under Security , click Secrets and variables > Actions.

  3. Add the following secrets from the Vault++ dialog to Repository secrets:

    • VPP_SERVICE_ACCOUNT_KEY
    • VPP_SERVICE_ACCOUNT_PASSWORD
    warning
    Do not grant this service account access to any environment, as it will be used in PR pipelines, which run on unprotected branches.

2. Add a vpp scan config file

If you haven't already, create a vpp.scan.jsonc file in the root folder of your repository as shown below.

vpp.scan.jsonc
{
"$schema": "https://vaultplusplus.com/scan-schema.json",
"organization": "<your org slug>", // change to your organization slug

// Whitelisted Signatures
"whitelist": []
}

3. Create a PR pipeline

  1. Open your repository in your IDE.

  2. Create a new PR workflow YAML file, e.g., .github/workflows/vpp-pr.yml, with the following content:

    .github/workflows/vpp-pr.yml
    name: VPP PR Scan
    on:
    pull_request:
    branches: # Adjust according to your needs
    - main

    jobs:
    vpp:
    permissions:
    contents: read
    pull-requests: write
    name: VPP PR Check
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
    - uses: actions/checkout@v4
    - uses: vaultplusplus/setup@latest

    # In a monorepo, run vpp status for each application.
    # Use the working-directory parameter to select the application folder.
    #
    # Requires a vpp.jsonc config file.
    - run: vpp status
    # working-directory: ./apps/app1 # example for monorepo
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
    VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}

    # Run vpp scan pr at the repository root.
    # Requires a vpp.scan.jsonc config file.
    - run: vpp scan pr
    env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
    VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }}
  3. Commit and push your changes.

Allow GitHub Actions to approve PR

Vault++ will automatically approve your PR if no secrets are detected. By default, GitHub disables PR approvals from Actions. To enable it:

  1. For GitHub Enterprise or Organization accounts:

    • Go to your Enterprise or Organization settings page.
    • In the left sidebar, click Actions > General.
    • Enable Allow GitHub Actions to create and approve pull requests, then click Save.
  2. For repositories on personal accounts (or after completing step 1 for Enterprise/Organization repositories):

    • Go to your repository settings.
    • Click Actions > General.
    • Enable Allow GitHub Actions to create and approve pull requests, then click Save.

Well done! 🎉 Your PR is now protected against secret leaks. Next, we'll perform a Deep Scan to uncover hardcoded secrets hidden in your repository's history.