Skip to content
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

Always pad MAC addresses from nmap tracker with leading zeros #23492

Merged
merged 1 commit into from Apr 30, 2019

Conversation

Projects
None yet
4 participants
@mikeage
Copy link
Contributor

commented Apr 27, 2019

Breaking Change:

"Breaks" the MAC detection on a Mac by aligning it to the convention on Linux

Description:

In Linux, and when running a setuid nmap, MAC addresses are reported with a leading zero in each byte. Under Mac OS X, when running the arp command, there is no leading zero. This makes it annoying to share config files between a Mac and Linux setup.

This PR fixes this by forcing MAC addresses to be zero padded.

Sample results from arp, showing the rather different formats:

pi@raspberrypi:~ $  arp -n 192.168.1.137
Address                  HWtype  HWaddress           Flags Mask            Iface
192.168.1.137            ether   28:3a:4d:08:b5:c5   C                     wlan0

user@mac ~ $ arp -n 192.168.1.137
? (192.168.1.137) at 28:3a:4d:8:b5:c5 on en1 ifscope [ethernet]

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
@pvizeli
Copy link
Member

left a comment

LGTM

@mikeage

This comment has been minimized.

Copy link
Contributor Author

commented Apr 30, 2019

LGTM

Just to be clear, I saw this was originally a comment, and was then changed to a textual approval... but should it be a Github Code Review approval? [I'm not sure how the release process works in terms of finding which changes are ready to merge and how core contributors etc handle this process]

@pvizeli

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

Yeah, I was needed 2 rounds to understand exactly what you try to do :)

@fabaff

fabaff approved these changes Apr 30, 2019

Copy link
Member

left a comment

Seems to do what it should:

>>> import re
>>> macs = ['28:0:4d:8:0:c5', '0:0a:0:08:b5:0', '00:0:0:00:b5:c5']
>>> for mac in macs:
...     match = re.search(r'(([0-9A-Fa-f]{1,2}\:){5}[0-9A-Fa-f]{1,2})', str(mac))
...     print('{}\t-> {}'.format(mac, ':'.join([i.zfill(2) for i in match.group(0).split(':')])))
... 
28:0:4d:8:0:c5	-> 28:00:4d:08:00:c5
0:0a:0:08:b5:0	-> 00:0a:00:08:b5:00
00:0:0:00:b5:c5	-> 00:00:00:00:b5:c5

@fabaff fabaff merged commit 09012e7 into home-assistant:dev Apr 30, 2019

13 checks passed

build Workflow: build
Details
ci/circleci: pre-install-all-requirements Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.5.5 Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.6 Your tests passed on CircleCI!
Details
ci/circleci: pre-test 3.7 Your tests passed on CircleCI!
Details
ci/circleci: pylint Your tests passed on CircleCI!
Details
ci/circleci: static-check Your tests passed on CircleCI!
Details
ci/circleci: test 3.5.5 Your tests passed on CircleCI!
Details
ci/circleci: test 3.6 Your tests passed on CircleCI!
Details
ci/circleci: test 3.7 Your tests passed on CircleCI!
Details
cla-bot Everyone involved has signed the CLA
codecov/patch Coverage not affected when comparing 7458f1f...2d10e28
Details
codecov/project 94.29% (target 90%)
Details

@fabaff fabaff changed the title Always pad mac addresses from nmap tracker with leading zeros Always pad MAC addresses from nmap tracker with leading zeros Apr 30, 2019

@mikeage mikeage deleted the mikeage:patch-1 branch May 12, 2019

@balloob balloob referenced this pull request May 14, 2019

Merged

0.93.0 #23864

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.