Skip to content

Scope SBoM and Component Governance scans to non-C++ source directories#195

Open
Omotola wants to merge 2 commits into
cmake-daemonfrom
dev/oakeredolu/sbom-scope-archivedir
Open

Scope SBoM and Component Governance scans to non-C++ source directories#195
Omotola wants to merge 2 commits into
cmake-daemonfrom
dev/oakeredolu/sbom-scope-archivedir

Conversation

@Omotola
Copy link
Copy Markdown

@Omotola Omotola commented Jun 2, 2026

Fixes false-positive CG alert MVS-2026-qx3q-rvv6 flagging VC-Tools-MSVC 14.34.31933 against MicrosoftCMake_cmake-daemon. CMake does not link with that toolset; it was registered because the auto-injected CppSdkDetector enumerates every MSVC SxS install on the build agent whenever it spots any *.c/*.cpp/*.cxx/*.vcxproj in its scan root.

Fix — point both scans at directories that contain no C/C++ source:

Step Config added Where
🛡 Generate SBoM Manifest templateContext.sdl.sbom.BuildComponentPath: $(ArchiveDir) + per-output sbomBuildDropPath: $(ArchiveDir) Job_x64, Job_arm64, Job_x86
🛡 Component Governance ComponentDetection.SourcePath: $(Build.SourcesDirectory)/VSInsertion top-level variables:

$(ArchiveDir) only holds the built CMake binaries. VSInsertion/ holds the legitimate CG inputs (cgmanifest.json, Signing/packages.config) and zero C/C++/.vcxproj files, so CgManifest and NuGetPackagesConfig continue to fire while CppSdk reports 0 | 0.

Job_Final is unchanged (its Symbols output already scopes sbomBuildDropPath).

Verified on build 14278416 across x64/arm64/x86:

  • CG alerts no longer show
  • SBoM: BuildComponentPath = D:\a\_work\1\a\archive, CppSdk (Beta) = 0 | 0, TotalNumberOfPackages = 3 (was 9 — 6 false-positive MSVC toolsets dropped).
  • CG: --SourceDirectory D:\a\_work\1\s\VSInsertion, CppSdk = 0 | 0.
  • Zero Scanning MSVC toolsets… / Found MSVC toolset… lines in any of the 6 logs.
  • CgManifest = 1 | 1 and NuGetPackagesConfig = 1 | 1 preserved in both steps.

Files changed (15 net lines):

  • VSInsertion/Pipelines/build.yml
  • VSInsertion/Packaging/cgmanifest.json (CommitHash bumped to fix commit)

Work item: AB#2992623
CG alert: MVS-2026-qx3q-rvv6 (alertId 13858911, repo id 113867)

@Omotola Omotola force-pushed the dev/oakeredolu/sbom-scope-archivedir branch from 3446a1c to 0a59019 Compare June 4, 2026 00:21
Omotola and others added 2 commits June 3, 2026 17:37
The auto-injected `Generate SBoM Manifest` and `Component Governance`
steps both run an internal `CppSdkDetector` that, whenever it sees any
`*.c`/`*.cpp`/`*.cxx`/`*.vcxproj` file in its scan root, enumerates
*every* MSVC toolset installed side-by-side on the build agent
(`C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\*`)
and registers each one as a CG component. Because the build agent
carries multiple SxS toolsets that CMake does not actually link with,
this produced false-positive CG alerts (e.g. MVS-2026-qx3q-rvv6 against
`VC-Tools-MSVC 14.34.31933`, a toolset CMake never uses).

Scope each scan to a sub-tree that contains no C/C++ source so the
detector never triggers:

* SBoM step (per arch job): set
  `templateContext.sdl.sbom.BuildComponentPath: $(ArchiveDir)` and the
  matching `outputs[].sbomBuildDropPath: $(ArchiveDir)`. The archive
  directory only holds the built CMake binaries and their resources.

* Component Governance step (pipeline-wide): set the auto-injected
  task's `ComponentDetection.SourcePath` variable to
  `$(Build.SourcesDirectory)/VSInsertion`. That directory contains the
  legitimate CG inputs (cgmanifest.json, packages.config) but no
  C/C++/.vcxproj files.

The legitimate detectors (`CgManifest`, `NuGetPackagesConfig`) still
fire and the produced SBoM is unaffected. Verified across x64/arm64/x86:
`CppSdk` reports `0 | 0` in both steps, the `Scanning MSVC toolsets` /
`Found MSVC toolset` log lines are gone, and `TotalNumberOfPackages`
dropped from 9 to the 3 real packages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pin CommitHash to the SBoM/CG scope-fix commit so CG records the
correct registered state of the CMake repo for this branch.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Omotola Omotola force-pushed the dev/oakeredolu/sbom-scope-archivedir branch from 0a59019 to c93b28d Compare June 4, 2026 00:37
@Omotola Omotola changed the title Scope SBoM manifest to ArchiveDir for CMake build jobs Scope SBoM and Component Governance scans to non-C++ source directories Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant