fix: resolve cs/dereferenced-value-may-be-null in ListCredentialsAsync - #34
Merged
Merged
Conversation
The corrected buildless CodeQL analysis (adopted in #33) surfaced a cs/dereferenced-value-may-be-null alert on FileCredentialManager.cs: the provider-match guard was written `credential?.ProviderName.Equals(…) == true`, and CodeQL's flow analysis does not narrow `credential` to non-null through the `?.… == true` idiom, so the dereferences in the block body read as potential null accesses. The code was already safe (a null credential makes the guard false), but the guard is rewritten to `credential is not null && …` so the null state flows into the block — the whole body dereferences `credential` — letting both the compiler and CodeQL prove it safe. Behavior is unchanged. Build clean (0 warnings, TreatWarningsAsErrors on); 334 tests pass on net8.0 and net10.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Resolves the one open code-scanning alert on
main(cs/dereferenced-value-may-be-null,FileCredentialManager.cs:79) with a genuine code fix — no dismissal.Why it appeared now
The corrected buildless CodeQL analysis (#33) reads this file properly for the first time — the old compiled-build config had
paths-ignoresilently inert and analysed the wrong scope. The finding is real in the sense that CodeQL now sees it; the code itself was already safe.The fix
The provider-match guard was:
CodeQL's flow analysis doesn't narrow
credentialto non-null through the?.… == trueidiom, so every dereference in the block body (credential.ProviderName,.AccountId,.CredentialData, …) reads as a potential null access. Rewritten to:Behavior is identical (a null
credentialstill makes the guard false and skips the row), but the null state now flows into the block, so both the compiler and CodeQL can prove the accesses safe.Verification
TreatWarningsAsErrorson).net8.0andnet10.0.🤖 Generated with Claude Code