Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49e970d7ac | ||
|
|
c666240787 | ||
|
|
e27605859b | ||
|
|
2b22459068 | ||
|
|
4b3b5f928b | ||
|
|
1a53202fc4 | ||
|
|
df3fb7d00b | ||
|
|
987beb8186 | ||
|
|
4b9b6fb4ef |
@@ -1,7 +1,7 @@
|
|||||||
name: "build"
|
name: "build"
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
env:
|
env:
|
||||||
TRIVY_VERSION: 0.26.0
|
TRIVY_VERSION: 0.29.0
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: build
|
name: build
|
||||||
|
|||||||
+3
-1
@@ -1,2 +1,4 @@
|
|||||||
.idea/
|
.idea/
|
||||||
*.test
|
*.test
|
||||||
|
!test/data/*.test
|
||||||
|
trivyignores
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM aquasec/trivy:0.26.0
|
FROM ghcr.io/aquasecurity/trivy:0.29.0
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
RUN apk --no-cache add bash
|
RUN apk --no-cache add bash
|
||||||
RUN chmod +x /entrypoint.sh
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Build an image from Dockerfile
|
- name: Build an image from Dockerfile
|
||||||
run: |
|
run: |
|
||||||
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
|
docker build -t docker.io/my-organization/my-app:${{ github.sha }} .
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
output: 'trivy-results.sarif'
|
output: 'trivy-results.sarif'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -115,8 +115,8 @@ jobs:
|
|||||||
output: 'trivy-results.sarif'
|
output: 'trivy-results.sarif'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -152,7 +152,7 @@ jobs:
|
|||||||
severity: 'CRITICAL'
|
severity: 'CRITICAL'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -187,7 +187,7 @@ jobs:
|
|||||||
severity: 'CRITICAL'
|
severity: 'CRITICAL'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -222,7 +222,7 @@ jobs:
|
|||||||
severity: 'CRITICAL,HIGH'
|
severity: 'CRITICAL,HIGH'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -247,7 +247,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -256,10 +256,10 @@ jobs:
|
|||||||
output: 'trivy-results.sarif'
|
output: 'trivy-results.sarif'
|
||||||
env:
|
env:
|
||||||
TRIVY_USERNAME: Username
|
TRIVY_USERNAME: Username
|
||||||
TRIVY_PASSWORD: Password
|
TRIVY_PASSWORD: Password
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -283,7 +283,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -296,7 +296,7 @@ jobs:
|
|||||||
AWS_DEFAULT_REGION: us-west-2
|
AWS_DEFAULT_REGION: us-west-2
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -319,7 +319,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -330,7 +330,7 @@ jobs:
|
|||||||
GOOGLE_APPLICATION_CREDENTIAL: /path/to/credential.json
|
GOOGLE_APPLICATION_CREDENTIAL: /path/to/credential.json
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -352,7 +352,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Run Trivy vulnerability scanner
|
- name: Run Trivy vulnerability scanner
|
||||||
uses: aquasecurity/trivy-action@master
|
uses: aquasecurity/trivy-action@master
|
||||||
with:
|
with:
|
||||||
@@ -361,10 +361,10 @@ jobs:
|
|||||||
output: 'trivy-results.sarif'
|
output: 'trivy-results.sarif'
|
||||||
env:
|
env:
|
||||||
TRIVY_USERNAME: Username
|
TRIVY_USERNAME: Username
|
||||||
TRIVY_PASSWORD: Password
|
TRIVY_PASSWORD: Password
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
```
|
```
|
||||||
@@ -393,8 +393,10 @@ Following inputs can be used as `step.with` keys:
|
|||||||
| `cache-dir` | String | | Cache directory |
|
| `cache-dir` | String | | Cache directory |
|
||||||
| `timeout` | String | `5m0s` | Scan timeout duration |
|
| `timeout` | String | `5m0s` | Scan timeout duration |
|
||||||
| `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 |
|
||||||
| `list-all-pkgs` | String | | Output all packages regardless of vulnerability |
|
| `list-all-pkgs` | String | | Output all packages regardless of vulnerability |
|
||||||
| `security-checks`| String | `vuln` | comma-separated list of what security issues to detect (`vuln`,`config`)|
|
| `security-checks`| 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 |
|
||||||
|
|
||||||
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
|
[release]: https://github.com/aquasecurity/trivy-action/releases/latest
|
||||||
[release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github
|
[release-img]: https://img.shields.io/github/release/aquasecurity/trivy-action.svg?logo=github
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ inputs:
|
|||||||
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: ''
|
||||||
|
trivyignores:
|
||||||
|
description: 'comma-separated list of relative paths in repository to one or more .trivyignore files'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
runs:
|
runs:
|
||||||
using: 'docker'
|
using: 'docker'
|
||||||
image: "Dockerfile"
|
image: "Dockerfile"
|
||||||
@@ -100,3 +104,4 @@ runs:
|
|||||||
- '-q ${{ inputs.skip-files }}'
|
- '-q ${{ inputs.skip-files }}'
|
||||||
- '-r ${{ inputs.list-all-pkgs }}'
|
- '-r ${{ inputs.list-all-pkgs }}'
|
||||||
- '-s ${{ inputs.security-checks }}'
|
- '-s ${{ inputs.security-checks }}'
|
||||||
|
- '-t ${{ inputs.trivyignores }}'
|
||||||
|
|||||||
+19
-2
@@ -1,6 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:" o; do
|
while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:" o; do
|
||||||
case "${o}" in
|
case "${o}" in
|
||||||
a)
|
a)
|
||||||
export scanType=${OPTARG}
|
export scanType=${OPTARG}
|
||||||
@@ -59,6 +59,9 @@ while getopts "a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:" o; do
|
|||||||
s)
|
s)
|
||||||
export securityChecks=${OPTARG}
|
export securityChecks=${OPTARG}
|
||||||
;;
|
;;
|
||||||
|
t)
|
||||||
|
export trivyIgnores=${OPTARG}
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -98,7 +101,7 @@ if [ $vulnType ] && [ "$scanType" != "config" ];then
|
|||||||
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 ] && [ "$scanType" == "fs" ];then
|
if [ $securityChecks ];then
|
||||||
ARGS="$ARGS --security-checks $securityChecks"
|
ARGS="$ARGS --security-checks $securityChecks"
|
||||||
fi
|
fi
|
||||||
if [ $severity ];then
|
if [ $severity ];then
|
||||||
@@ -114,6 +117,20 @@ if [ $skipDirs ];then
|
|||||||
SARIF_ARGS="$SARIF_ARGS --skip-dirs $i"
|
SARIF_ARGS="$SARIF_ARGS --skip-dirs $i"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
if [ $trivyIgnores ];then
|
||||||
|
for f in $(echo $trivyIgnores | tr "," "\n")
|
||||||
|
do
|
||||||
|
if [ -f "$f" ]; then
|
||||||
|
echo "Found ignorefile '${f}':"
|
||||||
|
cat "${f}"
|
||||||
|
cat "${f}" >> ./trivyignores
|
||||||
|
else
|
||||||
|
echo "ERROR: cannot find ignorefile '${f}'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
ARGS="$ARGS --ignorefile ./trivyignores"
|
||||||
|
fi
|
||||||
if [ $timeout ];then
|
if [ $timeout ];then
|
||||||
ARGS="$ARGS --timeout $timeout"
|
ARGS="$ARGS --timeout $timeout"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# test data #1 for trivy-ignores option
|
||||||
|
CVE-2020-25576
|
||||||
|
CVE-2019-15551
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
# test data #2 for trivy-ignores option
|
||||||
|
CVE-2019-15554
|
||||||
+56
-8
@@ -1,8 +1,56 @@
|
|||||||
+---------------------------+------------+-----------+----------+------------------------------------------+
|
{
|
||||||
| TYPE | MISCONF ID | CHECK | SEVERITY | MESSAGE |
|
"SchemaVersion": 2,
|
||||||
+---------------------------+------------+-----------+----------+------------------------------------------+
|
"ArtifactName": ".",
|
||||||
| Dockerfile Security Check | DS002 | root user | HIGH | Specify at least 1 USER |
|
"ArtifactType": "filesystem",
|
||||||
| | | | | command in Dockerfile with |
|
"Metadata": {
|
||||||
| | | | | non-root user as argument |
|
"ImageConfig": {
|
||||||
| | | | | -->avd.aquasec.com/appshield/ds002 |
|
"architecture": "",
|
||||||
+---------------------------+------------+-----------+----------+------------------------------------------+
|
"created": "0001-01-01T00:00:00Z",
|
||||||
|
"os": "",
|
||||||
|
"rootfs": {
|
||||||
|
"type": "",
|
||||||
|
"diff_ids": null
|
||||||
|
},
|
||||||
|
"config": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Results": [
|
||||||
|
{
|
||||||
|
"Target": "Dockerfile",
|
||||||
|
"Class": "config",
|
||||||
|
"Type": "dockerfile",
|
||||||
|
"MisconfSummary": {
|
||||||
|
"Successes": 21,
|
||||||
|
"Failures": 1,
|
||||||
|
"Exceptions": 0
|
||||||
|
},
|
||||||
|
"Misconfigurations": [
|
||||||
|
{
|
||||||
|
"Type": "Dockerfile Security Check",
|
||||||
|
"ID": "DS002",
|
||||||
|
"Title": "Image user should not be 'root'",
|
||||||
|
"Description": "Running containers with 'root' user can lead to a container escape situation. It is a best practice to run containers as non-root users, which can be done by adding a 'USER' statement to the Dockerfile.",
|
||||||
|
"Message": "Specify at least 1 USER command in Dockerfile with non-root user as argument",
|
||||||
|
"Namespace": "builtin.dockerfile.DS002",
|
||||||
|
"Query": "data.builtin.dockerfile.DS002.deny",
|
||||||
|
"Resolution": "Add 'USER \u003cnon root user name\u003e' line to the Dockerfile",
|
||||||
|
"Severity": "HIGH",
|
||||||
|
"PrimaryURL": "https://avd.aquasec.com/misconfig/ds002",
|
||||||
|
"References": [
|
||||||
|
"https://docs.docker.com/develop/develop-images/dockerfile_best-practices/",
|
||||||
|
"https://avd.aquasec.com/misconfig/ds002"
|
||||||
|
],
|
||||||
|
"Status": "FAIL",
|
||||||
|
"Layer": {},
|
||||||
|
"CauseMetadata": {
|
||||||
|
"Provider": "Dockerfile",
|
||||||
|
"Service": "general",
|
||||||
|
"Code": {
|
||||||
|
"Lines": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"SchemaVersion": 2,
|
||||||
|
"ArtifactName": ".",
|
||||||
|
"ArtifactType": "filesystem",
|
||||||
|
"Metadata": {
|
||||||
|
"ImageConfig": {
|
||||||
|
"architecture": "",
|
||||||
|
"created": "0001-01-01T00:00:00Z",
|
||||||
|
"os": "",
|
||||||
|
"rootfs": {
|
||||||
|
"type": "",
|
||||||
|
"diff_ids": null
|
||||||
|
},
|
||||||
|
"config": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Results": [
|
||||||
|
{
|
||||||
|
"Target": "Dockerfile",
|
||||||
|
"Class": "config",
|
||||||
|
"Type": "dockerfile",
|
||||||
|
"MisconfSummary": {
|
||||||
|
"Successes": 21,
|
||||||
|
"Failures": 1,
|
||||||
|
"Exceptions": 0
|
||||||
|
},
|
||||||
|
"Misconfigurations": [
|
||||||
|
{
|
||||||
|
"Type": "Dockerfile Security Check",
|
||||||
|
"ID": "DS002",
|
||||||
|
"Title": "Image user should not be 'root'",
|
||||||
|
"Description": "Running containers with 'root' user can lead to a container escape situation. It is a best practice to run containers as non-root users, which can be done by adding a 'USER' statement to the Dockerfile.",
|
||||||
|
"Message": "Specify at least 1 USER command in Dockerfile with non-root user as argument",
|
||||||
|
"Namespace": "builtin.dockerfile.DS002",
|
||||||
|
"Query": "data.builtin.dockerfile.DS002.deny",
|
||||||
|
"Resolution": "Add 'USER \u003cnon root user name\u003e' line to the Dockerfile",
|
||||||
|
"Severity": "HIGH",
|
||||||
|
"PrimaryURL": "https://avd.aquasec.com/misconfig/ds002",
|
||||||
|
"References": [
|
||||||
|
"https://docs.docker.com/develop/develop-images/dockerfile_best-practices/",
|
||||||
|
"https://avd.aquasec.com/misconfig/ds002"
|
||||||
|
],
|
||||||
|
"Status": "FAIL",
|
||||||
|
"Layer": {},
|
||||||
|
"CauseMetadata": {
|
||||||
|
"Provider": "Dockerfile",
|
||||||
|
"Service": "general",
|
||||||
|
"Code": {
|
||||||
|
"Lines": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -442,7 +442,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "0.26.0"
|
"version": "0.29.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"results": [
|
"results": [
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
+1478
-107
File diff suppressed because it is too large
Load Diff
+19
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"SchemaVersion": 2,
|
"SchemaVersion": 2,
|
||||||
"ArtifactName": "https://github.com/aquasecurity/trivy-action/",
|
"ArtifactName": "https://github.com/krol3/demo-trivy/",
|
||||||
"ArtifactType": "repository",
|
"ArtifactType": "repository",
|
||||||
"Metadata": {
|
"Metadata": {
|
||||||
"ImageConfig": {
|
"ImageConfig": {
|
||||||
@@ -13,5 +13,22 @@
|
|||||||
},
|
},
|
||||||
"config": {}
|
"config": {}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"Results": [
|
||||||
|
{
|
||||||
|
"Target": "env",
|
||||||
|
"Class": "secret",
|
||||||
|
"Secrets": [
|
||||||
|
{
|
||||||
|
"RuleID": "github-pat",
|
||||||
|
"Category": "GitHub",
|
||||||
|
"Severity": "CRITICAL",
|
||||||
|
"Title": "GitHub Personal Access Token",
|
||||||
|
"StartLine": 5,
|
||||||
|
"EndLine": 5,
|
||||||
|
"Match": "export GITHUB_PAT=*****"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-14
@@ -1,50 +1,57 @@
|
|||||||
#!/usr/bin/env bats
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
@test "trivy image" {
|
@test "trivy image" {
|
||||||
# trivy image --severity CRITICAL -o image.test knqyf263/vuln-image:1.2.3
|
# trivy image --severity CRITICAL --format json --output image.test knqyf263/vuln-image:1.2.3
|
||||||
./entrypoint.sh '-a image' '-i knqyf263/vuln-image:1.2.3' '-b table' '-h image.test' '-g CRITICAL'
|
./entrypoint.sh '-a image' '-i knqyf263/vuln-image:1.2.3' '-b json' '-h image.test' '-g CRITICAL'
|
||||||
result="$(diff ./test/data/image.test image.test)"
|
result="$(diff ./test/data/image.test image.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy image sarif report" {
|
@test "trivy image sarif report" {
|
||||||
# trivy image --severity CRITICAL -f sarif -o image-sarif.test knqyf263/vuln-image:1.2.3
|
# trivy image --severity CRITICAL -f sarif --output image-sarif.test knqyf263/vuln-image:1.2.3
|
||||||
./entrypoint.sh '-a image' '-i knqyf263/vuln-image:1.2.3' '-b sarif' '-h image-sarif.test' '-g CRITICAL'
|
./entrypoint.sh '-a image' '-i knqyf263/vuln-image:1.2.3' '-b sarif' '-h image-sarif.test' '-g CRITICAL'
|
||||||
result="$(diff ./test/data/image-sarif.test image-sarif.test)"
|
result="$(diff ./test/data/image-sarif.test image-sarif.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy config" {
|
@test "trivy config" {
|
||||||
# trivy conf -o config.test .
|
# trivy config --format json --output config.test .
|
||||||
./entrypoint.sh '-a config' '-j .' '-b table' '-h config.test'
|
./entrypoint.sh '-a config' '-j .' '-b json' '-h config.test'
|
||||||
result="$(diff ./test/data/config.test config.test)"
|
result="$(diff ./test/data/config.test config.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy rootfs" {
|
@test "trivy rootfs" {
|
||||||
# trivy rootfs -o rootfs.test -f json .
|
# trivy rootfs --format json --output rootfs.test .
|
||||||
./entrypoint.sh '-a rootfs' '-j .' '-b json' '-h rootfs.test'
|
./entrypoint.sh '-a rootfs' '-j .' '-b json' '-h rootfs.test'
|
||||||
result="$(diff ./test/data/rootfs.test rootfs.test)"
|
result="$(diff ./test/data/rootfs.test rootfs.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy fs" {
|
@test "trivy fs" {
|
||||||
# trivy fs -f json -o fs.test .
|
# trivy fs --format json --output fs.test .
|
||||||
./entrypoint.sh '-a fs' '-j .' '-b json' '-h fs.test'
|
./entrypoint.sh '-a fs' '-j .' '-b json' '-h fs.test'
|
||||||
result="$(diff ./test/data/fs.test fs.test)"
|
result="$(diff ./test/data/fs.test fs.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy fs with securityChecks option" {
|
@test "trivy fs with securityChecks option" {
|
||||||
# trivy fs -f json --security-checks=vuln,config -o fs.test .
|
# trivy fs --format json --security-checks=vuln,config --output fs-scheck.test .
|
||||||
./entrypoint.sh '-a fs' '-j .' '-b json' '-s vuln,config' '-h fs-scheck.test'
|
./entrypoint.sh '-a fs' '-j .' '-b json' '-s vuln,config,secret' '-h fs-scheck.test'
|
||||||
result="$(diff ./test/data/fs.test fs.test)"
|
result="$(diff ./test/data/fs-scheck.test fs-scheck.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "trivy repo" {
|
@test "trivy repo with securityCheck secret only" {
|
||||||
# trivy repo -f json -o repo.test --severity CRITICAL https://github.com/aquasecurity/trivy-action/
|
# trivy repo --format json --output repo.test --security-checks=secret https://github.com/krol3/demo-trivy/
|
||||||
./entrypoint.sh '-b json' '-h repo.test' '-g CRITICAL' '-a repo' '-j https://github.com/aquasecurity/trivy-action/'
|
./entrypoint.sh '-b json' '-h repo.test' '-s secret' '-a repo' '-j https://github.com/krol3/demo-trivy/'
|
||||||
result="$(diff ./test/data/repo.test repo.test)"
|
result="$(diff ./test/data/repo.test repo.test)"
|
||||||
[ "$result" == '' ]
|
[ "$result" == '' ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "trivy image with trivyIgnores option" {
|
||||||
|
# cat ./test/data/.trivyignore1 ./test/data/.trivyignore2 > ./trivyignores ; trivy image --severity CRITICAL --format json --output image-trivyignores.test --ignorefile ./trivyignores knqyf263/vuln-image:1.2.3
|
||||||
|
./entrypoint.sh '-a image' '-i knqyf263/vuln-image:1.2.3' '-b json' '-h image-trivyignores.test' '-g CRITICAL' '-t ./test/data/.trivyignore1,./test/data/.trivyignore2'
|
||||||
|
result="$(diff ./test/data/image-trivyignores.test image-trivyignores.test)"
|
||||||
|
[ "$result" == '' ]
|
||||||
|
}
|
||||||
|
|||||||
+1
-1
@@ -29,6 +29,6 @@ jobs:
|
|||||||
severity: 'CRITICAL,HIGH'
|
severity: 'CRITICAL,HIGH'
|
||||||
|
|
||||||
- name: Upload Trivy scan results to GitHub Security tab
|
- name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v1
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
|
|||||||
Reference in New Issue
Block a user