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.
Hi,
first of all thank you for this great tool! I used it in one of my projects and it helps me to find a bug in a BLE smart lock.
While using your tool as a library and wrapping it with my code, I found two small bugs:
The first can be validated by looking at the implementation of
ConnectionSniffer
. In the methodon_packet_received
the methodon_connection
is called with a given timeout (packet.timeout
):btlejack/btlejack/supervisors.py
Lines 501 to 511 in c487859
I know the
on_connection
function is a placeholder and should be overridden like inCLIConnectionSniffer
anyway, but I think the interface should be the same. So I would add the timeout argument here:btlejack/btlejack/supervisors.py
Lines 528 to 530 in c487859
The second is an error during unpacking. Unpacking with
unpack('<H', raw[1:])[0]
of more than 2 bytes leads tostruct.error: unpack requires a buffer of 2 bytes
:btlejack/btlejack/dissect/att.py
Lines 205 to 210 in c487859
For the
WriteCommand
it was sliced correctly:btlejack/btlejack/dissect/att.py
Lines 221 to 226 in c487859
I assume that this behavior also occurs with other
from_bytes
implementations in the same module likeExchangeMtuResponse
,ExchangeMtuRequest
andErrorResponse
, but I am not 100% sure. Maybe some can confirm that?