Skip to content

Commit

Permalink
Merge branch 'release/v2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nfranzeck committed Sep 27, 2024
2 parents 8f8be71 + 6e8563b commit 901c96b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v2.5.0] - 2024-09-27
### Added
- [#49] Add feature to use a .trivyignore file to ignore cve that are false positives

## [v2.4.0] - 2024-09-18
### Changed
- Relicense to AGPL-3.0-only
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.cloudogu.ces</groupId>
<artifactId>dogu-build-lib</artifactId>
<name>dogu-build-lib</name>
<version>2.4.0</version>
<version>2.5.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
9 changes: 7 additions & 2 deletions src/com/cloudogu/ces/dogubuildlib/Trivy.groovy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,21 @@ class Trivy {
"-v /vagrant/trivy/output:/output " +
"-v /vagrant/trivy/cache:/root/.cache/ " +
"-v /var/run/docker.sock:/var/run/docker.sock " +
"-v /dogu/.trivyignore:/trivy/.trivyignore " +
"aquasec/trivy image " +
formatFlags(format, fileName) + " " +
"--exit-code 1 " +
"--severity ${level} " +
"${image} &> /dev/null; echo \\\$?"
"--debug " +
"--ignorefile /trivy/.trivyignore " +
"${image} &>> ./trivyscan.log; echo \\\$?"

def exitCode = this.vagrant().sshOut(command)

boolean ok = exitCode == "0"

this.vagrant().scp(":/vagrant/trivy/output", "trivy")
this.vagrant().scp(":./trivyscan.log", "trivy/output")
this.script.archiveArtifacts artifacts: 'trivy/output/trivyscan.*', allowEmptyArchive: true

if (!ok && strategy == TrivyScanStrategy.UNSTABLE) {
Expand All @@ -79,7 +85,6 @@ class Trivy {
return ok
}


/**
* Extracts the image and the version from the dogu.json in a doguPath to get the exact image name.
* @param doguPath The path of the dogu sources
Expand Down
9 changes: 6 additions & 3 deletions test/com/cloudogu/ces/dogubuildlib/TrivyTest.groovy
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,15 @@ class TrivyTest {
@Test
void scanUsesCorrectImage() {
trivy.scan("myimage", "plain", "critical,asdf,asdf123", "ignore")
verify(vagrant, times(1)).sshOut(matches(/^.*myimage &> \/dev\/null; echo \\\$\?$/))
verify(vagrant, times(1)).sshOut(matches(/^.*myimage &>> .\/trivyscan.log; echo \\\$\?$/))
}

@Test
void scanDoguExtractsCorrectDoguImageName() {
doReturn("registry.cloudogu.com/official/nginx").when(vagrant).sshOut("jq .Image /dogu/dogu.json")
doReturn("1.0.0-1").when(vagrant).sshOut("jq .Version /dogu/dogu.json")
trivy.scanDogu("/dogu", "plain", "critical,asdf,asdf123", "ignore")
verify(vagrant, times(1)).sshOut(matches(/^.*registry.cloudogu.com\/official\/nginx:1.0.0-1 &> \/dev\/null; echo \\\$\?$/))
verify(vagrant, times(1)).sshOut(matches(/^.*registry.cloudogu.com\/official\/nginx:1.0.0-1 &>> .\/trivyscan.log; echo \\\$\?$/))
}

@Test
Expand All @@ -194,12 +194,15 @@ class TrivyTest {
"-v /vagrant/trivy/output:/output " +
"-v /vagrant/trivy/cache:/root/.cache/ " +
"-v /var/run/docker.sock:/var/run/docker.sock " +
"-v /dogu/.trivyignore:/trivy/.trivyignore " +
"aquasec/trivy image " +
"-f json " +
"--output /output/myfilename " +
"--exit-code 1 " +
"--severity critical " +
"null:null &> /dev/null; echo \\\$?")
"--debug " +
"--ignorefile /trivy/.trivyignore " +
"null:null &>> ./trivyscan.log; echo \\\$?")
trivy.scanDogu("/dogu", "json", "critical", "fail", "myfilename")
}
}

0 comments on commit 901c96b

Please sign in to comment.