Search⌘ K
AI Features

Scanning Code and Container Images in the Pipeline

Explore how to incorporate security scanning into machine learning CI/CD pipelines on AWS. Understand the roles of Amazon ECR enhanced scanning, Amazon Inspector, and Amazon CodeGuru Reviewer in detecting vulnerabilities in codes and container images. Learn how to configure pipelines to fail on high-severity findings and manage ongoing monitoring with EventBridge to maintain secure deployment environments.

The previous lesson built an ML CI/CD pipeline with CodePipeline, CodeBuild and CodeDeploy, and added rollback triggers that protect production from a model that predicts badly. Those triggers do nothing about a serving image that ships a known vulnerability. CodeArtifact, covered in the lesson on secure dependencies, controls where packages come from; scanning checks what actually ends up in the code and the inference image.

This lesson adds two security checks to that pipeline: code is reviewed for security defects before it merges, and every container image is scanned before the Deploy stage can use it. You will learn how Amazon ECR enhanced scanning and Amazon Inspector work, how to fail a pipeline on vulnerabilities, and where Amazon CodeGuru Reviewer fits.

The diagram below shows where each check sits in the pipeline from the previous lesson.

Security checks in an ML CI/CD pipeline
Security checks in an ML CI/CD pipeline

Container image scanning with Amazon Inspector

Amazon ECR offers two scan types, set once for the whole private registry. The following table compares them:

Aspect

Basic Scanning

Enhanced Scanning

Scanning engine

Amazon ECR (AWS native technology, CVE database)

Amazon Inspector

What is scanned

Operating system packages

Operating system and programming language packages (for example, Python libraries in the image)

Scan frequency

Manual or scan on push

Scan on push or continuous scanning

New CVEs after push

Not rescanned automatically

Rescanned automatically with continuous scanning

Cost

No additional charge

Billed by Amazon Inspector (no extra Amazon ECR charge)

Enhanced scanning is the right choice for ML images, because most of their risk sits in language packages such as numpy, torch or the web server that wraps the model. The ...