This example uses a specific scanner image with the built-in vulnerability databases located in the image registry of the Kaspersky Container Security manufacturer.
To use the image scanning feature in the GitLab CI/CD process, you should enable the use of the GitLab Container Registry.
Integration configuration includes the following steps:
printf "login:password" | openssl base64 -A
where login and password are the user name and password of an account in the image registry of the Kaspersky Container Security manufacturer.
{
"auths": {
"repo.cloud.example.com": {
"auth": "base64hash"
}
}
}
where base64hash is the string obtained in step 1a.
To add scanning to the CI/CD pipeline, you should add the following lines to the .gitlab-ci.yml file:
scan_image:
stage: scanner
image:
name: repo.cloud.example.com/repository/company/scanner:v1.2-with-db
entrypoint: [""]
pull_policy: always
We recommend that you specify always for the pull_policy
parameter to receive relevant builds with updated databases of vulnerabilities and other malicious objects for each scan.
SCAN_TARGET: ${CI_REGISTRY_IMAGE}:master
BUILD_NUMBER: ${CI_JOB_ID}
BUILD_PIPELINE: ${CI_PIPELINE_ID}
API_TOKEN: <API token value>
The example here contains the master
tag, you can also specify another tag.
COMPANY_EXT_REGISTRY_USERNAME: ${COMPANY_EXT_REGISTRY_USERNAME}
COMPANY_EXT_REGISTRY_PASSWORD: ${COMPANY_EXT_REGISTRY_PASSWORD}
API_CA_CERT: ${KCS_CA_CERT}
The CA certificate of the Ingress controller is specified in the text field as a string in the .PEM format:
----- BEGIN CERTIFICATE ----- \ n... <certificate details>
...\ n ----- END CERTIFICATE -----
If the API_CA_CERT
variable is not set, scanning will start but will not be completed.
Use of the CA certificate of the Ingress controller allows the scanner running in CI/CD to verify the authenticity of the data receiving server.
If you use a self-signed certificate, or want to skip checking the data receiving server using the CA certificate of the Ingress controller, specify the value of the variable to skip the check as follows:
SKIP_API_SERVER_VALIDATION: 'true'
API_BASE_URL:
<web address>
variables:
API_BASE_URL: ${API_BASE_URL}
script:
- /bin/sh /entrypoint.sh $SCAN_TARGET --stdout > artifact-result.json
artifacts:
paths:
- artifact-result.json
After configuring integration with an external registry, you can scan images within the CI/CD process, including scanning in SBOM mode. Scan results can be viewed in Resources → CI/CD, or downloaded in the .SPDX, .JSON, and .HTML formats.
Page top