Fix packages + Implement working tests

Signed-off-by: guillaume <guillaume.derouville@gmail.com>
This commit is contained in:
guillaume
2021-10-28 01:37:52 +02:00
parent 701be92dad
commit 3fb03cd2d7
7 changed files with 201 additions and 40 deletions

View File

@@ -16,13 +16,12 @@ import (
// Trivy Image arguments
args: [arg=string]: string
// Enforce args best practices
args: {
"--exit-code": *"1" | string
"--severity": *"HIGH,CRITICAL" | string
"--format": *"table" | string
"--ignore-unfixed": *"true" | string
"--severity": *"HIGH,CRITICAL" | string
"--exit-code": *"1" | string
"--ignore-unfixed": *"" | string
"--format": *"table" | string
}
ctr: os.#Container & {
@@ -33,6 +32,7 @@ import (
path: "/bin/bash"
args: ["--noprofile", "--norc", "-eo", "pipefail", "-c"]
}
always: true
command: #"""
trivyArgs="$(
echo "$ARGS" |
@@ -42,18 +42,22 @@ import (
add
')"
trivy image "$trivyArgs" "$SOURCE"
echo "$SOURCE" > /ref
# Remove suffix and prefix quotes if present
trivyArgs="${trivyArgs#\"}"
trivyArgs="${trivyArgs%\"}"
trivy image $trivyArgs "$SOURCE"
echo -n "$SOURCE" > /ref
"""#
env: ARGS: json.Marshal(args)
env: SOURCE: source
}
// Export ref to create dependency (wait for the check to finish)
// Reference analyzed
ref: {
os.#File & {
from: ctr
path: "/ref"
}
from: ctr
path: "/ref"
}
}.contents @dagger(output)
}