Ravindra BagaleCourses & study guides Track your progress

Chapter 37: Toolchain Mastery and Tool Selection

37.1 Why.

Welcome to Chapter 37.

I am Ravindra Bagale.

Raju had no engineering degree. He had a folder of logos. Every week a new scanner promised to be the one that would make the city safe if he would only switch. He asked Guru-ji which brand to love.

Guru-ji put the logos face down. "Love a control objective. A tool is a rented pair of hands. When the hands get clumsy, expensive, or untrustworthy, you replace the hands and you keep the job. Brand loyalty is how teams keep a gate that no longer matches the threat model, and how they refuse a better gate because the old logo is on a slide."

He made Raju say the job before the product. "Suppose we are Paytm or PayFast and the job is to stop a known-bad library from shipping in a payment service. That job is software composition analysis, plus a registry you trust, plus a rule that fails the build. The logo is whoever does that job this year. Suppose we are Swiggy or Zomato and the job is to keep a secret out of a repository. That job is secret detection at commit and in the pipeline, not a mascot. Suppose we are Amazon and the job is to stop a public bucket or a wild role. That job is policy-as-code. Suppose we are Netflix and the job is to know what digest is running. That job is a registry with immutability and a deploy record. Suppose we are Infosys and a client already owns three overlapping scanners. Your value is to map each one to an objective and to retire the overlap, not to add a fourth logo. Suppose we are BHIM UPI or WhatsApp-shaped systems and a vendor demo wants production traffic. The answer is a lab fixture. Tools do not get to practice on customers."

Tools are also software you trust

Security tools run with high access. Choosing, configuring and updating them is part of security.

Trivy and Grype

Aqua's Trivy and Anchore's Grype are popular open-source scanners for images and dependencies. Many teams start with one of them because they run in CI with one command.

Semgrep and CodeQL

Semgrep and GitHub CodeQL are code scanners that let teams write their own rules. GitHub offers CodeQL free for public repositories.

37.2 What.

Objectives before categories. Write the harm you refuse, in a sentence, before you write a shopping list. "No unsigned image runs." "No new high-severity advisory in a direct dependency ships without a decision." "No infrastructure change merges if it would open a store to the world." "No long-lived secret sits in a git tree." Each sentence is a control objective. Categories are the usual shelves where tools that serve those sentences live. A shelf can hold many brands. A brand can sit on the wrong shelf if you bought it because a conference was exciting.

SAST. Static application security testing reads source or bytecode without running the service. The objective is to catch dangerous patterns early, when the author is still at the keyboard. Mastery is not "turn on every rule." Mastery is knowing which rules map to your threat model, what the false-positive load from Chapter 35 is, and which paths are tests. A SAST tool that blocks the build on style will be bypassed. A SAST tool that only runs the week before a release will be ignored until it is too late to be kind. You want it in the pull request, with a small blocking set and a larger report that does not stop the line.

SCA. Software composition analysis reads dependency manifests and lockfiles and compares them with advisory data. The objective is to know when a library you did not write is having a bad week, and to stop or to justify the upgrade. SCA without a lockfile is a rumor. SCA without an owner for the upgrade is a report. Pair it with the debt ledger. A finding that cannot name the service and the team is not mastered. It is forwarded email.

Registry. A registry stores artifacts: container images, packages, maybe charts. The objective is a single place where you can say which digest exists, who pushed it, and whether production is allowed to pull it. Mastery looks like immutability for release tags, retention you chose on purpose, and permissions that separate the human who writes application code from the identity that pushes a blessed image. A registry that allows anyone to overwrite a tag is a lobby, not a control. Chapter 14 taught image hygiene. Here you treat the registry as a selectable component. You can move artifacts to another registry if you pin by digest and you have a cut-over plan. If you cannot move, you do not have a registry. You have a hostage.

Policy-as-code. Policy-as-code evaluates a document, a plan, or a request against rules you can review in git. The objective is to make "we do not allow that shape" executable. Infrastructure plans, Kubernetes manifests, and cloud requests all fit. Mastery is unit tests for the policy, a clear fail message a developer can repair, and an exception path with an expiry, the same expiry habit as Chapter 35. A policy engine you cannot replace is just a brand-shaped bottleneck. Keep the policies in your repository in a form you could reimplement. The engine should be swappable. The rules are yours.

Neighbor shelves, named so you do not mix them. Secret detection looks for credentials in code and history. It is not SAST, even if one product sells both. Dependency confusion and typosquat defenses live next to SCA and the registry: private namespaces, pinned sources. Image scanning looks at packages inside an image. It overlaps SCA and does not replace a signature. DAST probes a running lab application from the outside. It is not a license to probe the public internet. Signing and provenance attestations sit beside the registry. A bill of materials records what you think you built. Identity and access tools are not scanners, but a toolchain that ignores who the pipeline is will fail the Codecov-shaped lesson below. You do not need every shelf on day one. You need to know which shelf you are buying from, and which objective is still uncovered.

Selection without loyalty. Score a candidate against the objective, in a lab, on your code. Ask where it runs: laptop, pull request, pipeline, registry, or cluster admission. Ask what data leaves your account. Source code and dependency lists are sensitive. A tool that uploads the repository to a tenancy you do not control needs a written reason. Ask how it fails: closed, open, or silently skipped. Prefer fail closed for the few rules you truly mean. Ask the false-positive cost in hours, using Chapter 35's method, on a real week of your lab history. Ask the exit. Can you export findings, suppressions, and policies in a documented format. If the answer is no, you are not buying a tool. You are building a trap. Price matters. A free tool you understand can beat a suite you never tune. A paid tool with a sharp objective can beat five free tools that overlap and argue.

How to replace a tool. Replacement is a drill, not a divorce in production at midnight. Run the old and the new against the same commits for a window you choose. Compare findings on a sample, not on a victory metric from the vendor. Decide which differences are new signal, which are noise, and which are regressions you will not accept. Move suppressions deliberately. A blanket import of every old ignore is how you launder last decade's exceptions into the new logo. Dual-write the policy or the advisory gate until the new tool blocks what the old tool blocked for the rules you kept. Then switch the blocking flag. Then remove the old credential, the old webhook, and the old runner permission in the same week. A replaced tool that still holds a production token is not replaced. Update the diagram and the on-call note so people stop restarting the ghost. Practice this once in a lab with two trivial scanners, even if both are simple scripts you wrote, so the muscle exists before a contract forces the date.

Mastery is operational. You can explain, without a slide, what blocks a merge today and why. You can find the last run. You can name the identity the tool uses and show it is not an admin of the cloud account. You can turn a rule off with an expiry and show the pipeline enforcing that expiry. You can take a finding from the tool to a debt row and back. You can remove the tool in a lab and watch the control fail in a way your review expects, then put a replacement in and watch the control return. If only one vendor engineer can do those things, you have a subscription, not mastery.

A teaching sample: an objective card. Lab only.

objective: block a lab image that is not signed, at deploy time
category: registry plus policy-as-code, not "whatever the suite calls it"
today: tool A checks signatures in the lab cluster
data: image digest and signature only; source code stays in git
exit: policies live in git; tool A is not the only copy
replace drill: tool B evaluates the same policy for two weeks; then tool A's token is revoked
non-goal: a dashboard of logo coverage

Overlap is a cost, not a trophy. Two SAST tools that block on the same rule do not make you twice as safe. They double Chapter 35's hour load and teach people that red is negotiable. Map each blocking rule to one owner. If tool A and tool B both claim SCA, pick the one whose advisory source you can explain and whose suppressions you can export. Keep the other in report-only for a month, then remove it. An Infosys-shaped client who already pays for three scanners does not need a fourth. They need a picture of which objective each one serves, and a retirement date for the overlap. The same is true inside a Paytm-shaped or Amazon-shaped platform team: the paved path from Chapter 26 should carry one blessed tool per shelf, with an escape hatch that is an approved replacement, not a personal download.

A small replacement story. In the lab, objective: "fail the build if a direct dependency advisory is high and has no debt row." Tool A, a local checker you script against a sample advisory file, blocks today. Tool B reads the same lockfile and the same sample file. For five commits you run both. On the third commit tool B misses a fixture you care about, so you fix B's match rule, you do not declare victory. On the fifth commit they agree. You switch the blocking bit to B. You delete A's credential from the lab runner. You push one more commit and watch A fail to start, while B still blocks. The objective card's sentence does not change. That is mastery. A logo swap that skips the five commits is hope.

Ravindra Bagale's Tip

If you cannot name the control in one sentence without the vendor's name, you are not ready to buy or to renew.

Practice task

Pick one objective you already care about. Name the category. Run one tool in a lab you own. Write the exit plan in five lines. Do not connect a trial tenant to a company account that is not your lab.

37.3 How.

  1. List the harms you refuse for one lab service, one sentence each.
  2. Map each sentence to a category: SAST, SCA, registry, policy-as-code, or a neighbor shelf.
  3. Mark shelves you do not need yet, so you do not buy from boredom.
  4. For one shelf, write the data the tool must see and the data it must not upload.
  5. Choose a lab implementation you can install without a production credential.
  6. Point it at a toy repository you own, with a deliberate benign bad pattern you can explain.
  7. Confirm it catches that pattern and ignores a boring line you marked as a fixture.
  8. Record the minutes you spent dismissing noise. That is Chapter 35's load, in miniature.
  9. Store the rule set in git, not only in a vendor console.
  10. Write an exception with an owner and an expiry, and show the lab gate enforcing the date.
  11. Export findings once, so you know the exit format is real.
  12. Add a second lab tool on the same shelf, even a small script, and run both for a handful of commits.
  13. Diff their results. Keep signal. Drop noise. Do not import every suppression blindly.
  14. Switch which one is allowed to block, and leave the other in report-only for the drill.
  15. Revoke the first tool's token and confirm it can no longer read the lab.
  16. Update the objective card so a stranger sees the new tool and the same sentence.
  17. Check the pipeline identity. It should not be an administrator of your lab cloud account.
  18. Confirm a failed tool run fails the job, rather than skipping the control in silence.
  19. Document how a developer reproduces a finding locally without pasting secrets into chat.
  20. Remove any trial signup that asked you to share a live customer repository. You did not need one.
  21. Read the card aloud and delete any sentence that is a brand slogan.
  22. Put the card next to the threat model for the service.
  23. Schedule a yearly replacement drill on the calendar, even if you expect to keep the same tool.
  24. Tell a second person which objective would still be true if the vendor vanished on a Sunday.
  25. Stop. Do not run trials against Swiggy, Paytm, Amazon, BHIM UPI, WhatsApp, Zomato, Netflix, Infosys, PayFast, or any codebase you do not own.

Choosing a tool

  1. Write the problem first (for example, "find vulnerable npm packages").
  2. Shortlist two or three tools.
  3. Try them on one real repo; count true and false findings.
  4. Check how they fit CI, cost and support.
  5. Pin tool versions and verify downloads (Codecov lesson).
  6. Review the choice every year.
NeedOpen-source optionsCommercial examples
Code scanning (SAST)Semgrep, CodeQLCheckmarx, Veracode
Dependencies (SCA)Trivy, Grype, OWASP Dependency-CheckSnyk, Mend
Secretsgitleaks, TruffleHogGitHub Advanced Security
IaCCheckov, TrivyPrisma Cloud
RuntimeFalcoSysdig, CrowdStrike

37.4 A real public incident.

Name. Codecov Bash Uploader compromise.

Date. Codecov said unauthorized changes to its Bash Uploader began on 31 January 2021. Codecov said it learned of the problem on 1 April 2021. Codecov published a public security update on 15 April 2021.

Source. Codecov's security update of 15 April 2021 and Codecov's April 2021 post-mortem. A customer had compared a published checksum with the uploader they downloaded. This chapter does not describe how the credential was taken and does not describe the uploader's altered behavior beyond what those notices say in plain impact language.

What happened. Codecov's public notice said an error in its image-creation process allowed an unauthorized party to obtain a credential that could modify the Bash Uploader script. The altered script could export information present in customers' continuous integration environments, including credentials those environments held, to an outside destination. Related uploaders that wrapped the same script were affected. The control failure is a toolchain failure. Teams trusted a helper that ran inside the pipeline, often with the environment the build already had, and they did not all verify what they downloaded. Detection, in the public account, came from a customer checking a checksum, not from loyalty to the brand. The response that mattered for customers was to rotate credentials that had been exposed to CI, to stop using the altered path, and to understand blast radius. The lesson for selection is sharp. A coverage tool is not "just a reporter" if it runs in the deploy identity's room. Any tool on that shelf must be pinned, checked, least privileged, and replaceable. If the only way to keep the objective "we measure tests" is to pipe an unpinned remote script into a shell, you do not have mastery. You have a habit. You can meet the same objective with a vetted, versioned uploader, or you can decide the objective is not worth the risk and remove it. Removal is a valid selection.

How to stop.

  1. On systems you own, stop running the untrusted helper. Remove it from the pipeline the same day you know.
  2. Rotate credentials and tokens that the affected CI environment could see. Assume they left.
  3. Preserve pipeline logs and the identity list so you can see what the helper was allowed to reach.
  4. Rebuild from a clean, pinned toolchain before you trust new artifacts.
  5. Tell the people whose environments were in scope, without pasting secrets into the notice.

How to prevent it again.

  1. Pin tools by version and verify a checksum or signature you obtained out of band from the download.
  2. Keep CI environments minimal. A test-coverage helper does not need production keys.
  3. Separate the identity that builds and reports from the identity that deploys.
  4. Prefer a tool you can vendor or mirror inside a registry you control.
  5. Practice replacement: a lab pipeline that still meets the objective when tool A is removed and tool B, or no coverage upload at all, takes its place.
  6. Do not hunt for altered uploaders on other companies' systems. Read the advisory. Check your own lab and your own jobs.

This is for learning only, and only inside a system you are allowed to test.

37.5 A simple picture.

Four shelves you must be able to name: SAST, SCA, registry, and policy-as-code. Each shelf holds a swappable tool. The objective card stays when the logo changes.

Control objectives on shelves: SAST, SCA, registry, and policy-as-code, with tools that can be swapped.

37.6 A short animation.

A tool sits on the shelf and does the job. A second tool slides in. The first token fades out. The objective label never moves.

One tool replaces another on the same control shelf while the objective label stays.

37.7 Conclusion.

Raju turned the logos face down and wrote four sentences. Guru-ji let him pick a lab tool only after the sentence existed. "You can change your mind about a vendor. You cannot change your mind about whether an unsigned image may run, and then pretend the toolchain is mature. In Chapter 38 you will walk one small application through the whole road, in a lab, without a new logo and without a victim."

  • Name the objective. Then name the category. Then pick a tool.
  • SAST, SCA, registry, and policy-as-code are shelves, not religions.
  • An exit plan and a replacement drill are part of the purchase.
  • A tool that runs in CI must be pinned, minimal, and revocable.
  • Codecov's public update on 15 April 2021 is the lesson that a helper in the pipeline is a privileged tool.
  • Own lab only.

END OF CHAPTER 37 MASTER CLASS

RuleReason
Problem before productAvoid unused tools
Pin and verify toolsCodecov 2021
Measure false positivesKeep developer trust