Automate security and compliance scanning
Learning objectives
- Match scanning to exposed credentials, vulnerable components, code patterns and infrastructure configuration.
- Configure the intended Advanced Security product and verify its actual analysis.
- Triage and remediate findings without equating dismissal or generated fixes with resolution.
- Connect DevOps environments to Defender for Cloud and inspect scope, identity continuity and freshness.
Place each scanner where its evidence exists
Secret scanning identifies exposed credentials. Dependency scanning looks for known vulnerable components. Code scanning analyzes supported patterns in supported languages, while IaC scanning examines supported infrastructure misconfigurations. None proves every vulnerability absent. Retain repository, commit, branch, configuration, run status and finding identity with each result.
Push protection addresses recognizable secrets in new pushes; repository scanning addresses existing history. Dependency analysis needs supported component/advisory coverage and the relevant dependency graph/build context. Code analysis needs supported languages and successful required builds. Cloud posture and code-to-cloud mapping add context but cannot replace an executed scan.
An alert does not automatically block merge or release. Configure the appropriate protection/check policy separately. A scanner enabled on a settings page, a completed analysis and an enforced gate are distinct states.
Triage findings through their actual exposure
Consider dependency path, runtime/development use, impact and exploitation likelihood. EPSS estimates exploitation likelihood, not severity. A missing scope label does not prove development-only use, and the same package can appear through different paths with different scopes.
For an exposed credential, revoke or rotate as well as remove source exposure. For a vulnerable dependency, upgrade/remove it, rebuild and rescan. For a code finding, review and test the correction and rerun analysis. Dismiss only for a documented justified reason; dismissal alone changes a record, not the underlying risk.
Copilot Autofix proposes a change. Inspect it, execute relevant tests and inspect the next scanner result. The adopted preview does not promise Autofix for secret or malware findings. In an illustrative case where a proposed patch removes an alert but breaks required behavior, remediation is incomplete even if scanning no longer reports the old location.
Configure Azure Repos analysis deliberately
Enable the relevant Secret Protection/Code Security product at the authorized repository and billing scope. Existing-repository enablement and automatic enablement for future repositories/projects are separate decisions. Applicable secret repository scanning starts with its feature; push protection evaluates later pushes. Code Security enablement alone does not execute a dependency scan.
An advanced dependency pipeline can include:
- task: AdvancedSecurity-Dependency-Scanning@1
Place it in the intended pipeline with supported dependency/build inputs available. Inspect the executed run rather than treating the task declaration as a scan receipt.
For CodeQL, choose default setup when supported language, shared pool and schedule fit. The dated adopted ADO source excludes Go and Swift from default setup and directs those cases to advanced setup. Advanced configuration supports custom builds, pools and branches. Repository permission, Marketplace-task availability and worker capacity still matter.
Inspect the real run and the intended branch's Advanced Security alerts. The documented hub does not display PR-branch findings as though they were default-branch results. Preserve that branch distinction when comparing the proposed change with accepted baseline analysis.
Inspect GitHub configuration tests and independent scanners
With Actions enabled and the relevant entitlement, use Settings → Security and quality → Advanced Security → Code Security → CodeQL analysis → Set up → Default. Inspect generated configuration, change languages/query suite where needed and choose Enable CodeQL. This launches configuration testing; inspect its actual completion.
If every supported-language analysis fails, the interface can remain enabled while no scans run until successful reconfiguration or a qualifying language addition. Thus an enabled label plus no alerts can mean missing analysis. Default setup can supersede advanced setup and its upload route; ADO organization-level coexistence does not prove identical GitHub repository behavior.
Enable other scanners independently. Under Advanced Security, choose Dependabot alerts → Enable. Separately select Secret Protection → Enable, review the impact, then Enable Secret Protection. Verify dependency alerts and secret settings/results independently of CodeQL's workflow. Entitlement, licensing and authorization remain applicable; these instructions do not perform enablement or billing changes.
For a controlled correction, compare commit and run, inspect finding identity/location, fix the cause and inspect the next analysis. An empty finding list may mean unsupported coverage or no successful run, not secure code. Retain errors and incomplete coverage instead of converting absence into a pass.
Onboard Defender with an operation-specific identity
A Defender for Cloud connector establishes inventory/security integration. It does not automatically enable every scanner or paid feature. The ADO quickstart requires subscription Contributor, target-organization Project Collection Administrator, Basic or Basic + Test Plans, and allowed third-party OAuth. The broader feature matrix also names Security Admin for connection scenarios; preserve requirements for the actual operation rather than declaring one role sufficient everywhere. GitHub connection needs organization-owner authority. Reading findings can use scoped Security Reader rather than subscription administration.
For ADO, open Defender for Cloud → Environment settings → Add environment → Azure DevOps. Supply name, subscription, resource group and region. Use Configure access in the intended tenant, review permissions and existing/future organization discovery scope, then Review and generate → Create. Inspect expected repositories/builds in Inventory and DevOps security. Discovery can take hours, and specific scanning recommendations may still need pipeline configuration.
The authorizing identity is used for operations and appears in audit/usage attribution. Its access loss can stop automation until reauthorization; calls count toward its consumption limits. Inspect identity continuity rather than repeatedly recreating the connector with broader privileges.
For GitHub, choose its supported environment connector and authorize the intended organization/repositories. Verify discovered repositories and connector health. The Microsoft Security DevOps action, applicable scanning/plan prerequisites and advanced code-to-cloud/posture evidence remain separate. Undecoded table icons do not establish plan entitlement.
Consider an illustrative healthy connector with no findings. Check whether the repository was discovered, the intended scanner actually ran, the identity still has access and the findings are fresh. An incomplete discovery window and an absent pipeline task produce a different diagnosis from a successful scan with no applicable findings. A service identity appropriate for continuity may help where supported, but it is not permission to widen access silently. No connector, product or live scan was configured for this lesson.
Summary
Use separate evidence for configuration, analysis, findings and enforcement. Triage exposure and dependency paths, verify proposed corrections through tests and new analysis, and preserve unsupported or failed coverage. Defender integration adds inventory and context only within its actual scope, identity and scanner prerequisites.
