Skip to main content
Container images contain multiple layers of software dependencies that introduce security risks across the entire software supply chain. The endorctl container scan command analyzes container images to identify vulnerabilities in base OS packages, runtime dependencies, and application libraries, providing comprehensive security visibility across all containerized workloads.

Create finding policies for containers

Container base images from untrusted sources may lack proper security audits or fail to comply with organizational standards, increasing the risk of vulnerabilities being exploited. To address this, you can configure a finding policy to detect unauthorised base images and raise a critical finding. For example, to allow only base images that start with gcp or ghcr, use the Container policy template and specify Base Image Name Regex as ^gcp, ^ghcr. See Create a finding policy from template for detailed instructions on creating finding policies. Finding policy template for container base images

Perform the endorctl scan

Endor Labs supports the following methods of scanning container images:

Scan container images in a Git repository

Run the following command to scan a container image built in a specific repository. Specify the project path using the --path argument and the container image name using the --image argument. This associates the container with the Git repository and branch of the project.
You can also scan multiple container images as part of a single repository.
You can tag findings with the corresponding container image name and tag. This lets you filter container-related findings in the user interface or through the API.

Match container dependency paths to SCA findings

A container scan traces application dependencies, such as Java libraries, only to the package file in the image, such as a JAR file. The dependency path of a container finding can then differ from the path of the SCA finding for the same vulnerability. An exception policy that matches on a dependency path applies to the SCA finding but not to the container finding. To fill in these paths from the project’s SCA results, turn on dependency correlation. The container image must include the project’s own JAR at the same group ID, artifact ID, and version that the SCA scan reported. If the image was built from a different version of the code, no paths match, and the scan doesn’t show a warning.
  1. Run an SCA scan on the project to generate the results used by the container scan. The scan can be of any type except a pull request scan. Endor Labs prioritizes results from the container scan’s branch, followed by the default branch and then the most recently updated branch.
  2. Turn on dependency correlation. It is set to false by default.
  3. Scan the container with --path set to the same repository and without --project-name, so both scans share a project.
The dependency path of a container finding can still differ from the corresponding SCA finding in the following cases:
  • The image contains libraries that aren’t included in the SCA scan, such as libraries added through a shade configuration. These libraries retain the dependency path from the container scan.
  • The library versions in the image differ from those in the SCA scan.
  • The finding description displays only the shortest dependency path.
  • The shaded JAR file name doesn’t match its artifact ID, such as app.jar, so the first library in the path might show the name of a different library.

Scan container images as a standalone project

Run the following command to scan a container image from a registry. Specify the project name using the --project-name argument, and the container image name and tag using the --image argument.
To keep multiple versions of a container image in a container-only project, include the --as-ref flag.
You can tag findings with the corresponding container image name and tag. This lets you filter container-related findings in the user interface or through the API.
ImportantTo associate a container scan with an existing SCA scan for a project, you must use the --path argument specifying the same project path used for the SCA scan. You cannot associate a container scan with an SCA scan for a project using the --project-name parameter.

Scan container image tarball

You can save a container image as a tarball and scan it with endorctl to generate a report containing dependencies, SBOM details, and security findings.
  1. Ensure that you have the container image available locally.
  2. Export the image to a tarball file.
  3. Perform the endorctl scan.
    • --image-tar must point to the absolute path of the tarball file.
    • --image=<name:tag> is optional but recommended. It explicitly identifies the container image inside the tarball.

Perform container scan in CI pipelines

You can integrate container scanning into CI pipelines to automatically detect vulnerabilities and ensure the security of container images during the build and deployment process. To scan containers in CI pipelines using GitHub Actions, set the scan_container parameter to true in the GitHub Actions script. Additionally, you must provide the image parameter with the container image you want to scan. See CI/CD Integration for more information.