Deep Scan
This guide helps you scan your repositories to uncover secrets hidden in your Git history.
Prerequisites
- Have a Vault++ account.
- Have a git repository.
1. 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.
{
"$schema": "https://vaultplusplus.com/scan-schema.json",
"organization": "<your org slug>", // change to your organization slug
// Whitelisted Signatures
"whitelist": []
}
2. Scan a local repository
To scan a repository on your local machine, open a terminal, navigate to your repository folder, and run the following command:
# vpp scan repo --help
# Usage: vpp scan repo [options]
# Options:
# -c, --use-checkpoint Use checkpoints to skip previously scanned commits
# -s, --since <since> Oldest commit to scan from (excluding this commit)
# --worker <size> Worker size, defaults to the number of available CPU
# --mem <size> Memory size (MB) allocated to each worker, defaults to memory size / num of workers
# --max-batch <size> Maximum batch size
# -h, --help display help for command
vpp scan repo --use-checkpoint
3. Run a deep scan in CICD
Create a service account (If you have created a service account when creating the PR scanner, you can skip this step.)
The following steps will guide you in creating a dedicated service account without access to live environments, which can be used for deep repository scans and PR scans.
- Github Actions
- Bitbucket Pipeline
- Gitlab Pipeline
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example PR Scan, then press Enter.
-
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.
-
In a new browser tab, open your GitHub repository and click the Settings tab.
-
In the left sidebar, under Security , click Secrets and variables > Actions.
-
Add the following secrets from the Vault++ dialog to Repository secrets:
VPP_SERVICE_ACCOUNT_KEY
VPP_SERVICE_ACCOUNT_PASSWORD
warningDo not grant this service account access to any environment, as it will be used in PR pipelines, which run on unprotected branches.
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example PR Scan, then press Enter.
-
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.
-
In a new browser tab, open your Bitbucket repository.
-
In the left sidebar, click Repository Settings and then click Repository variables under the Pipelines section.
-
Add the following secrets from Vault++:
VPP_SERVICE_ACCOUNT_KEY
VPP_SERVICE_ACCOUNT_PASSWORD
warningDo not grant this service account access to any environment, as it will be used in PR pipelines, which run on unprotected branches. -
In the left sidebar, click Access tokens under the Security section.
-
Click Create Repository Access Token.
-
Enter a name, e.g., VPP PR Check
-
Enable Repositories: Write and Pull requests: Write, then click Create.
-
Copy the access token from the modal (the first token shown).
-
Go back to Repository variables (as in step 6) and add a new secret:
- Name:
BITBUCKET_REPO_TOKEN
- Value: The access token you just created.
- Name:
-
Log in to your Vault++ account, choose the desired application, and navigate to the Settings tab.
-
Find the Service Accounts section and click the Add () button.
-
Enter a descriptive label, for example PR Scan, then press Enter.
-
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.
-
In a new browser tab, open your GitLab repository.
-
In the left sidebar, click Settings, then select Access tokens.
-
Click Add new token and use the following details:
- Name: e.g., VPP
- Expiration: Recommended to set it to 6 months.
- Role: Set to Reporter
- Scopes: Enable api
-
Copy the generated token.
For repositories in groups, Repository Access Tokens are only available with paid plans. On the free plan, Repository Access Tokens are available only for repositories in personal accounts. If you're working with a group repository on a free plan, use a Personal Access Token instead.
-
In the left sidebar, click Settings, then select CI/CD.
-
Scroll to the Variables section and click Add Variable.
-
Add the following variables:
GITLAB_PROJECT_TOKEN
(with the token generated in step 8)VPP_SERVICE_ACCOUNT_KEY
andVPP_SERVICE_ACCOUNT_PASSWORD
from Vault++
Use these settings for each variable:
- Type: Variable
- Environments: All (default)
- Visibility: Masked and hidden
- Disable the Protect variable flag (so it's accessible from all branches)
- Disable the Expand variable reference option
- Key: Set to the respective variable name (
GITLAB_PROJECT_TOKEN
,VPP_SERVICE_ACCOUNT_KEY
orVPP_SERVICE_ACCOUNT_PASSWORD
) - Value: Enter the corresponding value for each key
You can use the same variable key with different values in GitLab CICD variables. This allows you to assign different values to VPP_SERVICE_ACCOUNT_KEY
and VPP_SERVICE_ACCOUNT_PASSWORD
for each environment, which implies using different service accounts for each environment.
Follow these steps to automatically run deep scans in your repository:
- Github Actions
- Bitbucket Pipeline
- Gitlab Pipeline
-
Open your repository in your IDE.
-
Create a new workflow YAML file, e.g.,
.github/workflows/vpp-scan.yml
, with the following content:.github/workflows/vpp-scan.ymlname: VPP Deep Scan
on:
push:
branches:
- main
jobs:
vpp:
name: VPP Deep Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# fetch all history for deep scanning
fetch-depth: 0
- uses: vaultplusplus/setup@latest
# Requires a vpp.scan.jsonc config file.
- run: vpp scan repo --use-checkpoint
env:
VPP_SERVICE_ACCOUNT_KEY: ${{ secrets.VPP_SERVICE_ACCOUNT_KEY }}
VPP_SERVICE_ACCOUNT_PASSWORD: ${{ secrets.VPP_SERVICE_ACCOUNT_PASSWORD }} -
Commit and push your changes.
-
Open the
bitbucket-pipelines.yml
file in your repository. -
Add a new section in the
branches
pipeline, or create a new step if you already have an existing one, with the following content:bitbucket-pipelines.ymlimage: atlassian/default-image:4
pipelines:
branches:
main:
- step:
# fetch all history for deep scanning
clone:
depth: full
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
# Requires a vpp.scan.jsonc config file.
- vpp scan repo --use-checkpoint
# Existing steps... -
Commit and push your changes
-
Open the
.gitlab-ci.yml
file in your repository. -
Add the following snippet at the end of the file:
.gitlab-ci.ymlvpp-deep-scan:
variables:
# fetch all history for deep scanning
GIT_DEPTH: 0
rules:
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- eval "$(curl -fsSLA $SHELL https://vpp.sh)"
- vpp scan repo --use-checkpoint -
Commit and push your changes
Great job! 🎉 Your repository is now protected against secret leaks. In the next guide, we'll set up automated secret rotation.