<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>ECS Compose-X - Blog (Posts about clair-scan)</title><link>https://blog.compose-x.io/</link><description></description><atom:link href="https://blog.compose-x.io/categories/clair-scan.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2021 &lt;a href="mailto:JohnPreston@users.noreply.github.com"&gt;https://github.com/johnpreston&lt;/a&gt; </copyright><lastBuildDate>Sat, 24 Jul 2021 16:39:04 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Automated ECR Scans &amp; Reports with ecr-scan-reporter</title><link>https://blog.compose-x.io/posts/automated-ecr-scans-reports-with-ecr-scan-reporter/index.html</link><dc:creator>https://github.com/johnpreston</dc:creator><description>&lt;div&gt;&lt;div class="section" id="situation-analysis"&gt;
&lt;h2&gt;Situation analysis&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;#TLDR;&lt;/strong&gt; A lot of images built and used, no notifications, and no automated re-scan after X amount of time.&lt;/p&gt;
&lt;p&gt;With the rapid adoption of containerized technologies, and the ease of use that allows anyone today to publish images
for internal or public consumption, has grown the necessity to scan and inspect security of our images.&lt;/p&gt;
&lt;p&gt;Although DockerHub and other Docker images repositories allow certain vendors to release official images, there is
no doubt that unaware developers or cloud engineers would jump at the opportunity to grab the first image that does
the job for them and move on.&lt;/p&gt;
&lt;p&gt;But that is not the only issue at hand: with the adoption of DevOps lifecycles, a lot of repositories simply grow bigger
by day, as the pipelines build new images everyday.&lt;/p&gt;
&lt;p&gt;On &lt;a class="reference external" href="https://aws.amazon.com/ecr/"&gt;AWS ECR&lt;/a&gt;, you can set to perform a scan of the image when pushed,
but, not all OSes are supported yet for scanning, and, most importantly, there is no notification integration built-in
to let the teams know the outcome of the scan with other services. Which could lead to vulnerabilities to be shipped into
the newest version of your images. If you rely on humans to actively go and check for the scan result when you provided
them with a pipeline that does everything else for them, chances are, they won't.&lt;/p&gt;
&lt;p&gt;Furthermore, by  having tens of new images a day published can lead to simply to loosing complete track of what is in your repository.
So after even just a few days, these images you recently pushed could in fact contain vulnerabilities that on the day
you scanned them, weren't in the CVE (or other security reports sources) at the time, and one of these images
could very well be the one you have running in production.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="section" id="welcome-ecr-scan-reporter"&gt;
&lt;h2&gt;Welcome ECR Scan Reporter&lt;/h2&gt;
&lt;p&gt;#TLDR; &lt;a class="reference external" href="https://serverlessrepo.aws.amazon.com/applications/eu-west-1/518078317392/ecr-scan-reporter"&gt;ECR Scan Reporter&lt;/a&gt; | &lt;a class="reference external" href="https://ecr-scan-reporter.compose-x.io/"&gt;Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;ECR Scan Reports being a built-in feature of &lt;a class="reference external" href="https://aws.amazon.com/ecr/"&gt;AWS ECR&lt;/a&gt;, which is free, uses &lt;a class="reference external" href="https://github.com/quay/clair"&gt;Clair&lt;/a&gt;, and publishes to EventsBridges events
when scans are in progress, failed or complete, we have a very easy integration that allows us to capture and feed into AWS Lambda (or other services).&lt;/p&gt;
&lt;p&gt;Also, EventsBridge allowing us to create cronjobs like executions (previously into AWS CloudWatch Events) we could trigger
a scan for all the images of all our repositories on a regular basis to ensure that we keep up with the images we previously
published.&lt;/p&gt;
&lt;p&gt;&lt;a class="reference external" href="https://serverlessrepo.aws.amazon.com/applications/eu-west-1/518078317392/ecr-scan-reporter"&gt;ECR Scan Reporter&lt;/a&gt; aims to provide these features in cost effective way using AWS Lambda and fully automated, that users
can configure as they need it.&lt;/p&gt;
&lt;div class="section" id="actively-scanning-regularly"&gt;
&lt;h3&gt;Actively scanning regularly&lt;/h3&gt;
&lt;img alt="https://ecr-scan-reporter.compose-x.io/_images/EcrScanReporterWorkflow.jpg" src="https://ecr-scan-reporter.compose-x.io/_images/EcrScanReporterWorkflow.jpg"&gt;
&lt;p&gt;As described above, we then have 2 functions which work together. The first one, will list all the repositories in the
Registry (note that these are region based), and then send into SQS a list of the repositories that you want to scan.&lt;/p&gt;
&lt;div class="admonition hint"&gt;
&lt;p class="admonition-title"&gt;Hint&lt;/p&gt;
&lt;p&gt;The Function that lists the repositories can be provided a regular expression to select which repositories to scan.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;A second Lambda function, triggered by Lambda via SQS, receives the repositories to scan. The reason for splitting the
two functions is to enable parallelism and keep the execution time of these lambda functions very short.&lt;/p&gt;
&lt;p&gt;That second function is then going to list the images of the given repository, and describe these in order to get information
details about the scan.&lt;/p&gt;
&lt;p&gt;If the image was never scanned, it will trigger a scan. If the image was scanned, it will then evaluate how long ago was
that last scan, and if above the user defined "expiry duration", will then trigger a new scan for that image.&lt;/p&gt;
&lt;div class="admonition hint"&gt;
&lt;p class="admonition-title"&gt;Hint&lt;/p&gt;
&lt;p&gt;The default duration is 7 days, and is completely configurable by the user.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="admonition hint"&gt;
&lt;p class="admonition-title"&gt;Hint&lt;/p&gt;
&lt;p&gt;For each vulnerability level (CRITICAL, HIGH, MEDIUM and LOW) the user can override the threshold value for the scan.&lt;/p&gt;
&lt;/div&gt;
&lt;div class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;Some repositories do not have immutable tagging, leading to some images being untagged, but still in the repository.
ECR Scan Reporter will then fall back onto using the Image Digest instead of the image tag in subsequent API calls.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="reporting-findings"&gt;
&lt;h3&gt;Reporting findings&lt;/h3&gt;
&lt;p&gt;As mentioned in the situation analysis, there is not (yet! ... AWS has a habit to make my solutions obsolete) a feature
to integrate into notifications systems easily yet to report on the security findings once the scan is complete (or failed).&lt;/p&gt;
&lt;p&gt;From SNS, one can do the integration to a number of target, or for integration that might require a little bit more
involvement, trigger a similar lambda function to notify on findings.&lt;/p&gt;
&lt;div class="admonition note"&gt;
&lt;p class="admonition-title"&gt;Note&lt;/p&gt;
&lt;p&gt;ECR Scan Reporter is written as a Python Library. The Lambda functions simply put the functions in the right order,
but you could re-use the Lambda Layer / Python library in your own function and reuse these functions.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="section" id="future-improvements"&gt;
&lt;h2&gt;Future improvements&lt;/h2&gt;
&lt;p&gt;One thing that teams using ECR today can do is already to setup lifecycle policies to clean up images that match a number
of criteria, which can remove a fair number of images "left behind" which will inevitably get security vulnerabilities
reported and therefore create "noise" when the InfoSec teams try to triage and understand what is going on.&lt;/p&gt;
&lt;p&gt;Where the implementation of the reporting function is very simple and basic, it would be very easy for anyone to adapt the
functions into doing more.&lt;/p&gt;
&lt;div class="section" id="participate-in-the-roadmap"&gt;
&lt;h3&gt;Participate in the roadmap!&lt;/h3&gt;
&lt;p&gt;This is an open source project that we would love users to get involved, so please help making the reporter better
and open &lt;a class="reference external" href="https://github.com/compose-x/ecr-scan-reporter/issues/new?assignees=JohnPreston&amp;amp;labels=enhancement&amp;amp;template=feature_request.md&amp;amp;title="&gt;new feature requests on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/div&gt;</description><category>AWS</category><category>AWS ECR</category><category>aws-lambda</category><category>clair-scan</category><category>Docker</category><category>security</category><category>vulnerability</category><guid>https://blog.compose-x.io/posts/automated-ecr-scans-reports-with-ecr-scan-reporter/index.html</guid><pubDate>Sat, 24 Jul 2021 15:24:26 GMT</pubDate></item></channel></rss>