[ CORRUPTED_GLITCH // TRANSMISSION_project-03-shift-left-sast ]

DATE ......

READ_TIME . 2 MIN

WORDS ..... 408

CHANNEL ... DEVOPS

REVISED ...

Project 03: Shifting Security Left with SAST in Azure Pipelines

Full build log: wiring SonarCloud static analysis into Azure DevOps CI/CD so vulnerabilities die in the pull request, not in production.

The mission: recurring vulnerability assessment across C# and TypeScript codebases, enforced automatically — a PR with a new critical finding cannot merge. No security review meetings, no spreadsheets.

[ PIPELINE PARAMS ]

SCANNER
SonarCloud (SAST + quality gate)
CI
Azure DevOps multi-stage YAML
LANGUAGES
C# (.NET) · TypeScript
GATE
new criticals = merge blocked
CADENCE
every PR + nightly full scan

#Pipeline Flow

 PR opened ──▶ build ──▶ unit tests ──▶ SONAR SCAN
                                            │
                              quality gate PASS? ── no ──▶ ✖ MERGE BLOCKED
                                            │                (finding linked
                                           yes                in the PR)
                                            ▼
                                     ✔ MERGE ALLOWED ──▶ CD stages

#Step 1 — The Scan Stage

azure-pipelines.yml YAML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
stages:
  - stage: Analyze
    jobs:
      - job: SAST
        steps:
          - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: "sonarcloud-conn"
              organization: "corrupted-glitch"
              scannerMode: "MSBuild"
              projectKey: "billing-api"
          - script: dotnet build --configuration Release
          - script: dotnet test --collect:"XPlat Code Coverage"
          - task: SonarCloudAnalyze@1
          - task: SonarCloudPublish@1
            inputs:
              pollingTimeoutSec: "300"   # wait for the verdict

#Step 2 — Make the Gate a Wall

A scan that only reports is decoration. Two switches make it enforcement:

  1. SonarCloud quality gate: new_critical_violations = 0, coverage on new code ≥ 80%.
  2. Azure DevOps branch policy: the Analyze stage is a required status check on main.

#Step 3 — Kill the Noise in Week One

The first scan on a real codebase produces hundreds of findings. Triage them once, aggressively:

sonar-project.properties (excerpt as ts for highlight) TYPESCRIPT
// Exclusions are a security decision — document each one
sonar.exclusions = "**/migrations/**, **/*.generated.cs, **/vendor/**"
sonar.cpd.exclusions = "**/dto/**"        // DTOs duplicate by design
sonar.issue.ignore.multicriteria = "e1"   // reviewed 2026-03: false positive

#Results

MetricBeforeAfter 90 days
Criticals reaching productionuntracked0
Mean fix time (critical)weeksinside the PR
Coverage on new code≥ 80% enforced
Security review meetingsweekly0

[ RELATED_SIGNALS ]