-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix several user reported issue NullReferenceException
#2596
Conversation
} | ||
context.Logger = logger; | ||
context.Logger = hashData?.Sha256 == null | ||
? (CachingLogger)context.Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's just wrap this code in a check that hashData.Sha256 is non-null, will be more readable.
Could we get this change in and then also try to mock up a test for this condition?
I'm concerned we're not necessarily handling this negative condition comprehensively.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we get this change in and then also try to mock up a test for this condition? ---- done fixing the code, will need to mock up a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix
NullReferenceException
when file hashing fails (due to file locked or other errors reading the file).One way to repro:
Scan the root folder and put the output SARIF file inside the folder, the output .sarif file will be locked,
for any reason can’t get hash (locked in this case), hashes will be null and then we will get unhandled null exception.