-
-
Notifications
You must be signed in to change notification settings - Fork 78
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: Match the complete BcSymbolMap header (NATIVE-281) #523
Conversation
Previously, the match was truncated to the input buffer length, which meant that empty files always passed the check, which they obviously should not.
5034f01
to
ff9ade1
Compare
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.
I can't request changes anymore... but I fear this breaks things
let buf = b"oops"; | ||
assert!(!BcSymbolMap::test(&buf[..])); | ||
assert!(BcSymbolMap::test(b"BCSymbolMap Version: 2.0")); | ||
assert!(!BcSymbolMap::test(b"BCSymbolMap Vers")); |
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.
IIRC it is important that this does pass the test, I suspect if sentry-cli adopts this you won't be able to upload any bcsymbolmaps anymore.
@@ -433,7 +428,7 @@ mod tests { | |||
) | |||
.unwrap(); | |||
|
|||
assert!(BcSymbolMap::test(&data.as_bytes()[..20])); | |||
assert!(BcSymbolMap::test(data.as_bytes())); |
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.
likely this 20 bytes was therefore also not an accidental number
Looking at this in more detail, I see two code paths calling |
Either way, we can also back out "half" of the change, meaning: Allow truncating down to ~20bytes. |
Is this what I recall then? If sentry-cli looks inside an archive this test only gets called with 16 bytes? That would still mean we want it to consider it a match if there are fewer bytes matching. IIRC this test method is supposed to be best effort, so if you only provide a slice of say 4 bytes and they match the first 4 bytes of our prefix it should still say "this could be a bcsymbolmap". though obviously doing this at 0 bytes is taking it too far :) |
Oh what I meant to refer to was this: symbolic/symbolic-debuginfo/src/object.rs Lines 127 to 129 in 10ccd26
Symbolic needs at least 16 bytes to actually detect anything. It does not truncate, only checks for that. Other longer file headers are also checked for precisely: symbolic/symbolic-debuginfo/src/pdb.rs Line 127 in 10ccd26
|
hum, did some spelunking in the sentry-cli codebase as well and I can't find a reason for the requirement to be able to do partial matches, though I'm like 100% sure this was a requirement and that this was done explicitly like this before. I think these API's are a bit meh as they are, they require a "large enough" slice but you're left not knowing what "large enough" means is as a caller. So whatever, I guess it's fine, thanks for having a look as well. |
Hm, maybe we should have a look at the |
good point, though it seems the test methods aren't even exposed on the python API and sentry re-implements this: https://github.com/getsentry/sentry/blob/master/src/sentry/models/debugfile.py#L421-L433 |
👍🏻 thanks for looking into this, in which case I think we are good. |
Previously, the match was truncated to the input buffer length, which meant that
empty files always passed the check, which they obviously should not.