This is the multi-page printable view of this section.
Click here to print.
Return to the regular view of this page.
Image Scanning
Using Trivy to scan images for CVEs and other issues.
Trivy is one of the best tools for scanning Kubernetes images, and m9sweeper
can coordinate scanning images deployed to your cluster, rescanning of those images, as well as
blocking images from deploying if they do not meet your minimum criteria for compliance.
M9sweeper also allows you to create exceptions or have your employees' request exceptions be approved when they
do not have the time to fix an issue in the moment but still want to allow applications to deploy.
For a full list of trawler configuration options, see the trawler reference guide
1 - Automating Scanning
How to automatically scan your images.
By default, m9sweeper will scan all images that it sees deployed in your cluster that have not been scanned.
Also, you can configure the Image Rescan Period (Days) when setting up policies to automatically rescan images. This
will then rescan any images currently running in your cluster if they have not been scanned in a certain number of
days.

2 - Scanning in CICD Pipelines
Learn how to give developers feedback in your CICD pipelines.
You can automatically scan images using trawler in your automated CICD pipelines. The easiest way to do this is by
running trawler from the command line using the container image. It will look something like this.
docker run \
--env "M9SWEEPER_URL=XXX" \
--env "M9SWEEPER_API_KEY=XXX" \
--env "CLUSTER_NAME=XXX" \
--env "DOCKER_IMAGE_URL=XXX" \
-it m9sweeper/trawler trawler scan
Note that you will need to provide an API key as well as the name of the cluster you are scanning it for
so that it can authenticate with m9sweeper. You will have to run a scan for each cluster you plan to deploy it to because
each cluster might have different policies setup.
3 - Enforcing Compliance
Keeping your cluster safe.
3.1 - Setting Up Policies
Define how much risk you are willing to tolerate.
Policy Settings
In the organization settings, you can click on policies in the left navigation and configure one or more policies
for your cluster. These policies define what criteria an image must meet to be considered compliant in the cluster.
It looks something like this.

Only policies and scanners that are active and required will be used in determing whether an image is compliant. Also,
when evaluating an image for a cluster, only policies that are configured for that cluster will be applied.
Configuring Trivy Requirements
When configuring the trivy scanner, you can define the maximum number of vulnerabilities for each category. The
defaults that come pre-installed essentially will block any image with a fixable major or critical vulnerability.

3.2 - Installing Webhook
Installing the Webhook
In order to have m9sweeper enforce image scanning compliance in your cluster, you need to install a validating webhook
in your cluster. This should be done automatically by m9sweeper during the setup process, but if for some reason it
was not you can click “Update Kubeconfig” on your cluster’s settings page and run through the setup wizard again
to have it install the webhook for you.

3.3 - Enabling Enforcement
How to enable enforcement.
To enable enforcement, you need to make your way to the Cluster settings for your cluster and check the box that
enables webhook enforcement.

Once checked, anything that is not compliant with the policies you have setup will be prevented from deploying. Note
that this only works if you have installed the webhook during the setup process.
3.4 - Exceptions
How to manage policy exceptions.
Sometimes, for practical reasons, you may need to allow something with a known security issue to continue to be deployed
in an environment. You can do this using exceptions.
Creating Exceptions
Your team can create exceptions when the need arises.

Temporary Exceptions
When a new exception is discovered such as through a nightly image rescan, you may want automatically provide teams
with a certain amount of time (lets say a week) before it would block their deployments. This can be done through the
use of a temporary exception.
To enable this feature, you need to edit the policy that is setup for your cluster(s) and check the box (see below) and
set how many days the temporary exceptions should be active.

When new temporary exceptions are created, it will email all of your admins to review and decide what to do. They should
notify your software development teams if the issue should be resolved right away and/or change the end date on the
exception.
Exception Statuses
Active: Active exceptions are the only exceptions that will be used when validating image compliance, and only
if the current date is within the exception’s start and end date.
In Review: When an exception is submitted for review, it will be in this status. It will not be used when validating
an image’s compliance, but someone should review to decide whether it is a risk your organization is willing to take.
Inactive: The exception will be ignored when validating image compliance.
Requesting Exceptions
When viewing an image, if a team member who is NOT an admin believes an exception is required, they can request an
exception. This exception falls into the In Review status and will not be active, but it does provide a forum for
your team to request exceptions and for someone else (such as your security/ops team) to review and approve the
exception. They would approve the exception by changing its status to Active.

Exception Types
Exception types are available as options: Policy and Override.
- Policy: Allow listed policy(s) to be bypassed. When this type is chosen, user should also select scanner(s) and policy(s) for the desired exception.
- Override: When this type is chosen, user should select an alternate severity level for desired exception.