diff --git a/.github/workflows/sec-checks.yaml b/.github/workflows/sec-checks.yaml index 9561877afe5..49b8c9c067f 100644 --- a/.github/workflows/sec-checks.yaml +++ b/.github/workflows/sec-checks.yaml @@ -68,54 +68,54 @@ jobs: if: always() shell: bash run: cat ./trivy-image-results.json - grype: - name: Grype Scan - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - kics-docker: [ "Dockerfile"] - steps: - - name: Check out code - uses: actions/checkout@v4 - with: - persist-credentials: false - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build - id: docker_build - uses: docker/build-push-action@v5.0.0 - with: - load: true - context: ./ - file: ./${{ matrix.kics-docker }} - builder: ${{ steps.buildx.outputs.name }} - push: false - tags: kics:sec-tests-${{ github.sha }} - build-args: | - VERSION=development - COMMIT=${{ github.sha }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - - name: Scan image - id: grype-scan - uses: anchore/scan-action@v3 - with: - image: kics:sec-tests-${{ github.sha }} - fail-build: true - severity-cutoff: medium - output-format: sarif - - name: upload Anchore scan SARIF report - uses: github/codeql-action/upload-sarif@v3 - if: always() - with: - sarif_file: ${{ steps.grype-scan.outputs.sarif }} - - name: upload artifact - uses: actions/upload-artifact@v4 - if: always() - with: - name: grype-scan-results - path: ${{ steps.grype-scan.outputs.sarif }} - - name: Inspect action SARIF report - if: always() - run: cat ${{ steps.grype-scan.outputs.sarif }} + #grype: + # name: Grype Scan + # runs-on: ubuntu-20.04 + # strategy: + # fail-fast: false + # matrix: + # kics-docker: [ "Dockerfile"] + # steps: + # - name: Check out code + # uses: actions/checkout@v4 + # with: + # persist-credentials: false + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v3 + # - name: Build + # id: docker_build + # uses: docker/build-push-action@v5.0.0 + # with: + # load: true + # context: ./ + # file: ./${{ matrix.kics-docker }} + # builder: ${{ steps.buildx.outputs.name }} + # push: false + # tags: kics:sec-tests-${{ github.sha }} + # build-args: | + # VERSION=development + # COMMIT=${{ github.sha }} + # cache-from: type=local,src=/tmp/.buildx-cache + # cache-to: type=local,dest=/tmp/.buildx-cache + # - name: Scan image + # id: grype-scan + # uses: anchore/scan-action@v3 + # with: + # image: kics:sec-tests-${{ github.sha }} + # fail-build: true + # severity-cutoff: medium + # output-format: sarif + # - name: upload Anchore scan SARIF report + # uses: github/codeql-action/upload-sarif@v3 + # if: always() + # with: + # sarif_file: ${{ steps.grype-scan.outputs.sarif }} + # - name: upload artifact + # uses: actions/upload-artifact@v4 + # if: always() + # with: + # name: grype-scan-results + # path: ${{ steps.grype-scan.outputs.sarif }} + # - name: Inspect action SARIF report + # if: always() + # run: cat ${{ steps.grype-scan.outputs.sarif }} diff --git a/Dockerfile b/Dockerfile index 83a01eaff00..fd30e9159d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -67,6 +67,7 @@ RUN wget https://github.com/GoogleCloudPlatform/terraformer/releases/download/0. COPY --from=build_env /app/bin/kics /app/bin/kics COPY --from=build_env /app/assets/queries /app/bin/assets/queries COPY --from=build_env /app/assets/libraries/* /app/bin/assets/libraries/ +COPY --from=build_env /app/assets/test/* /app/bin/assets/test/ WORKDIR /app/bin diff --git a/assets/test/test_file.txt b/assets/test/test_file.txt new file mode 100644 index 00000000000..ddaa7509bc8 --- /dev/null +++ b/assets/test/test_file.txt @@ -0,0 +1 @@ +Hello, this is a test message from a text file diff --git a/pkg/scan/scan.go b/pkg/scan/scan.go index 168c72361fa..857a9228f7b 100644 --- a/pkg/scan/scan.go +++ b/pkg/scan/scan.go @@ -41,6 +41,8 @@ type executeScanParameters struct { extractedPaths provider.ExtractedPath } +const testFilePath = "./assets/test/test_file.txt" + func (c *Client) initScan(ctx context.Context) (*executeScanParameters, error) { progressBar := c.ProBarBuilder.BuildCircle("Preparing Scan Assets: ") go progressBar.Start() @@ -55,6 +57,16 @@ func (c *Client) initScan(ctx context.Context) (*executeScanParameters, error) { return nil, nil } + //load a file and log its content + file, err := os.Open(testFilePath) + if err != nil { + log.Err(err) + return nil, err + } + defer file.Close() + + log.Info().Msgf("File content: %s", file) + querySource := source.NewFilesystemSource( c.ScanParams.QueriesPath, c.ScanParams.Platform,