8000 Bluetooth LE: multiple improvements by micolous · Pull Request #1855 · secdev/scapy · GitHub
[go: up one dir, main page]

Skip to content

Bluetooth LE: multiple improvements #1855

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

Merged
merged 1 commit into from
Mar 2, 2019
Merged

Conversation

micolous
Copy link
Contributor
@micolous micolous commented Feb 17, 2019

A number of fixes and enhancements, primarily for Bluetooth Low Energy:

  • Fix: BluetoothHCISocket.sr now works
  • Fix: Python 3 issue with LEMacField
  • New: Bluetooth documentation page, explaining Bluetooth physical layer differences and some basic recipes for connecting to the HCI, BLE discovery and advertising.
  • New: cross-references for Bluetooth SIG assigned numbers
  • New: BTUUID128Field for 128-bit UUID fields
  • New: Adds some more EIR_Hdr enum types, and sort them
  • New: EIR_CompleteList128BitServiceUUIDs (and IncompleteList)
  • New: EIR_ServiceData16BitUUID (with protocol stacking support)
  • Fix: Protocol stacking for EIR_Manufacturer_Specific_Data
  • Fix: Renames HCI_Event_Hdr.length to .len (for consistency), and fixes calculation of it
  • Fix: Can now dissect packets composed of multiple HCI_LE_Meta_Advertising_Report (.number > 1), by adding HCI_LE_Meta_Advertising_Reports, which contains a list of HCI_LE_Meta_Advertising_Report.
  • Fix: Set a default MTU on Bluetooth*Socket classes
  • New: HCI BLE whitelist commands
  • New: Eddystone beacons which uses the new stackable functionality of EIR_ServiceData16BitUUID
  • Adds tests for new functionality, and regression tests for fixes where plausible

This PR looks huge, but nearly half of the lines in this PR come from the documentation!

@codecov
Copy link
codecov bot commented Feb 17, 2019

Codecov Report

Merging #1855 into master will increase coverage by 0.02%.
The diff coverage is 93.22%.

@@            Coverage Diff             @@
##           master    #1855      +/-   ##
==========================================
+ Coverage   85.76%   85.79%   +0.02%     
==========================================
  Files         185      186       +1     
  Lines       42473    42638     +165     
==========================================
+ Hits        36429    36583     +154     
- Misses       6044     6055      +11
Impacted Files Coverage Δ
scapy/layers/bluetooth.py 86.81% <91.11%> (+0.4%) ⬆️
scapy/contrib/eddystone.py 95.4% <95.4%> (ø)
scapy/layers/tls/basefields.py 80.53% <0%> (+0.67%) ⬆️

@gpotter2
Copy link
Member
8000 gpotter2 commented Feb 18, 2019

SIde note: if you’re wondering why tests are failing (even though it’s a draft), modules now require to have special tags defined (it has existed for a long time, but wasn’t enforced since very recently so there’s no other doc that
https://github.com/secdev/scapy/blob/master/scapy/main.py#L197-L203 for now).

Edit: doc will be added in #1865

Those tags allow Scapy to display the file correctly when using the explore() command

@micolous micolous force-pushed the bluetooth-fun branch 3 times, most recently from 43f7af2 to e33057a Compare February 24, 2019 09:56
@micolous micolous changed the title (DRAFT) Bluetooth LE: multiple improvements Bluetooth LE: multiple improvements Feb 24, 2019
@micolous micolous marked this pull request as ready for review February 24, 2019 10:04
@gpotter2
Copy link
Member
gpotter2 commented Feb 24, 2019

Hi ! PR’s looking great.

Note we apply a strict PEP8 linter in order to keep code consistency across the codebase. Your PR has a few errors, available at https://travis-ci.org/secdev/scapy/jobs/497727702#L880 (one of them is that we disallow star (import *) imports

Edit:

List of errors
scapy/
scapy/contrib/eddystone.py:19:1: F403 'from scapy.layers.bluetooth import *' used; unable to detect undefined names
scapy/contrib/eddystone.py:88:26: F405 'six' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:105:13: F405 'EIR_Hdr' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:105:22: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:105:23: F405 'EIR_Flags' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:107:13: F405 'EIR_Hdr' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:107:22: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:107:23: F405 'EIR_CompleteList16BitServiceUUIDs' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:109:13: F405 'EIR_Hdr' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:109:22: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:109:23: F405 'EIR_ServiceData16BitUUID' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:109:49: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:115:16: F405 'HCI_LE_Meta_Advertising_Report' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:117:21: E261 at least two spaces before inline comment
scapy/contrib/eddystone.py:127:16: F405 'HCI_Hdr' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:127:25: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:127:26: F405 'HCI_Command_Hdr' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:127:43: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:127:44: F405 'HCI_Cmd_LE_Set_Advertising_Data' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:148:9: F405 'ByteEnumField' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:168:33: E226 missing whitespace around arithmetic operator
scapy/contrib/eddystone.py:177:9: F405 'ByteEnumField' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:204:1: E302 expected 2 blank lines, found 1
scapy/contrib/eddystone.py:221:13: F405 'EIR_ServiceData16BitUUID' may be undefined, or defined from star imports: scapy.layers.bluetooth
scapy/contrib/eddystone.py:222:1: W391 blank line at end of file
scapy/layers/bluetooth.py:76:80: E501 line too long (80 > 79 characters)
scapy/layers/bluetooth.py:90:80: E501 line too long (80 > 79 characters)
scapy/layers/bluetooth.py:92:80: E501 line too long (80 > 79 characters)
scapy/layers/bluetooth.py:681:9: E741 ambiguous variable name 'l'
scapy/layers/bluetooth.py:684:1: E302 expected 2 blank lines, found 1
scapy/layers/bluetooth.py:693:9: E741 ambiguous variable name 'l'
scapy/layers/bluetooth.py:696:1: E302 expected 2 blank lines, found 1
scapy/layers/bluetooth.py:704:1: E302 expected 2 blank lines, found 1
scapy/layers/bluetooth.py:829:36: E128 continuation line under-indented for visual indent
scapy/layers/bluetooth.py:929:24: E126 continuation line over-indented for hanging indent
scapy/layers/bluetooth.py:933:20: E126 continuation line over-indented for hanging indent
scapy/layers/bluetooth.py:942:1: E302 expected 2 blank lines, found 1
scapy/layers/bluetooth.py:959:13: E128 continuation line under-indented for visual indent
scapy/layers/bluetooth.py:989:22: E126 continuation line over-indented for hanging indent
scapy/layers/bluetooth.py:1047:80: E501 line too long (96 > 79 characters)

* **Fix:** `BluetoothHCISocket.sr` now works

* **Fix:** Python 3 issue with `LEMacField`

* **New:** Bluetooth documentation page, explaining Bluetooth physical layer
  differences and some basic recipes for connecting to the HCI, BLE
  discovery and advertising.

* **New:** cross-references for Bluetooth SIG assigned numbers

* **New:** `BTUUID128Field` for 128-bit UUID fields

* **New:** Adds some more `EIR_Hdr` enum types, and sort them

* **New:** `EIR_CompleteList128BitServiceUUIDs` (and `IncompleteList`)

* **New:** `EIR_ServiceData16BitUUID` (with protocol stacking support)

* **Fix:** Protocol stacking for `EIR_Manufacturer_Specific_Data`

* **Fix:** Renames `HCI_Event_Hdr.length` to `.len` (for consistency), and
  fixes calculation of it

* **Fix:** Can now dissect packets composed of multiple
  `HCI_LE_Meta_Advertising_Report` (`.number > 1`), by adding
  `HCI_LE_Meta_Advertising_Reports`, which contains a list of
  `HCI_LE_Meta_Advertising_Report`.

* **Fix:** Set a default MTU on `Bluetooth*Socket` classes

* **New:** HCI BLE whitelist commands

* **New:** [Eddystone beacons](https://github.com/google/eddystone) which
  uses the new stackable functionality of `EIR_ServiceData16BitUUID`

* Adds tests for new functionality, and regression tests for fixes where
  plausible
@micolous
Copy link
Contributor Author
micolous commented Feb 24, 2019

Thanks, pep8 issues should be addressed now. I have done another rebase/squash with those extra commits -- it looks like PyPI was still is having a bad day: https://travis-ci.org/secdev/scapy/jobs/497731888#L915

@gpotter2
Copy link
Member
gpotter2 commented Feb 24, 2019

Yeah, I’m investigating. One of our optional dependencies (python-can, used for CAN socket 8000 s), made a release 2hours ago.

I’ll be following up the issue with them hardbyte/python-can#520

@gpotter2
Copy link
Member

They fixed it. Just restarted all failing tests (on all failing PRs, might take some time)

Copy link
Member
@gpotter2 gpotter2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good to me ! Great PR ! Thanks a lot

I'll merge it later today

@gpotter2 gpotter2 merged commit f837905 into secdev:master Mar 2, 2019
@micolous micolous mentioned this pull request Mar 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Performs some code clean-up enhancement new layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0