GitHub Actions Integration
Last updated
Last updated
GitHub Actions is a platform for continuous integration in GitHub repositories. An action encodes a reusable task with configurable parameters.
Xygeni provides a xygeni-action
for downloading and running the scanner on the repository.
The following configuration examples show how to install & run the scanner using an API Token stored as a secret named XYGENI_TOKEN
. See Generate Xygeni API Token for Scanner or ask your Xygeni administrator to generate it.
The xygeni-action
action downloads, configures and executes the Xygeni Scanner on the repository where the action is invoked.
The scanner needs an API token to communicate with the Xygeni platform. Such API token is a secret that could be registered safely at the appropriate scope (organization, repository or environment) using GitHub Encrypted Secrets.
For example, to register the API token as a secret named XYGENI_TOKEN
, for repository in the current working directory. you may use the GitHub gh
command:
(You must be the repository owner for creating repository secrets.)
For creating encryption secret at environment scope in a personal account repository (you need to be the repository owner), add --env ENV_NAME
:
For creating encryption secret at organization scope (so the secret is available to all or a subset of the organization repositories), add --org ORG_NAME
:
You may use the corresponding GitHub webpages for setting the api token as a secret named XYGENI_TOKEN
at the appropriate scope.
In a GitHub workflow (.github/workflows/*.yml
) the Xygeni scanner could be run on the repository files, typically after actions/checkout
to retrieve the branch sources. The GITHUB_WORKSPACE
environment variable will contain the default location of the repository when using the checkout action.
You can configure a GitHub action with the form:
Where XYGENI_TOKEN
is the name of the encrypted secret where the API token was saved.
Only the API token (or alternatively the username + password) is required.
The default values for some parameters can be changed. For example, you may specify a specific name for the project instead of the GitHub repository name,GITHUB_REPOSITORY
. Also, you may want to scan a particular source subdirectory instead of the default, por example ${{ github.repository }}/src
.
You can see more information about default GitHub environment variables here.
The available parameters for the action are:
Use --never-fail
to avoid breaking the build if the scan finds issues or fails.
You may also use --fail_on=critical
to terminate the build only when critical issues are found.
Use --run=secrets,iac
if you want to scan only for secrets and IaC flaws, for example.
Example for scanning only hard-coded secrets and IaC flaws detectors, and failing the build only when critical issues are found:
You may use pinned versions for the action, using the immutable commit SHA instead of version numbers, as specified in Pin actions to full length commit SHA.
Parameter | Description | Mandatory | Default value |
---|---|---|---|
xygeni_url
Base URL of the Xygeni API.
No
gh_token
GitHub token to retrieve repository information for misconfigurations and compliance.
No
${GITHUB_TOKEN}
directory
Directory to analyze
No
${{ github.workspace }}
token
API token
No
username
Xygeni account’s username. Not recommended, use token instead.
No
password
Xygeni account’s password. Not recommended, use token instead.
No
command
Command to execute by the scanner
No
scan --never-fail -n ${{ github.repository }} -d /app