Lesson 1 of 6 Security and Compliance Scanning

Designing a Security and Compliance Scanning Strategy

This lesson explains the main types of scanning, and where to place them.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish code, dependency, secret and licence scanning.
  • Place scans in the delivery path.
  • Explain why scheduled scans are needed.
  • Plan a gradual rollout.

Types of scanning

Code scanning

Static application security testing (SAST) analyses source code for flaws such as SQL injection, without running it. CodeQL treats code as data and queries it for vulnerable patterns. Because it sees the source, it can point to the exact line, and it can run early. It may raise false positives, and it cannot find problems that appear only at run time.

Dependency scanning

Software composition analysis (SCA) lists the open-source components that an application uses, directly and transitively, and compares them with vulnerability databases. Most application code is third-party code, so this covers a large share of risk. Dependabot and GitHub Advanced Security dependency scanning do this.

Secret scanning

Secret scanning searches content and history for credentials that match known patterns. Finding a secret after it is committed requires rotation, so push protection goes a step further, and it blocks the push.

Licence scanning

Licence scanning identifies the licence of each dependency, so that legal policy can be applied. Some copyleft licences may not suit proprietary products. Dependency review in GitHub can fail a pull request that adds a package with a disallowed licence.

Other scanning

Container scanning examines image layers for vulnerable packages, and IaC scanning finds insecure settings in templates, such as a publicly accessible storage account. Dynamic application security testing (DAST) probes a running application from outside.

Sort into groups

Which kind of scan finds it?

Exam skills 4.3.1

Decide which kind of scanning would find each problem.

Log in to try this activity Interactive activities are free with an account.

Placing scans in the pipeline

A scan helps most when its results reach the developer who can act, while the change is still fresh. The following table shows a typical placement.

PointScanEffect
Editor and pre-commitLinters, local secret checksImmediate warning
PushPush protectionBlocks known secrets
Pull requestCode scanning, dependency review, IaC checksBlocks new high-severity findings
Main branch buildFull dependency and container scansBlocks the artifact
Before productionDAST and image policy checksBlocks the release
ScheduledFull code and dependency rescansFinds newly disclosed vulnerabilities
RuntimeDefender for Cloud and registry scansMonitors what is deployed

Scheduled scans are essential. A library that was safe when it was deployed may have a vulnerability disclosed six months later, and a code change is not needed for the risk to appear.

The following diagram shows where dependency review blocks a risky change in a pull request.

Blocking risky dependencies at the pull request. The dependency-review action runs as a required status check when a dependency changes and fails on chosen vulnerability severities and on licences outside the allow list. Code scanning covers your own code, and Dependabot alerts report after the fact.
The scenario is illustrative.
Match the pairs

Where each scan belongs

Exam skills 4.3.1

Match each point in delivery with the scan placed there.

Log in to try this activity Interactive activities are free with an account.

Rolling out without blocking delivery

Turning on all scanners in blocking mode generally produces thousands of old findings, and teams quickly ask for it to be turned off. A gradual approach works better.

  1. Inventory

    Enable scanning in report-only mode, and measure the baseline.

  2. Stop the bleeding

    Block new high-severity findings on pull requests.

  3. Burn down

    Fix existing findings by severity, with time set aside.

  4. Tighten

    Lower the severity threshold over time.

Triage matters too. A finding can be a true problem, a false positive, or a real problem with low risk in context, so a process for dismissing findings with a reason is required. Software bills of materials (SBOMs) record what an artifact contains, which makes it possible to answer quickly whether a new vulnerability affects you.

Put in order

Rolling out scanning

Exam skills 4.3.1

Arrange a gradual rollout of security scanning.

Log in to try this activity Interactive activities are free with an account.
Worked example

Matching a scan to a need

A company's legal team must block any pull request that adds a dependency under a licence that it has not approved. Security also wants to prevent vulnerable versions from being added. The code is on GitHub. What should you configure?

Use dependency review with the dependency-review action, as a required status check. It can fail on chosen vulnerability severities, and on licences outside an allow list, at the point when a dependency changes. Code scanning looks for flaws in your own code, and not licences. Dependabot alerts report on existing dependencies after the fact, rather than blocking additions.

Check yourself

Why run a dependency scan on a schedule if no code has changed?

Show answer

New vulnerabilities are disclosed in existing packages, so a safe dependency can become unsafe.

Exam Tips

Remember for the exam

  • SAST reads code; SCA reads dependencies; DAST probes a running app.
  • Run scheduled scans, as new vulnerabilities appear with no code change.
  • Begin in report-only mode, then block new high-severity findings.
  • Dependency review can block vulnerable or disallowed-licence packages.
  • An SBOM shows what an artifact contains.