Skip to content

Dev/sraroseck/danmoseley/binskim suppress err997 ilonly#1193

Open
Sasinkas wants to merge 8 commits into
mainfrom
dev/sraroseck/danmoseley/binskim-suppress-err997-ilonly
Open

Dev/sraroseck/danmoseley/binskim suppress err997 ilonly#1193
Sasinkas wants to merge 8 commits into
mainfrom
dev/sraroseck/danmoseley/binskim-suppress-err997-ilonly

Conversation

@Sasinkas

@Sasinkas Sasinkas commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Dan Moseley and others added 8 commits April 16, 2026 12:51
Remove EnforcePdbLoadForManagedAssemblies from the ERR997 gate condition
so that IL-only managed assemblies (including satellite resource assemblies)
no longer trigger ERR997.ExceptionLoadingPdb. These assemblies typically
have no PDB, and no current rule requires PDB data for IL-only binaries.

Native and mixed-mode binaries still trigger ERR997 as before.

The two PDB-using rules applicable to IL-only assemblies (BA2004, BA2027)
already handle null PDB gracefully via LogPdbLoadException => false.

Mark EnforcePdbLoadForManagedAssemblies as [Obsolete] since it is public
virtual but no longer referenced in the gate logic.

Fixes #1173

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Assemblies

- New property defaults to false (opt-in instead of opt-out)
- Add IsManagedResourceOnly unconditional skip for satellite DLLs
- Future rules can override RequiresPdbForManagedAssemblies => true to
  get the ERR997 safety net for IL-only managed assemblies

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…o false

Restore the original property name to avoid a breaking public API change.
The default is changed from true to false so IL-only managed assemblies
no longer trigger ERR997.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Suppress ERR997 for IL-only managed assemblies
@Sasinkas Sasinkas requested a review from a team as a code owner June 8, 2026 09:10

@martin-reznik martin-reznik left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Recommend against merging this as written (Request changes).

I traced the reachability and this diff is a behavioral no-op for all 17 shipped rules — the 14 default-logging rules exclude IsILOnly in CanAnalyzePE, and the 3 managed-applicable rules (BA2004, BA2027, BA4001) already set LogPdbLoadException => false, so none reach the changed block. There are no SARIF baseline changes, consistent with that.

So the only real effect is on the SDK default that downstream/future rules inherit — and it flips the framework bias from fail-safe to fail-open:

In Analyze, the null-PDB early-return (crash protection) is welded to the ERR997 emission:

if (LogPdbLoadException) {
    if (target.Pdb == null && (!IsManaged || IsMixedMode || EnforcePdbLoadForManagedAssemblies)) {
        LogExceptionLoadingPdb(...);   // emit ERR997
        return;                         // protect the rule body from a null PDB
    }
}
this.AnalyzePortableExecutableAndPdb(context);   // runs with Pdb == null if we didn't return

Flipping EnforcePdbLoadForManagedAssemblies to false removes the early-return for managed-IL targets, so a managed-applicable rule that keeps the default LogPdbLoadException now runs with Pdb == null → either an NRE (no guard) or a silent skip / false negative (self-guarded). In a security scanner, a silent false negative is the worst outcome — "no result" reads as "clean." Note --ignorePdbLoadError already makes the loud path non-fatal, so the loudness this removes was already tunable.

The history reinforces this. #988 (fixing #986) handled a managed binary missing its PDB causing a fatal ExceptionLoadingPdb — caused by BA2027 (#657) forgetting LogPdbLoadException => false. The durable fix was the per-rule opt-out plus the RulePropertyTests allow-list. The fail-safe default is exactly what made that omission loud enough to catch and fix quickly; this change would make the same class of omission silent. BA2027 also shows "needs-PDB and managed-applicable" is a real, shipped shape (SourceLink data lives in the PDB), so the SDK default genuinely matters.

Also process-wise: empty description, no linked work item, no tests — and the change routes around the RulePropertyTests guard rather than extending it.

Suggestion: keep EnforcePdbLoadForManagedAssemblies => true. If a specific managed rule is too aggressive about PDBs, opt it out explicitly (the existing, test-enforced pattern). If there's a real downstream need behind this, could you share the scenario? The right fix is likely to decouple the welded concerns — always early-return on a null PDB (no NRE for any future rule) and let the flags control only whether it surfaces as ERR997 vs a non-fatal NotApplicable/informational — rather than flipping the whole default to silent-by-default.

@danmoseley

Copy link
Copy Markdown

Sounds fine to me. @Sasinkas LMK if you need me to do anything here but it would be great if you could just make the fix as I have moved teams and roles

@martin-reznik

Copy link
Copy Markdown
Collaborator

@danmoseley - can you remind me reasoning behind this change? From what I saw, it should be no-op for all current rules (it would not change behavior of any of them), but it would effectively flip the default - and this control should be ideally on the rule itself.

Maybe I am misunderstanding the impact?

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.

3 participants