-
Notifications
You must be signed in to change notification settings - Fork 92
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
Enable peekable-based binary sniffing on ZipArchiveArtifacts #2773
Conversation
string extension = Path.GetExtension(Uri.ToString()); | ||
if (this.binaryExtensions.Contains(extension)) | ||
const int PeekWindowBytes = 1024; | ||
var peekable = new PeekableStream(this.Stream, PeekWindowBytes); |
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.
Does this need to be disposed?
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.
No, peekable just has the underlying stream and a managed buffer. 1k, in this case.
string extension = Path.GetExtension(Uri.ToString()); | ||
return this.binaryExtensions.Contains(extension); | ||
GetArtifactData(); | ||
return this.bytes != null; |
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.
Before this check was cheap, now it looks like it's potentially much more expensive since you're introspecting the actual stream. Are there any concerns around perf changes here?
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.
Sort of, but that expectation has to be baked into the whole premise of categorizing based on contents.
I would say I just gained appreciation on another thread that the way we protect ourselves from scanning obviously bogus content is the file deny extensions, which remains a feature. So you could imagine that once you've passed that check, we're going to scan, so the only perf-sensitivity to this change would be when we do the first read. (Not if.) That's not a high-stakes question.
Interested in Michael's take on this.
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.
Left minor question, otherwise LGTM.
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.
No description provided.