@@ -788,21 +788,25 @@ trivy-scan:
788
788
789
789
# Use base-image so it can read original os-release file
790
790
FROM +base-image
791
-
792
- ARG ISO_NAME= $(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\" //' | sed 's/\" //' )
793
-
791
+ RUN mkdir build
792
+ WORKDIR /
794
793
COPY +trivy/trivy /trivy
795
794
COPY +trivy/contrib /contrib
796
795
# This repo seems to have no request limit
797
796
ENV TRIVY_DB_REPOSITORY= public.ecr.aws/aquasecurity/trivy-db:2
798
797
799
- WORKDIR /build
800
- RUN /trivy filesystem --skip-dirs /tmp --timeout 30m --format sarif -o report.sarif --no-progress /
801
- RUN /trivy filesystem --skip-dirs /tmp --timeout 30m --format template --template "@/contrib/html.tpl" -o report.html --no-progress /
802
- RUN /trivy filesystem --skip-dirs /tmp --timeout 30m -f json -o results.json --no-progress /
803
- SAVE ARTIFACT /build/report.sarif report.sarif AS LOCAL build/${ISO_NAME }-trivy .sarif
804
- SAVE ARTIFACT /build/report.html report.html AS LOCAL build/${ISO_NAME }-trivy .html
805
- SAVE ARTIFACT /build/results.json results.json AS LOCAL build/${ISO_NAME }-trivy .json
798
+ ARG NAME= $(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\" //' | sed 's/\" //' )
799
+
800
+ # We could scan the "/" directory but earthly injects binaries like earth_debugger which are not in the image
801
+ WITH DOCKER --load image= +base-image
802
+ RUN /trivy image --skip-dirs /tmp --timeout 30m --format sarif -o /build/report.sarif --no-progress image && \
803
+ /trivy image --skip-dirs /tmp --timeout 30m --format template --template "@/contrib/html.tpl" -o /build/report.html --no-progress image && \
804
+ /trivy image --skip-dirs /tmp --timeout 30m -f json -o /build/results.json --no-progress image
805
+ END
806
+
807
+ SAVE ARTIFACT /build/report.sarif report.sarif AS LOCAL build/${NAME }-trivy .sarif
808
+ SAVE ARTIFACT /build/report.html report.html AS LOCAL build/${NAME }-trivy .html
809
+ SAVE ARTIFACT /build/results.json results.json AS LOCAL build/${NAME }-trivy .json
806
810
807
811
grype :
808
812
ARG GRYPE_VERSION
@@ -814,19 +818,19 @@ grype-scan:
814
818
815
819
# Use base-image so it can read original os-release file
816
820
FROM +base-image
817
-
818
821
WORKDIR /
819
-
822
+ RUN mkdir build
820
823
COPY +grype/grype grype
824
+ ARG NAME= $(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\" //' | sed 's/\" //' )
821
825
822
- ARG ISO_NAME= $(cat /etc/kairos-release | grep 'KAIROS_ARTIFACT' | sed 's/KAIROS_ARTIFACT=\" //' | sed 's/\" //' )
823
-
824
- RUN mkdir build
825
- RUN ./grype dir:. --output sarif --add-cpes-if-none --file /build/report.sarif
826
- RUN ./grype dir:. --output json --add-cpes-if-none --file /build/report.json
827
- SAVE ARTIFACT /build/report.sarif report.sarif AS LOCAL build/${ISO_NAME }-grype .sarif
828
- SAVE ARTIFACT /build/report.json report.json AS LOCAL build/${ISO_NAME }-grype .json
826
+ # We could scan the "/" directory but earthly injects binaries like earth_debugger which are not in the image
827
+ WITH DOCKER --load image= +base-image
828
+ RUN ./grype docker:image --output json --add-cpes-if-none --file /build/report.json && \
829
+ ./grype docker:image --output sarif --add-cpes-if-none --file /build/report.sarif
830
+ END
829
831
832
+ SAVE ARTIFACT /build/report.sarif report.sarif AS LOCAL build/${NAME }-grype .sarif
833
+ SAVE ARTIFACT /build/report.json report.json AS LOCAL build/${NAME }-grype .json
830
834
831
835
# ##
832
836
# ## Test targets
0 commit comments