Menu

1 / 9

Block Leaked Secrets in Your CI/CD Pipeline with Gitleaks, CodePipeline and CodeBuild

DEV Community: cicd·Gbenga Ogbonyenitan·6 days ago
#pnksQDkV
#devtocicd#devto#dev#gitleaks#demo
Long article (4733 words) — no AI summary yet.
Reading 0:00
15s threshold

Introduction

Someone accidentally commits an access key. It happens to careful people too. If nothing checks for it, the key rides along with the next deployment.

In this guide, you build a pipeline that checks every commit for secrets before it deploys anything. The scan runs in CodeBuild with Gitleaks. If it finds a secret, the Build stage fails, and the Deploy stage never starts.

You build it twice. First by hand in the console, so you see every piece. Then with CloudFormation. You run the same six tests on both:

A clean commit passes and deploys.

A commit with a fake key is blocked.

Deleting the key file lets the pipeline pass, and the key is still in the Git history.

A false positive is allowed with a comment.

A custom rule catches your own token format.

A finding you have dealt with is accepted through an ignore file.

The demo app is one HTML page in an S3 bucket. The page says which release it is.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.