Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41f05d9ecf | ||
|
|
0cd397afbf | ||
|
|
b43daad0c3 | ||
|
|
dedfa59531 | ||
|
|
f96f79aa22 | ||
|
|
82ec0dd604 | ||
|
|
e5f43133f6 | ||
|
|
1a09192c0e | ||
|
|
1f0aa582c8 | ||
|
|
43849adf01 | ||
|
|
8bd2f9fbda |
@@ -1,7 +1,7 @@
|
|||||||
name: "build"
|
name: "build"
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
env:
|
env:
|
||||||
TRIVY_VERSION: 0.37.1
|
TRIVY_VERSION: 0.42.1
|
||||||
BATS_LIB_PATH: '/usr/lib/'
|
BATS_LIB_PATH: '/usr/lib/'
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM ghcr.io/aquasecurity/trivy:0.37.1
|
FROM ghcr.io/aquasecurity/trivy:0.42.1
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
RUN apk --no-cache add bash curl npm
|
RUN apk --no-cache add bash curl npm
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|||||||
@@ -299,11 +299,12 @@ jobs:
|
|||||||
```
|
```
|
||||||
|
|
||||||
### Using Trivy to generate SBOM
|
### Using Trivy to generate SBOM
|
||||||
It's possible for Trivy to generate an SBOM of your dependencies and submit them to a consumer like GitHub Dependency Snapshot.
|
It's possible for Trivy to generate an [SBOM](https://www.aquasec.com/cloud-native-academy/supply-chain-security/sbom/) of your dependencies and submit them to a consumer like [GitHub Dependency Graph](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph).
|
||||||
|
|
||||||
The sending of SBOM to GitHub feature is only available if you currently have [GitHub Dependency Snapshot](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api) available to you in your repo.
|
The [sending of an SBOM to GitHub](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api) feature is only available if you currently have GitHub Dependency Graph [enabled in your repo](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/configuring-the-dependency-graph#enabling-and-disabling-the-dependency-graph-for-a-private-repository).
|
||||||
|
|
||||||
|
In order to send results to GitHub Dependency Graph, you will need to create a [GitHub PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) or use the [GitHub installation access token](https://docs.github.com/en/actions/security-guides/automatic-token-authentication) (also known as `GITHUB_TOKEN`):
|
||||||
|
|
||||||
In order to send results to the GitHub Dependency Snapshot, you will need to create a [GitHub PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
|
|
||||||
```yaml
|
```yaml
|
||||||
---
|
---
|
||||||
name: Pull Request
|
name: Pull Request
|
||||||
@@ -311,7 +312,11 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
|
||||||
|
## GITHUB_TOKEN authentication, add only if you're not going to use a PAT
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Checks
|
name: Checks
|
||||||
@@ -320,14 +325,14 @@ jobs:
|
|||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Snapshots
|
- name: Run Trivy in GitHub SBOM mode and submit results to Dependency Graph
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
scan-type: 'fs'
|
scan-type: 'fs'
|
||||||
format: 'github'
|
format: 'github'
|
||||||
output: 'dependency-results.sbom.json'
|
output: 'dependency-results.sbom.json'
|
||||||
image-ref: '.'
|
image-ref: '.'
|
||||||
github-pat: '<github_pat_token>'
|
github-pat: ${{ secrets.GITHUB_TOKEN }} # or ${{ secrets.github_pat_name }} if you're using a PAT
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using Trivy to scan your private registry
|
### Using Trivy to scan your private registry
|
||||||
@@ -498,10 +503,10 @@ Following inputs can be used as `step.with` keys:
|
|||||||
| `ignore-policy` | String | | Filter vulnerabilities with OPA rego language |
|
| `ignore-policy` | String | | Filter vulnerabilities with OPA rego language |
|
||||||
| `hide-progress` | String | `true` | Suppress progress bar |
|
| `hide-progress` | String | `true` | Suppress progress bar |
|
||||||
| `list-all-pkgs` | String | | Output all packages regardless of vulnerability |
|
| `list-all-pkgs` | String | | Output all packages regardless of vulnerability |
|
||||||
| `security-checks` | String | `vuln,secret` | comma-separated list of what security issues to detect (`vuln`,`secret`,`config`) |
|
| `scanners` | String | `vuln,secret` | comma-separated list of what security issues to detect (`vuln`,`secret`,`config`) |
|
||||||
| `trivyignores` | String | | comma-separated list of relative paths in repository to one or more `.trivyignore` files |
|
| `trivyignores` | String | | comma-separated list of relative paths in repository to one or more `.trivyignore` files |
|
||||||
| `trivy-config` | String | | Path to trivy.yaml config |
|
| `trivy-config` | String | | Path to trivy.yaml config |
|
||||||
| `github-pat` | String | | GitHub Personal Access Token (PAT) for sending SBOM scan results to GitHub Dependency Snapshots |
|
| `github-pat` | String | | Authentication token to enable sending SBOM scan results to GitHub Dependency Graph. Can be either a GitHub Personal Access Token (PAT) or GITHUB_TOKEN |
|
||||||
| `limit-severities-for-sarif` | Boolean | false | By default *SARIF* format enforces output of all vulnerabilities regardless of configured severities. To override this behavior set this parameter to **true** |
|
| `limit-severities-for-sarif` | Boolean | false | By default *SARIF* format enforces output of all vulnerabilities regardless of configured severities. To override this behavior set this parameter to **true** |
|
||||||
|
|
||||||
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
|
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
|
||||||
|
|||||||
+2
-2
@@ -71,7 +71,7 @@ inputs:
|
|||||||
description: 'output all packages regardless of vulnerability'
|
description: 'output all packages regardless of vulnerability'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
security-checks:
|
scanners:
|
||||||
description: 'comma-separated list of what security issues to detect'
|
description: 'comma-separated list of what security issues to detect'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
@@ -114,7 +114,7 @@ runs:
|
|||||||
- '-p ${{ inputs.hide-progress }}'
|
- '-p ${{ inputs.hide-progress }}'
|
||||||
- '-q ${{ inputs.skip-files }}'
|
- '-q ${{ inputs.skip-files }}'
|
||||||
- '-r ${{ inputs.list-all-pkgs }}'
|
- '-r ${{ inputs.list-all-pkgs }}'
|
||||||
- '-s ${{ inputs.security-checks }}'
|
- '-s ${{ inputs.scanners }}'
|
||||||
- '-t ${{ inputs.trivyignores }}'
|
- '-t ${{ inputs.trivyignores }}'
|
||||||
- '-u ${{ inputs.github-pat }}'
|
- '-u ${{ inputs.github-pat }}'
|
||||||
- '-v ${{ inputs.trivy-config }}'
|
- '-v ${{ inputs.trivy-config }}'
|
||||||
|
|||||||
+8
-4
@@ -57,7 +57,7 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:z:" o; do
|
|||||||
export listAllPkgs=${OPTARG}
|
export listAllPkgs=${OPTARG}
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
export securityChecks=${OPTARG}
|
export scanners=${OPTARG}
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
export trivyIgnores=${OPTARG}
|
export trivyIgnores=${OPTARG}
|
||||||
@@ -105,6 +105,7 @@ if [ $template ] ;then
|
|||||||
fi
|
fi
|
||||||
if [ $exitCode ];then
|
if [ $exitCode ];then
|
||||||
ARGS="$ARGS --exit-code $exitCode"
|
ARGS="$ARGS --exit-code $exitCode"
|
||||||
|
SARIF_ARGS="$SARIF_ARGS --exit-code $exitCode"
|
||||||
fi
|
fi
|
||||||
if [ "$ignoreUnfixed" == "true" ] && [ "$scanType" != "config" ];then
|
if [ "$ignoreUnfixed" == "true" ] && [ "$scanType" != "config" ];then
|
||||||
ARGS="$ARGS --ignore-unfixed"
|
ARGS="$ARGS --ignore-unfixed"
|
||||||
@@ -114,9 +115,9 @@ if [ $vulnType ] && [ "$scanType" != "config" ] && [ "$scanType" != "sbom" ];the
|
|||||||
ARGS="$ARGS --vuln-type $vulnType"
|
ARGS="$ARGS --vuln-type $vulnType"
|
||||||
SARIF_ARGS="$SARIF_ARGS --vuln-type $vulnType"
|
SARIF_ARGS="$SARIF_ARGS --vuln-type $vulnType"
|
||||||
fi
|
fi
|
||||||
if [ $securityChecks ];then
|
if [ $scanners ];then
|
||||||
ARGS="$ARGS --security-checks $securityChecks"
|
ARGS="$ARGS --scanners $scanners"
|
||||||
SARIF_ARGS="$SARIF_ARGS --security-checks $securityChecks"
|
SARIF_ARGS="$SARIF_ARGS --scanners $scanners"
|
||||||
fi
|
fi
|
||||||
if [ $severity ];then
|
if [ $severity ];then
|
||||||
ARGS="$ARGS --severity $severity"
|
ARGS="$ARGS --severity $severity"
|
||||||
@@ -169,6 +170,8 @@ if [ "$skipFiles" ];then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
trivyConfig=$(echo $trivyConfig | tr -d '\r')
|
trivyConfig=$(echo $trivyConfig | tr -d '\r')
|
||||||
|
# To make sure that uploda GitHub Dependency Snapshot succeeds, disable the script that fails first.
|
||||||
|
set +e
|
||||||
if [ "${format}" == "sarif" ] && [ "${limitSeveritiesForSARIF}" != "true" ]; then
|
if [ "${format}" == "sarif" ] && [ "${limitSeveritiesForSARIF}" != "true" ]; then
|
||||||
# SARIF is special. We output all vulnerabilities,
|
# SARIF is special. We output all vulnerabilities,
|
||||||
# regardless of severity level specified in this report.
|
# regardless of severity level specified in this report.
|
||||||
@@ -186,6 +189,7 @@ else
|
|||||||
returnCode=$?
|
returnCode=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set -e
|
||||||
if [[ "${format}" == "github" ]]; then
|
if [[ "${format}" == "github" ]]; then
|
||||||
if [[ "$(echo $githubPAT | xargs)" != "" ]]; then
|
if [[ "$(echo $githubPAT | xargs)" != "" ]]; then
|
||||||
printf "\n Uploading GitHub Dependency Snapshot"
|
printf "\n Uploading GitHub Dependency Snapshot"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json",
|
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
{
|
||||||
"tool": {
|
"tool": {
|
||||||
@@ -43,15 +43,15 @@
|
|||||||
"text": "No HEALTHCHECK defined"
|
"text": "No HEALTHCHECK defined"
|
||||||
},
|
},
|
||||||
"fullDescription": {
|
"fullDescription": {
|
||||||
"text": "You shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers."
|
"text": "You should add HEALTHCHECK instruction in your docker container images to perform the health check on running containers."
|
||||||
},
|
},
|
||||||
"defaultConfiguration": {
|
"defaultConfiguration": {
|
||||||
"level": "note"
|
"level": "note"
|
||||||
},
|
},
|
||||||
"helpUri": "https://avd.aquasec.com/misconfig/ds026",
|
"helpUri": "https://avd.aquasec.com/misconfig/ds026",
|
||||||
"help": {
|
"help": {
|
||||||
"text": "Misconfiguration DS026\nType: Dockerfile Security Check\nSeverity: LOW\nCheck: No HEALTHCHECK defined\nMessage: Add HEALTHCHECK instruction in your Dockerfile\nLink: [DS026](https://avd.aquasec.com/misconfig/ds026)\nYou shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
"text": "Misconfiguration DS026\nType: Dockerfile Security Check\nSeverity: LOW\nCheck: No HEALTHCHECK defined\nMessage: Add HEALTHCHECK instruction in your Dockerfile\nLink: [DS026](https://avd.aquasec.com/misconfig/ds026)\nYou should add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
||||||
"markdown": "**Misconfiguration DS026**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Dockerfile Security Check|LOW|No HEALTHCHECK defined|Add HEALTHCHECK instruction in your Dockerfile|[DS026](https://avd.aquasec.com/misconfig/ds026)|\n\nYou shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers."
|
"markdown": "**Misconfiguration DS026**\n| Type | Severity | Check | Message | Link |\n| --- | --- | --- | --- | --- |\n|Dockerfile Security Check|LOW|No HEALTHCHECK defined|Add HEALTHCHECK instruction in your Dockerfile|[DS026](https://avd.aquasec.com/misconfig/ds026)|\n\nYou should add HEALTHCHECK instruction in your docker container images to perform the health check on running containers."
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
"precision": "very-high",
|
"precision": "very-high",
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "0.37.1"
|
"version": "0.42.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"results": [
|
"results": [
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"Class": "config",
|
"Class": "config",
|
||||||
"Type": "dockerfile",
|
"Type": "dockerfile",
|
||||||
"MisconfSummary": {
|
"MisconfSummary": {
|
||||||
"Successes": 22,
|
"Successes": 24,
|
||||||
"Failures": 2,
|
"Failures": 2,
|
||||||
"Exceptions": 0
|
"Exceptions": 0
|
||||||
},
|
},
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
"ID": "DS026",
|
"ID": "DS026",
|
||||||
"AVDID": "AVD-DS-0026",
|
"AVDID": "AVD-DS-0026",
|
||||||
"Title": "No HEALTHCHECK defined",
|
"Title": "No HEALTHCHECK defined",
|
||||||
"Description": "You shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
"Description": "You should add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
||||||
"Message": "Add HEALTHCHECK instruction in your Dockerfile",
|
"Message": "Add HEALTHCHECK instruction in your Dockerfile",
|
||||||
"Namespace": "builtin.dockerfile.DS026",
|
"Namespace": "builtin.dockerfile.DS026",
|
||||||
"Query": "data.builtin.dockerfile.DS026.deny",
|
"Query": "data.builtin.dockerfile.DS026.deny",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"Class": "config",
|
"Class": "config",
|
||||||
"Type": "dockerfile",
|
"Type": "dockerfile",
|
||||||
"MisconfSummary": {
|
"MisconfSummary": {
|
||||||
"Successes": 22,
|
"Successes": 24,
|
||||||
"Failures": 2,
|
"Failures": 2,
|
||||||
"Exceptions": 0
|
"Exceptions": 0
|
||||||
},
|
},
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
"ID": "DS026",
|
"ID": "DS026",
|
||||||
"AVDID": "AVD-DS-0026",
|
"AVDID": "AVD-DS-0026",
|
||||||
"Title": "No HEALTHCHECK defined",
|
"Title": "No HEALTHCHECK defined",
|
||||||
"Description": "You shoud add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
"Description": "You should add HEALTHCHECK instruction in your docker container images to perform the health check on running containers.",
|
||||||
"Message": "Add HEALTHCHECK instruction in your Dockerfile",
|
"Message": "Add HEALTHCHECK instruction in your Dockerfile",
|
||||||
"Namespace": "builtin.dockerfile.DS026",
|
"Namespace": "builtin.dockerfile.DS026",
|
||||||
"Query": "data.builtin.dockerfile.DS026.deny",
|
"Query": "data.builtin.dockerfile.DS026.deny",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json",
|
"$schema": "https://json.schemastore.org/sarif-2.1.0.json",
|
||||||
"runs": [
|
"runs": [
|
||||||
{
|
{
|
||||||
"tool": {
|
"tool": {
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "0.37.1"
|
"version": "0.42.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"results": [
|
"results": [
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ bats_load_library bats-assert
|
|||||||
bats_load_library bats-file
|
bats_load_library bats-file
|
||||||
|
|
||||||
@test "trivy repo with securityCheck secret only" {
|
@test "trivy repo with securityCheck secret only" {
|
||||||
# trivy repo --format json --output repo.test --security-checks=secret https://github.com/krol3/demo-trivy/
|
# trivy repo --format json --output repo.test --scanners=secret https://github.com/krol3/demo-trivy/
|
||||||
run ./entrypoint.sh '-b json' '-h repo.test' '-s secret' '-a repo' '-j https://github.com/krol3/demo-trivy/'
|
run ./entrypoint.sh '-b json' '-h repo.test' '-s secret' '-a repo' '-j https://github.com/krol3/demo-trivy/'
|
||||||
run diff repo.test ./test/data/repo.test
|
run diff repo.test ./test/data/repo.test
|
||||||
echo "$output"
|
echo "$output"
|
||||||
@@ -52,7 +52,7 @@ bats_load_library bats-file
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy fs with securityChecks option" {
|
@test "trivy fs with securityChecks option" {
|
||||||
# trivy fs --format json --security-checks=vuln,config --output fs-scheck.test .
|
# trivy fs --format json --scanners=vuln,config --output fs-scheck.test .
|
||||||
run ./entrypoint.sh '-a fs' '-b json' '-j .' '-s vuln,config,secret' '-h fs-scheck.test'
|
run ./entrypoint.sh '-a fs' '-b json' '-j .' '-s vuln,config,secret' '-h fs-scheck.test'
|
||||||
run diff fs-scheck.test ./test/data/fs-scheck.test
|
run diff fs-scheck.test ./test/data/fs-scheck.test
|
||||||
echo "$output"
|
echo "$output"
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-20.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
Reference in New Issue
Block a user