Skip to content

Commit

Permalink
chore: update test to version 0.27.1 (#106)
Browse files Browse the repository at this point in the history
* chore: update test to version 0.27.0

* chore: add test file secret and update to 0.27.1

* fix: support repository with securityCheck secret

Co-authored-by: carolina valencia <krol3@users.noreply.github.com>
  • Loading branch information
krol3 and krol3 committed May 9, 2022
1 parent 2b30463 commit 4b9b6fb
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "build"
on: [push, pull_request]
env:
TRIVY_VERSION: 0.26.0
TRIVY_VERSION: 0.27.1
jobs:
build:
name: build
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM aquasec/trivy:0.26.0
FROM aquasec/trivy:0.27.1
COPY entrypoint.sh /
RUN apk --no-cache add bash
RUN chmod +x /entrypoint.sh
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ fi
if [ $securityChecks ] && [ "$scanType" == "fs" ];then
ARGS="$ARGS --security-checks $securityChecks"
fi
if [ $securityChecks ] && [ "$scanType" == "repo" ];then
ARGS="$ARGS --security-checks $securityChecks"
fi
if [ $severity ];then
ARGS="$ARGS --severity $severity"
fi
Expand Down
50 changes: 50 additions & 0 deletions test/data/fs-scheck.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"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": 22,
"Failures": 1,
"Exceptions": 0
},
"Misconfigurations": [
{
"Type": "Dockerfile Security Check",
"ID": "DS002",
"Title": "root user",
"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": "appshield.dockerfile.DS002",
"Query": "data.appshield.dockerfile.DS002.deny",
"Resolution": "Add 'USER \u003cnon root user name\u003e' line to the Dockerfile",
"Severity": "HIGH",
"PrimaryURL": "https://avd.aquasec.com/appshield/ds002",
"References": [
"https://docs.docker.com/develop/develop-images/dockerfile_best-practices/",
"https://avd.aquasec.com/appshield/ds002"
],
"Status": "FAIL",
"Layer": {},
"IacMetadata": {}
}
]
}
]
}
2 changes: 1 addition & 1 deletion test/data/image-sarif.test
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@
}
}
],
"version": "0.26.0"
"version": "0.27.1"
}
},
"results": [
Expand Down
21 changes: 19 additions & 2 deletions test/data/repo.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"SchemaVersion": 2,
"ArtifactName": "https://github.com/aquasecurity/trivy-action/",
"ArtifactName": "https://github.com/krol3/demo-trivy/",
"ArtifactType": "repository",
"Metadata": {
"ImageConfig": {
Expand All @@ -13,5 +13,22 @@
},
"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=*****"
}
]
}
]
}
8 changes: 4 additions & 4 deletions test/test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@

@test "trivy fs with securityChecks option" {
# trivy fs -f json --security-checks=vuln,config -o fs.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" == '' ]
}

@test "trivy repo" {
# trivy repo -f json -o repo.test --severity CRITICAL https://github.com/aquasecurity/trivy-action/
./entrypoint.sh '-b json' '-h repo.test' '-g CRITICAL' '-a repo' '-j https://github.com/aquasecurity/trivy-action/'
@test "trivy repo with securityCheck secret only" {
# trivy repo -f json -o repo.test --security-checks=secret https://github.com/krol3/demo-trivy/
./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" == '' ]
}

0 comments on commit 4b9b6fb

Please sign in to comment.