Giter Site home page Giter Site logo

container-scan's Introduction

Container Scan

Deprecation Notice

This project is no longer actively maintained, and has had some deficiencies for sometime now. If anyone is interested to implement the action logic on their own or fork the repo then feel free to do so. Adding few consise points below on what this action does, which might help others to replicate it.

  1. Trivy and Dockle are used internally for running certain kinds of scans on images.
  2. It accepts some necessary inputs that are passed to Trivy/Dockle to run cli commands.
  3. It allows users to update an allowedlist of vulnerabilities for the repo. So that the action doesn't shows up the allowed vulnerabilites on every run.
  4. For leveraging this feature the scanitizer app needs to be installed/integrated for consumption of appropriate APIs to update the allowedlist for the repo.

This action may be archived in the future, but it will still be consumable in the workflows. Just that it won't be maintained in the future.

Overview

This action can be used to help you add some additional checks to help you secure your Docker Images in your CI. This would help you attain some confidence in your docker image before pushing them to your container registry or a deployment.

It internally uses Trivy and Dockle for running certain kinds of scans on these images.

  • Trivy helps you find the common vulnerabilities within your docker images.
  • Dockle is a container linter, which helps you identify if you haven't followed
    • Certain best practices while building the image
    • CIS Benchmarks to secure your docker image

Please checkout Trivy and Dockle licenses.

Action inputs

Action input Description Default Value
image-name (Required) The Docker image to be scanned ''
severity-threshold (Optional) Minimum severity threshold set to control flagging of the vulnerabilities found during the scan. The available levels are: (UNKNOWN, LOW, MEDIUM, HIGH, CRITICAL); if you set the severity-threshold to be `MEDIUM` every CVE found of a level higher than or equal to `MEDIUM` would be displayed HIGH
run-quality-checks (Optional) This is a boolean value. When set to `true` adds additional checks to ensure the image follows best practices and CIS standards. true
username (Optional) Username to authenticate to the Docker registry. This is only required when you're trying to pull an image from your private registry ''
password (Optional) Password to authenticate to the Docker registry. This is only required when you're trying to pull an image from your private registry ''
trivy-version (Optional) Version of Trivy to run, e.g. 0.22.0. The default is to use latest version. ''

Action output

The action generates an output file consisting of detailed description of all the detected vulnerabilities and best practice violations in JSON format. This file can be accessed by using the output variable scan-report-path.
Here is a sample scan report:

{
  "imageName": "myacr.azurecr.io/testapp:770aed6bd33d7240b4bdb55f16348ce37b86bb09",
  "vulnerabilities": [
    {
      "vulnerabilityId": "CVE-2018-12886",
      "packageName": "gcc-8-base",
      "severity": "HIGH",
      "description": "stack_protect_prologue in cfgexpand.c and stack_protect_epilogue in function.c in GNU Compiler Collection (GCC) 4.1 through 8 (under certain circumstances) generate instruction sequences when targeting ARM targets that spill the address of the stack protector guard, which allows an attacker to bypass the protection of -fstack-protector, -fstack-protector-all, -fstack-protector-strong, and -fstack-protector-explicit against stack overflow by controlling what the stack canary is compared against.",
      "target": "myacr.azurecr.io/ascdemo:770aed6bd33d7240b4bdb55f16348ce37b86bb09 (debian 10.4)"
    },
    {
      "vulnerabilityId": "CVE-2019-20367",
      "packageName": "libbsd0",
      "severity": "CRITICAL",
      "description": "nlist.c in libbsd before 0.10.0 has an out-of-bounds read during a comparison for a symbol name from the string table (strtab).",
      "target": "myacr.azurecr.io/ascdemo:770aed6bd33d7240b4bdb55f16348ce37b86bb09 (debian 10.4)"
    },
    {
      "vulnerabilityId": "CVE-2020-1751",
      "packageName": "libc-bin",
      "severity": "HIGH",
      "description": "An out-of-bounds write vulnerability was found in glibc before 2.31 when handling signal trampolines on PowerPC. Specifically, the backtrace function did not properly check the array bounds when storing the frame address, resulting in a denial of service or potential code execution. The highest threat from this vulnerability is to system availability.",
      "target": "myacr.azurecr.io/ascdemo:770aed6bd33d7240b4bdb55f16348ce37b86bb09 (debian 10.4)"
    }
  ],
  "bestPracticeViolations": [
    {
      "code": "CIS-DI-0001",
      "title": "Create a user for the container",
      "level": "WARN",
      "alerts": "Last user should not be root"
    },
    {
      "code": "CIS-DI-0005",
      "title": "Enable Content trust for Docker",
      "level": "INFO",
      "alerts": "export DOCKER_CONTENT_TRUST=1 before docker pull/build"
    }
  ],
  "vulnerabilityScanTimestamp": "2021-03-05T09:38:48.036Z"
}

Ignoring vulnerabilities

In case you would like the action to ignore any vulnerabilities and best practice checks, create an allowedlist file at the path .github/containerscan/allowedlist.yaml in your repo. Here's an example allowedlist.yaml file.

general:
  vulnerabilities:
    - CVE-2003-1307
    - CVE-2007-0086
    - CVE-2019-3462
    - CVE-2011-3374
  bestPracticeViolations:
    - CIS-DI-0005
    - DKL-LI-0003
    - CIS-DI-0006
    - DKL-DI-0006

Install Scanitizer (currently in Beta) on your repository for more convenient management of allowedlist file.

Example YAML snippets

Container scan of an image available locally or publically available on dockerhub

- uses: azure/container-scan@v0
  with:
    image-name: my-image:my-tag

Container scan of an image available on a private registry

- uses: azure/container-scan@v0
  with:
    image-name: loginServerUrl/my-image:${{ github.sha }} # loginServerlUrl/ would be empty if it's hosted on dockerhub; ${{ github.sha }} could also be replaced with any desired image tag
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}

Container scan of an image available locally, publically, or privately using workflow environment variables

- uses: azure/container-scan@v0
  with:
    image-name: ${{ env.loginServerUrl }}/my-image:${{ github.sha }} # ${{ env.loginServerUrl }}/ would be empty if it's hosted on dockerhub; ${{ github.sha }} could also be replaced with any desired image tag
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}

End to end workflow using Azure

The following is an example of not just this action, but how this action could be used along with other actions to setup a CI.

Where your CI would:

  • Build a docker image
  • Scan the docker image for any security vulnerabilities
  • Publish it to your private container registry.
on: [push]

jobs:
  build-secure-and-push:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master

    - run: docker build . -t contoso.azurecr.io/k8sdemo:${{ github.sha }}
      
    - uses: Azure/container-scan@v0
      with:
        image-name: contoso.azurecr.io/k8sdemo:${{ github.sha }}
    
    - uses: Azure/docker-login@v1
      with:
        login-server: contoso.azurecr.io
        username: ${{ secrets.REGISTRY_USERNAME }}
        password: ${{ secrets.REGISTRY_PASSWORD }}
    
    - run: docker push contoso.azurecr.io/k8sdemo:${{ github.sha }}

End to end workflow using any container repository and workflow environment variables

The following is an example of not just this action, but how this action could be used along with other actions to setup a CI.

Where your CI would:

  • Build a docker image
  • Scan the docker image for any security vulnerabilities
  • Publish it to your preferred container registry.

This example assumes you have defined an evironment variable in your workflow for CONTAINER_REGISTRY.

on: [push]

jobs:
  build-secure-and-push:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master

    - run: docker build . -t ${{ env.CONTAINER_REGISTRY }}/k8sdemo:${{ github.sha }}
      
    - uses: Azure/container-scan@v0
      with:
        image-name: ${{ env.CONTAINER_REGISTRY }}/k8sdemo:${{ github.sha }}
    
    - uses: Azure/docker-login@v1
      with:
        login-server: ${{ env.CONTAINER_REGISTRY }}
        username: ${{ secrets.REGISTRY_USERNAME }}
        password: ${{ secrets.REGISTRY_PASSWORD }}
    
    - run: docker push ${{ env.CONTAINER_REGISTRY }}/k8sdemo:${{ github.sha }}

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

container-scan's People

Contributors

ajinkya599 avatar dependabot[bot] avatar jldeen avatar josh-01 avatar koalaty-code avatar koushdey avatar microsoft-github-operations[bot] avatar microsoftopensource avatar oyri avatar shigupt202 avatar smuu avatar sundargs2000 avatar thesattiraju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

container-scan's Issues

`Error: An error occurred while scanning container image`

I'm having issues while running the action.

Tested with two different images hosted on Azure Container Registry.

Run Azure/container-scan@v0
/usr/bin/tar --version
tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
/usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/52aa4326-3e88-4277-8faf-7859e7173d82 -f /home/runner/work/yp-search-api-health-microservice/yp-search-api-health-microservice/_temp/tools/trivy
Scanning for vulnerabilties in image: ***/yp-search-api-health-microservice:development
Error: An error occurred while scanning container image: ***/yp-search-api-health-microservice:development for vulnerabilities.

Any additional info, let me know.

SEVERITY FATAL escapes the severity-threshold

I just saw some builds that have a severity labeled by the container scan as FATAL but the action doesn't acknowledge this as a problem.
โ•‘ VULNERABILITY ID โ”‚ TITLE โ”‚ SEVERITY โ”‚ DESCRIPTION โ•‘ โ•‘ CIS-DI-0010 โ”‚ Do not store credential โ”‚ FATAL โ”‚ Suspicious file extension found : โ•‘

guessing it drops the check only one the defined keywords

Dockle scan fails due to invalid username/password combo

Trivy check runs successfully according to log

Scanning for vulnerabilities...
No vulnerabilities were detected in the container image

But after Dockle initializes we get this message:

Scanning for CIS and best practice violations...
Error: FATAL	unable to initialize a image struct: failed to initialize source: unable to retrieve auth token: invalid username/password: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information.
Error: An error occurred while scanning the container image for best practice violations

The action seems to be taking the credentials we provided

Run Azure/container-scan@v0
  with:
    image-name: ***/search-training-index:aa12c0d5170e523d92ddf29cfc51e54a7a7c19ea
    username: ***
    password: ***
    severity-threshold: HIGH
    token: ***
    run-quality-checks: true
  env:
    AZURE_WEBAPP_NAME: search-training-index

We know our credentials are right, because are being used by other actions.

Any idea of what's going on? What i'm missing?

Failed to download trivy

We are trying to integrate this action with one of our current workflows in a private repo, but our workflow keeps failing with the following error:

Error: Failed to download trivy from https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-64bit.tar.gz

I went ahead and enabled additional logging by setting the ACTIONS_RUNNER_DEBUG and ACTIONS_STEP_DEBUG secrets to true, and we are seeing the following logs:

Could not find allowedlist file.
##[debug]Downloading https://api.github.com/repos/aquasecurity/trivy/releases/latest
##[debug]Downloading /home/runner/work/_temp/8472635f-cf05-4075-a5c2-b755d65851c4
##[debug]download complete
##[debug]isExplicit: 0.16.0
##[debug]explicit? true
##[debug]checking cache: /opt/hostedtoolcache/trivy/0.16.0/x64
##[debug]not found
##[debug]Could not find trivy in cache, downloading from https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-64bit.tar.gz
##[debug]Downloading https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-64bit.tar.gz
##[debug]Downloading /home/runner/work/****/****/_temp/tools/trivy
Error: Failed to download trivy from https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-64bit.tar.gz
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Scan Docker Image

Additional information about environment:

Current runner version: '2.277.1'
Operating System
  Ubuntu
  20.04.2
  LTS
Virtual Environment
  Environment: ubuntu-20.04
  Version: 20210208.0
  Included Software: https://github.com/actions/virtual-environments/blob/ubuntu20/20210208.0/images/linux/Ubuntu2004-README.md

By chance, has anyone else ran into this issue before?

Latest code fails with error: Cannot find module '@actions/core'

I'm trying the latest code from PR #29 but the action is failing with an error:

Run azure/container-scan@b5317f7365a8e3aab8e35d97e932d105ad2ed4e8
internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module '@actions/core'
Require stack:
- /home/runner/work/_actions/azure/container-scan/b5317f7365a8e3aab8e35d97e932d105ad2ed4e8/lib/main.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/runner/work/_actions/azure/container-scan/b5317f7365a8e3aab8e35d97e932d105ad2ed4e8/lib/main.js:19:27)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:[14](https://github.com/xxx/xxx/runs/5072317271?check_suite_focus=true#step:4:14))
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/runner/work/_actions/azure/container-scan/b53[17](https://github.com/xxx/xxx/runs/5072317271?check_suite_focus=true#step:4:17)f7365a8e3aab8e35d97e9[32](https://github.com/xxx/xxx/runs/5072317271?check_suite_focus=true#step:4:32)d105ad2ed4e8/lib/main.js'
  ]
}

FATAL scan error: image scan failed: failed analysis:

Hello all,

I have issues using the Azure Container-Scan Github Action. I would like to scan an image but I am getting the following error:

"Error: FATAL scan error: image scan failed: failed analysis: analyze error: timeout: context deadline exceeded"

Any idea of why is happening?

Warning when scanning containers

A scan on containers, is returning such a warning.

Warning: An error occurred while creating the check run for container scan. Error: Error: An error occurred while creating scan result. Statuscode: 403, StatusMessage: Forbidden, head_sha: (sha mentioned)

An error occurred while scanning container image: <TAG> for vulnerabilities

Hi there,
after replacing the base image I've started having this problem:

Run azure/container-scan@v0
Could not find allowedlist file.
/usr/bin/tar --version
tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
/usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/ee136a0f-930d-4460-946c-5350691898b7 -f /home/runner/work/kiwi-back/kiwi-back/_temp/tools/trivy
Scanning for vulnerabilties in image: <TAG>
Error: FATAL	scan error: image scan failed: failed analysis: analyze error: failed to analyze layer: sha256:1e286eeb0cc3ab35932b7e5b52c3a2b07f2e6a120ed5bb295a84303691dca2c9 : unable to get uncompressed layer sha256:1e286eeb0cc3ab35932b7e5b52c3a2b07f2e6a120ed5bb295a84303691dca2c9: failed to get the layer content (sha256:1e286eeb0cc3ab35932b7e5b52c3a2b07f2e6a120ed5bb295a84303691dca2c9): gzip: invalid header
Error: An error occurred while scanning container image: <TAG> for vulnerabilities.

The previous one was python:3.9-slim and the current one is ubuntu/ubuntu:impish-21.10_edge.

I am testing out a hardened Docker image from Canonical: https://ubuntu.com/security/docker-images
I am assuming this is the root cause just because it is the only big thing I changed today.

The image I created works with our test suite, so I assume that is well-formed.

Receiving error while scanning a image

Tried using both v0 and v0.1 and consistently receiving this error message while running the action.

Scanning for CIS and best practice violations...
Error: Table data must not contain control characters.

Any suggestions on what could be wrong here?

Settings when action should return error

Currently the action only return an error code, when the trivy scan return an error.

It would be helpful to set the severity/level for the vulnerabilities/best-practices when the action should return an error.

When using this action - Failing to download DB

Hi, I am attempting to use this github action, but it seems to be failing on getting the trivy DB (?). I am using a self hosted runner, and tested on that machine if I am able to curl that url curl https://api.github.com/repos/aquasecurity/trivy-db/releases, this does return data.

I am kind of confused on the error, it's saying 401 Bad credentials [], but I don't give this github action any credentials. Any ideas?

  - name: Scanning container
    uses: Azure/container-scan@v0
    with: 
      image-name: ${{github.sha}}

Error: FATAL DB error: failed to download vulnerability DB: failed to download vulnerability DB: failed to list releases: GET https://api.github.com/repos/aquasecurity/trivy-db/releases: 401 Bad credentials []
Error: An error occurred while scanning the container image for vulnerabilities

Vague error message : `Looks like the scanitizer app is not installed on the repo`

Creating scan result. image_name: metacontrollerio/metacontroller:lint, head_sha: aad6c67946130f3cc49b3c5db312f504dc6a2ddb
Looks like the scanitizer app is not installed on the repo. Falling back to check run creation through GitHub actions app...

what is scanitizer app ? There is no mention of it in README, also I tried to search on Github Marketplace but no luck

Use in DevOps YAML Pipelines?

Great action for Github!
Is there already a way to use this on Azure DevOps pipelines as well?
If not, any plans to support DevOps pipelines?

Multiple occurrences of same vulnerabilities in Trivy's output

We can see multiple occurrences of same CVE's in the output. This is because same vulnerability can be present in multiple packages used in the image. Also, it's not very intuitive to identify the source (package) of the vulnerability from the output.
We can add another field to indicate the package in which each CVE is found to resolve both these issues.

image

Ref: #25

"unable to initialize a scanner"

We have been seeing this error more and more lately and we wonder if this is related to the action or is github infra. Any suggestion would be greatly apreciated.

 Scanning for vulnerabilties in image: ***/***/----:------
Error: FATAL	scan error: unable to initialize a scanner: unable to initialize a docker scanner: 3 errors occurred:
Error: An error occurred while scanning container image: ***/***/-----:------ for vulnerabilitie

Incorrect and incomplete documentation of allowedlist.yaml and other ignores

Whitelisting according to docs doesn't work. Here are my findings so far

Readme currently states to use .github/containerscan/whitelist.yaml when digging through source it shows you actually look for .github/containerscan/allowedlist.yaml

Source also seems to indicate that you also observe the standard ignore files for both trivy and dockle. Thus is would be nice if you indicated that in the documentation too

But having tried both whitelist.yaml and allowedlist.yaml - neither seems to impact the findings or exit code of the job.

Workflow example:

image-scan:
    name: Image Scan & Lint
    needs: build-image
    runs-on: ubuntu-latest
    steps:
      - uses: azure/container-scan@v0
        name: Scan Image
        id: container-scan
        with:
          image-name: ${{ needs.build-image.outputs.image-name }}
          username: ******
          password: ******
          severity-threshold: HIGH
          run-quality-checks: true
      - uses: actions/upload-artifact@v2
        if: failure()
        with:
          name: trivy-image-scan
          path: ${{ steps.container-scan.outputs.scan-report-path }}

allowedlist / whitelist example (not that I intend to use these settings but just trying to impact the findings :) )

general:
  vulnerabilities:
    - CVE-2021-27290
  bestPracticeViolations:
    - CIS-DI-0006
    - DKL-DI-0003
    - DKL-DI-0004
    - CIS-DI-0005
    - DKL-LI-0003

Action could not find allowedlist file.

I placed the allowedlist.yaml under the specified directory .github/containerscan, and also installed the Scanitizer.

Here's how my file looks like

general:
  vulnerabilities:
    - CVE-2021-3807
  bestPracticeViolations:
    - CIS-DI-0005

Run output (first lines):

Could not find allowedlist file.
/usr/bin/tar --version
tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Image name as environment variable is not parsed

Description

Hello. Really like this action as it bundles together some my favorite container CI utilities.
I've noticed an issue that does not seem documented anymore, though: it doesn't parse environment variables set in the job.

Expected

When referencing the Docker image name stored as an environment variable (example below), the container-scan Action is able to parse it.
e.g.

      - name: Scan image
        uses: Azure/container-scan@v0
        with:
          image-name: $IMAGE_NAME:${{ github.sha }}
          severity-threshold: "CRITICAL"
          run-quality-checks: true

What actually happens

When referencing the Docker image name stored as an environment variable, the container-scan Action is not able to parse it.

Scanning for vulnerabilties...
Error: An error occured while scanning the container image for vulnerabilities

Example

I've created a test repository to demonstrate this behavior.

Thank you.

Defender for ACR - CI/CD scan result not shown

I am scanning my docker image at build time with the github action Container Image Scan, but the CI/CD scan results do not show in Defender.

You can see in this run that the scan was successful and found enough vulnerabilities (medium, high and criticals).

The post scan to appinsights was also successful and I double checked that the connection string + token were correctly set as secrets in github.

In defender I don't see the CI/CD scan results for the scanned image.
image

I followed this procedure which always used to work.

Error: Failed to download dockle

I'm presenting issues when scanning an ACR image.

This is the action output:

Error: Failed to download dockle from https://github.com/goodwithtech/dockle/releases/download/v0.4.4/dockle_0.4.4_Linux-64bit.tar.gz

I've tested the link and actually works.

Action can't scan image when docker context is set

I logged in using the action azure/docker-login@v1. I would assume that this action then can scan images from the registry I logged in there.
But in fact I need to pass the username and password field for this action to scan images.

Edit: It seems, that Trivy uses the docker context but Dockle does not.

Error when scanning image - Trivy - No help topic for image name

I am seeing the following error logs when trying to scan an image:

/usr/bin/tar --version
tar (GNU tar) 1.30
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
/usr/bin/tar xz --warning=no-unknown-keyword -C /home/runner/work/_temp/027f57e6-0bba-4a99-87b7-823b887b56bb -f /home/runner/work/maven-consumer-profile/maven-consumer-profile/_temp/tools/trivy
##[debug]Caching tool trivy 0.23.0 x64
##[debug]source dir: /home/runner/work/_temp/027f57e6-0bba-4a99-87b7-823b887b56bb
##[debug]destination /opt/hostedtoolcache/trivy/0.23.0/x64
##[debug]finished caching tool
##[debug]Trivy executable found at path  /opt/hostedtoolcache/trivy/0.23.0/x64/trivy
Scanning for vulnerabilties in image: test_docker_for_scan
ommand]/opt/hostedtoolcache/trivy/0.23.0/x64/trivy test_docker_for_scan
##[debug]No help topic for 'test_docker_for_scan'
##[debug]
Error: An error occurred while scanning container image: test_docker_for_scan for vulnerabilities.
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Scan Docker Image

I think this issue might be tied to the latest release of trivy: 0.23.0. In this release, there were breaking changes: aquasecurity/trivy#1652, where the trivy command is no longer supported and you must use trivy image.

Here is an example snippet of my current GitHub Workflow file:

- name: Build Docker image and Push to GitHub Packages
  uses: docker/build-push-action@v2
  with:
    context: .
    load: true
    push: false
    pull: true
    tags: |
      test_docker_for_scan
- name: Scan Docker Image
  uses: azure/container-scan@v0
  with:
    image-name: test_docker_for_scan
    username: USER
    password: ${{ secrets.GITHUB_TOKEN }}

This issue just started happening today. If you need any additional details, please let me know.

Strange placement of [container-scan] action in actions page

Hi,

I have been using this action in my project CI: here you container-scan is called within Docker workflow. However, I start noticing that if you go through my commit history, I start seeing container-scan showing up under other workflows. Take this one for example, why is [container-scan] falls under Node CI in this case. You can also check other commits' CI pipeline and you would not find [container-scan] under Docker workflow like intended. Am I doing something wrong?

Validate inputs beforehand

Validate the inputs before processing.
ex. If image-name is not provided the action fails with some cryptic error message.

Configuring "Ignoring vulnerabilities" in workflow

It would be a nice option to let user configure the list of vulnerabilities to ignore as action input. this can be either inline or the path to a file that contains the list.

either:

- uses: azure/container-scan@v0
  with:
    image-name:  http://myimage:latest
    username: changeit
    password: changit
    allowedlist:   # pass the list inline
     - CVE-2003-1307
     - CVE-2007-0086
     - CVE-2019-3462
     - CVE-2011-3374

or:

- uses: azure/container-scan@v0
  with:
    image-name:  http://myimage:latest
    username: changeit
    password: changit
    allowedlist: /path/to/allowedlist.yaml. # the file that contains the list of vulnerabilities to ignore. 

Scenario 1: Using the same workflow against multiple versions of the same image, one might want to ignore some vulnerabilities in older versions but not in the latest one for example.

Scenario 2: Using the action multiple times for different images in a single repo/workflow, one might one to ignore some vulnerabilities for one image not the other ones.

Error when trying to scan public image

I am seeing the following error when trying to implement a simple scan of an image.
Snippet is:

Error: FATAL	scan error: unable to initialize a scanner: unable to initialize a docker scanner: 3 errors occurred:
Error: An error occurred while scanning container image: parsedmarc:latest for vulnerabilities.

Full logs are attached
logs_10.zip

The github action looks like:

  docker_scan:
    runs-on: ubuntu-latest
    needs: docker_build_and_push
    steps:
      - name: Checkout repo
        uses: actions/checkout@v2

      - name: Pull and scan parsedmarc
        uses: azure/container-scan@v0
        with:
          image-name: parsedmarc:latest

Any help would be appreciated!

Error: Table data must not contain control characters.

I got error message while scan image type script using node10 alpine base image.
action runner is Ubuntu 20.04
I also try using trivy command on my local machine(mac) to scan this image but not found this kind of error.

##[debug]source dir: /home/runner/work/_temp/527a8b07-65d4-4e29-a906-3dc8c0903513
##[debug]destination /opt/hostedtoolcache/trivy/0.19.2/x64
##[debug]finished caching tool
##[debug]Trivy executable found at path  /opt/hostedtoolcache/trivy/0.19.2/x64/trivy
Scanning for vulnerabilties in image: my-image:1.24.0
ommand]/opt/hostedtoolcache/trivy/0.19.2/x64/trivy my-image:1.24.0
##[debug]2021-08-19T04:10:57.243Z	INFO	Using your github token
##[debug]2021-08-19T04:10:57.243Z	INFO	Need to update DB
##[debug]2021-08-19T04:10:57.243Z	INFO	Downloading DB...
##[debug]4.02 MiB / 22.99 MiB [---------->___________________________________________________] 17.49% ? p/s ?8.89 MiB / 22.99 MiB [----------------------->______________________________________] 38.68% ? p/s ?13.88 MiB / 22.99 MiB [------------------------------------>________________________] 60.38% ? p/s ?19.48 MiB / 22.99 MiB [---------------------------------------->_______] 84.75% 25.74 MiB p/s ETA 0s22.99 MiB / 22.99 MiB [---------------------------------------------------] 100.00% 31.63 MiB p/s 1s2021-08-19T04:11:17.046Z	INFO	Detected OS: alpine
##[debug]2021-08-19T04:11:17.046Z	INFO	Detecting Alpine vulnerabilities...
##[debug]2021-08-19T04:11:17.047Z	INFO	Number of language-specific files: 2
##[debug]2021-08-19T04:11:17.047Z	INFO	Detecting npm vulnerabilities...
##[debug]2021-08-19T04:11:17.050Z	INFO	Detecting yarn vulnerabilities...
##[debug]2021-08-19T04:11:17.058Z	WARN	DEPRECATED: the current JSON schema is deprecated, check https://github.com/aquasecurity/trivy/discussions/1050 for more information.
##[debug]
Error: Table data must not contain control characters.
##[debug]Node Action run completed with exit code 1```

Latest update needs a labeled release

The PR #29 was fix for a breaking change; however the repo owners neglected to create a versioned release for this code, meaning that anyone using it will need to refer to it by commit hash (yuck). eg uses: azure/container-scan@b5317f7365a8e3aab8e35d97e932d105ad2ed4e8

Repo owners, please create a labeled release for this latest update.

Provide flag to not fail action if thresholds are met

I'm currently trying to add this action to my workflow and would like to be able to proceed with additional steps of my job after this scan is run. Currently the action fails after this scan because of high vulnerabilities, which in turn doesn't allow these steps to run. Is this already possible? Or would this be something that could added?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.