Skip to content

[build] Scope BinSkim scanning to build output only#10940

Merged
jonathanpeppers merged 1 commit intomainfrom
dev/peppers/BinSkimTestFailures
Mar 16, 2026
Merged

[build] Scope BinSkim scanning to build output only#10940
jonathanpeppers merged 1 commit intomainfrom
dev/peppers/BinSkimTestFailures

Conversation

@jonathanpeppers
Copy link
Member

Add analyzeTargetGlob to restrict BinSkim to bin\Build*\ directories, excluding bin\Test*\ test assemblies. Test-built debug assemblies produce BA2021 (DoNotMarkWritableSectionsAsExecutable) false positives that add noise to every failing PR build.

The 1ES template applies sdl config globally to all jobs with no per-job override mechanism, so analyzeTargetGlob is the most targeted way to exclude test output from scanning.

Add analyzeTargetGlob to restrict BinSkim to bin\Build*\ directories,
excluding bin\Test*\ test assemblies. Test-built debug assemblies
produce BA2021 (DoNotMarkWritableSectionsAsExecutable) false positives
that add noise to every failing PR build.

The 1ES template applies sdl config globally to all jobs with no
per-job override mechanism, so analyzeTargetGlob is the most targeted
way to exclude test output from scanning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 13, 2026 21:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Scopes BinSkim SDL scanning in the Azure Pipelines 1ES template configuration to only scan actual product build outputs, reducing noise from test-built assemblies that can trigger false positives (e.g., BA2021).

Changes:

  • Adds a BinSkim analyzeTargetGlob filter to include only bin\Build*\** content.
  • Documents the intent inline (exclude bin\Test* test assemblies from BinSkim scanning).

Copy link
Member Author

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review Summary

Verdict: ⚠️ Needs Changes

Found 1 issue:

  • ⚠️ MSBuild targets: The analyzeTargetGlob successfully eliminates BA2021 false positives from test assemblies under bin/Test*, but CI still fails with BA2007 (EnableCriticalCompilerWarnings) on bin/BuildRelease/net10.0/arm64/libZipSharpNative-3-3.dll and the x64 variant — these are in bin/Build* and pass through the new filter. The PR needs either a .gdnbaselines file to baseline BA2007 for libZipSharpNative, or the libzip CMake build needs -wd4996 removed.

👍 Good targeted approach — analyzeTargetGlob is the right lever since the 1ES template doesn't support per-job SDL overrides.


Review generated by android-reviewer from review guidelines.

binskim:
scanOutputDirectoryOnly: true
# Only scan actual build output, not test assemblies under bin/Test*
analyzeTargetGlob: +|bin\Build*\**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 ⚠️ CI / SDL — This glob correctly excludes bin/Test* assemblies (fixing BA2021 noise), but CI still fails because BA2007 fires on bin/BuildRelease/net10.0/{arm64,x64}/libZipSharpNative-3-3.dll — which matches bin\Build*\**.

Options to get CI green:

  1. Add a .gdnbaselines file to baseline BA2007 for libZipSharpNative (the -wd4996 comes from the upstream libzip CMake build and isn't trivially fixable).
  2. Or add a second exclude pattern: analyzeTargetGlob: +|bin\Build*\** -|**\libZipSharpNative*

Without one of these, this PR alone won't unblock CI.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement to not find tons of issues when MSBuild test lanes fail.

We should actually fix libZipSharp separately.

@jonathanpeppers jonathanpeppers merged commit 574e797 into main Mar 16, 2026
9 of 10 checks passed
@jonathanpeppers jonathanpeppers deleted the dev/peppers/BinSkimTestFailures branch March 16, 2026 15:38
jonathanpeppers added a commit that referenced this pull request Mar 16, 2026
The +|bin\Build*\** glob uses BinSkim CLI prefix syntax that the 1ES
Guardian wrapper does not support, causing: 'Could not parse glob
pattern'. scanOutputDirectoryOnly: true already restricts scanning to
the staging output directory, so the additional glob is unnecessary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jonathanpeppers added a commit that referenced this pull request Mar 16, 2026
The +| prefix is BinSkim CLI syntax that the 1ES Guardian wrapper
cannot parse: 'Could not parse glob pattern'. Remove the +| prefix
and keep the glob pattern for Guardian compatibility.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants