
Before you begin
- Labs create a Google Cloud project and resources for a fixed time
- Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
- On the top left of your screen, click Start lab to begin
Enable APIs and set up Artifact Registries
/ 20
Set up a Cloud Build pipeline and push your Docker image to Artifact Registry
/ 20
Create an Attestor, KMS pair, and update the policy
/ 20
Integrate vulnerability scanning into your CI/CD pipeline
/ 20
Fix the vulnerability and redeploy the CI/CD pipeline
/ 20
In a challenge lab you’re given a scenario and a set of tasks. Instead of following step-by-step instructions, you will use the skills learned from the labs in the course to figure out how to complete the tasks on your own! An automated scoring system (shown on this page) will provide feedback on whether you have completed your tasks correctly.
When you take a challenge lab, you will not be taught new Google Cloud concepts. You are expected to extend your learned skills, like changing default values and reading and researching error messages to fix your own mistakes.
To score 100% you must successfully complete all tasks within the time period!
This lab is recommended for students who have enrolled in the Secure Software Delivery course. Are you ready for the challenge?
You are a software engineer at Cymbal Bank, tasked with securely deploying a new web application to the cloud. The application handles sensitive customer data, so security is paramount. Your goal is to implement a robust, automated pipeline that builds, scans, signs, and deploys the containerized application while adhering to strict security standards. For this challenge, you will use Google Cloud services such as Artifact Registry, Binary Authorization, and Cloud Build to achieve this objective on a sample application.
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources will be made available to you.
This hands-on lab lets you do the lab activities yourself in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials that you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
Before you can start building your secure CI/CD pipeline, you need to enable the necessary Google Cloud APIs and set up your development environment. This will ensure that you have access to all the required services and tools.
artifact-scanning-repo
and artifact-prod-repo
, respectively.The scanning repository will be used to store the Docker image before it is scanned for vulnerabilities, while the production repository will store the image after it has been signed and is ready for deployment.
To verify the objective, click Check my progress.
In this task, you'll lay the foundation for your CI/CD pipeline by creating a basic Cloud Build configuration to build and push your Docker image to Artifact Registry. This initial step will enable you to scan the image for vulnerabilities later in the lab.
Start by adding the following roles to the Cloud Build service account:
roles/iam.serviceAccountUser
roles/ondemandscanning.admin
In the Cloud Shell Editor, open the sample-app/cloudbuild.yaml
file.
Complete TODOs: Fill out the image name placeholders (<image-name>
). For this, you will need to reference the artifact-scanning-repo
repository, and the image name should be sample-image
. Make sure to use the region
Submit the build.
Check out the image you pushed to the artifact-scanning-repo
repository and verify you can see a number of Critical vulnerabilities in the scan results.
To verify the objective, click Check my progress.
To enforce strict security policies for container deployments, you'll leverage Binary Authorization. This service allows you to define who can deploy what images, and under which conditions. In this task, you'll create and configure the necessary components of Binary Authorization, including attestors, notes, and KMS keys. This will prepare you to integrate Binary Authorization into your CI/CD pipeline.
In Cloud Shell, create a JSON file. This file will define an Attestor note containing the attestation hint. The attestation hint's human_readable_name
should be set to "Container Vulnerabilities attestation authority".
Use the Container Analysis API to create a new note with the ID vulnerability_note
. The note's details should be defined in the note file you created in the previous step. Make sure to include proper authentication and set the appropriate Content-Type header in your API request.
Use the Container Analysis API to retrieve the details of the Attestor note you just created. Make sure to include proper authentication in your API request.
Use the gcloud
command-line tool to create a new Binary Authorization Attestor. The Attestor ID should be vulnerability-attestor, and it should be associated with the Attestor note you created earlier.
Use the gcloud
command-line tool to list all existing Binary Authorization Attestors. Verify that the Attestor you just created is included in the list.
Construct an IAM policy that grants the Binary Authorization service account the roles/containeranalysis.notes.occurrences.viewer
role on the Attestor note you created. Then, use the Container Analysis API to set this IAM policy on the note.
In this section, you will generate a KMS key pair to sign attestations.
Set up Key Management:
binauthz-keys
in the global
location to store the keys.lab-key
and make sure it's version 1.Link Key to Attestor:
gcloud
command-line tool to associate the lab-key
(version 1) with your Binary Authorization Attestor. Make sure to specify the global
location and the binauthz-keys
keyring when referencing the key.Modify the Policy: Adjust the Binary Authorization policy to enforce the requirement for attestations for the default rule.
Incorporate Your Attestor: Include the vulnerability-attestor
you previously created as part of the policy configuration.
To verify the objective, click Check my progress.
Building upon the basic pipeline from Task 2, you'll now enhance it with crucial security features. This includes vulnerability scanning to identify potential weaknesses in your container images and image signing to ensure their integrity. In this task, you will integrate vulnerability scanning and image signing into your CI/CD pipeline, making it more robust and secure.
Grant the Cloud Build service account the following IAM roles in your project:
roles/binaryauthorization.attestorsViewer
roles/cloudkms.signerVerifier
roles/containeranalysis.notes.attacher
roles/iam.serviceAccountUser
roles/ondemandscanning.admin
Additionally, ensure that the Compute Engine default service account also has the cloudkms.signerVerifier
role.
In this section, you will complete the Cloud Build pipeline to include vulnerability scanning, severity checks, image signing, and deployment to Cloud Run. The code provided below is a partial implementation of the pipeline. You will need to fill in the missing parts to complete the pipeline.
artifact-scanning-repo
repository.CRITICAL
vulnerabilities are found.vulnerability-attestor
, and the key version is the full path to the lab-key
version 1.artifact-prod-repo
repository for this purpose.artifact-prod-repo
repository for this step.cloudbuild.yaml
file in the second task of this lab. Make sure to replace the rest of the placeholders with the correct values for the remaining TODOs.
Trigger the Build:
Observe the Build Failure:
CRITICAL
severity vulnerability.CRITICAL
severity vulnerability. You will address this issue in the next task.
To verify the objective, click Check my progress.
In a real-world scenario, vulnerability scans often reveal issues that need to be addressed. This task simulates such a scenario, where your build fails due to a critical vulnerability. In this task, you will analyze the build failure, identify the vulnerability, and fix it by updating your application's dependencies. You will then re-trigger the Cloud Build pipeline to ensure the build completes successfully without any critical vulnerabilities.
Update the Dockerfile: Modify your Dockerfile to use the python:3.8-alpine
base image. Update the Flask
, Gunicorn
, and Werkzeug
dependencies to the following versions:
3.0.3
23.0.0
3.0.4
Re-trigger the Build: Submit your updated Cloud Build configuration to initiate a new build.
Verify Build Success: Check the Cloud Build History page to confirm that the build completes successfully without any CRITICAL
vulnerability issues.
For testing purposes, run the following command to allow unauthenticated access to the Cloud Run service so you can validate the deployment. Replace <your-region>
with the region where you deployed the service.
To verify the objective, click Check my progress.
Congratulations! In this lab, you successfully implemented a secure CI/CD pipeline that builds, scans, signs, and deploys a web application to the cloud. This hands-on experience has equipped you with essential skills for building and deploying secure applications in the cloud, incorporating security best practices into your development workflows and ensuring the integrity of your software delivery process.
Check out the following resources to learn more about the topics covered in this lab:
...helps you make the most of Google Cloud technologies. Our classes include technical skills and best practices to help you get up to speed quickly and continue your learning journey. We offer fundamental to advanced level training, with on-demand, live, and virtual options to suit your busy schedule. Certifications help you validate and prove your skill and expertise in Google Cloud technologies.
Manual Last Updated September 4, 2024
Lab Last Tested September 4, 2024
Copyright 2024 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.
This content is not currently available
We will notify you via email when it becomes available
Great!
We will contact you via email if it becomes available
One lab at a time
Confirm to end all existing labs and start this one