louis 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +7 -0
- data/Rakefile +11 -0
- data/lib/louis.rb +3 -7
- data/lib/louis/const.rb +9 -0
- data/lib/louis/version.rb +1 -1
- data/louis.gemspec +1 -0
- data/spec/louis_spec.rb +56 -0
- data/spec/spec_helper.rb +6 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c504dde7be169053134a867e3d2c34cb86a2f75c
|
4
|
+
data.tar.gz: f97494bf3010114f5c6ada56d951faf4f5fb99f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efb736393a05a7cd590e4967b97a155f7807ebd5c58e9f1497a937f82a03703a6c05a9526b15c6fdd5ccce3b1573ec3c7f9fde3d45fa012e99f7c68c951aa308
|
7
|
+
data.tar.gz: 85dc12268c91e3b2dd9d9a71fb01f7e2361a5b358a85ccd1860073adfca3b848d9196566e556301e8591dd73a276ec26f4265ee32594b29dd6009f55629fa55f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Louis
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/louis.svg)](http://badge.fury.io/rb/louis)
|
4
|
+
[![Build Status](https://travis-ci.org/pwnieexpress/louis.svg?branch=master)](https://travis-ci.org/pwnieexpress/louis)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/pwnieexpress/louis/badge.svg?branch=master)](https://coveralls.io/r/pwnieexpress/louis?branch=master)
|
6
|
+
[![Dependency Status](https://gemnasium.com/pwnieexpress/louis.svg)](https://gemnasium.com/pwnieexpress/louis)
|
7
|
+
[![Security](https://hakiri.io/github/pwnieexpress/louis/master.svg)](https://hakiri.io/github/pwnieexpress/louis/master)
|
8
|
+
[![Code Climate](https://codeclimate.com/github/pwnieexpress/louis/badges/gpa.svg)](https://codeclimate.com/github/pwnieexpress/louis)
|
9
|
+
|
3
10
|
There is a public registry maintained by the IANA that is required to be used
|
4
11
|
by all vendors operating in certains spaces. Ethernet, Bluetooth, and Wireless
|
5
12
|
device manufacturers are all assigned unique prefixes. This database is
|
data/Rakefile
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
2
|
|
3
|
+
begin
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
task :default => :spec
|
7
|
+
rescue LoadError
|
8
|
+
# no rspec available
|
9
|
+
end
|
10
|
+
|
11
|
+
task :parse_data_file => [:environment] do
|
12
|
+
end
|
13
|
+
|
3
14
|
task :environment do
|
4
15
|
base_path = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
|
5
16
|
$LOAD_PATH.unshift(base_path) unless $LOAD_PATH.include?(base_path)
|
data/lib/louis.rb
CHANGED
@@ -1,11 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require 'louis/const'
|
2
|
+
require 'louis/version'
|
2
3
|
|
3
4
|
module Louis
|
4
|
-
OUI_FILE = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data',
|
5
|
-
'mac_oui_manuf.txt'))
|
6
|
-
|
7
|
-
OUI_FORMAT_REGEX = /^(?<prefix>[0-9a-fA-F:\-]+)(\/(?<mask>(\d+)))?\s+(?<short_vendor>\S+)(\s+# (?<long_vendor>.+))?$/
|
8
|
-
|
9
5
|
# Calculate the bit mask for testing whether or not a mac_prefix matches.
|
10
6
|
# This returns an integer with the upper X bits set where X is the mask
|
11
7
|
# length.
|
@@ -42,7 +38,7 @@ module Louis
|
|
42
38
|
return if @lookup_table
|
43
39
|
@lookup_table = []
|
44
40
|
|
45
|
-
File.open(
|
41
|
+
File.open(ORIGINAL_OUI_FILE).each_line do |line|
|
46
42
|
if (matches = OUI_FORMAT_REGEX.match(line))
|
47
43
|
result = Hash[matches.names.zip(matches.captures)]
|
48
44
|
|
data/lib/louis/const.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
module Louis
|
2
|
+
ORIGINAL_OUI_FILE = File.expand_path(File.join(File.dirname(__FILE__), \
|
3
|
+
'..', '..', 'data', 'mac_oui_manuf.txt'))
|
4
|
+
|
5
|
+
PARSED_DATA_FILE = File.expand_path(File.join(File.dirname(__FILE__), \
|
6
|
+
'..', '..', 'data', 'processed_data.json'))
|
7
|
+
|
8
|
+
OUI_FORMAT_REGEX = /^(?<prefix>[0-9a-fA-F:\-]+)(\/(?<mask>(\d+)))?\s+(?<short_vendor>\S+)(\s+# (?<long_vendor>.+))?$/
|
9
|
+
end
|
data/lib/louis/version.rb
CHANGED
data/louis.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
|
+
spec.add_development_dependency "coveralls", "0.7.0"
|
24
25
|
spec.add_development_dependency "pry"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
spec.add_development_dependency "rdoc"
|
data/spec/louis_spec.rb
CHANGED
@@ -4,4 +4,60 @@ RSpec.describe Louis do
|
|
4
4
|
it 'has a version number' do
|
5
5
|
expect(Louis::VERSION).not_to be nil
|
6
6
|
end
|
7
|
+
|
8
|
+
it "it should have it's data file" do
|
9
|
+
expect(File.readable?(Louis::ORIGINAL_OUI_FILE)).to be(true)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'Format RegEx' do
|
13
|
+
subject { Louis::OUI_FORMAT_REGEX }
|
14
|
+
|
15
|
+
it "should ignore comment lines" do
|
16
|
+
comment_line = "# This is just a sample of what a comment might look like"
|
17
|
+
expect(subject).to_not match(comment_line)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should ignore blank lines" do
|
21
|
+
expect(subject).to_not match("")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# The core of the whole library
|
26
|
+
describe '#lookup' do
|
27
|
+
let(:base_mac) { '00:12:34:00:00:00' }
|
28
|
+
let(:partial_mac) { '3c:97:0e' }
|
29
|
+
let(:unknown_mac) { 'c5:00:00:00:00:00' }
|
30
|
+
|
31
|
+
it 'should return a hash' do
|
32
|
+
expect(Louis.lookup(base_mac)).to be_a(Hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have both the long vendor and short vendor' do
|
36
|
+
expect(Louis.lookup(base_mac).keys).to eq(['short_vendor', 'long_vendor'])
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should be able to identify the short vendor of a full MAC' do
|
40
|
+
expect(Louis.lookup(base_mac)['short_vendor']).to eq('CamilleB')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should be able to identify the long vendor of a full MAC' do
|
44
|
+
expect(Louis.lookup(base_mac)['long_vendor']).to eq('Camille Bauer')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should be able to identify the short vendor of a partial MAC' do
|
48
|
+
expect(Louis.lookup(partial_mac)['short_vendor']).to eq('WistronI')
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should be able to identify the long vendor of a patrial MAC' do
|
52
|
+
expect(Louis.lookup(partial_mac)['long_vendor']).to eq('Wistron InfoComm(Kunshan)Co.,Ltd.')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should return "Unknown" as the short vendor string for unknown MAC prefixes' do
|
56
|
+
expect(Louis.lookup(unknown_mac)['short_vendor']).to eq('Unknown')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should return "Unknown" as the long vendor string for unknown MAC prefixes' do
|
60
|
+
expect(Louis.lookup(unknown_mac)['long_vendor']).to eq('Unknown')
|
61
|
+
end
|
62
|
+
end
|
7
63
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,8 +3,13 @@ $LOAD_PATH.unshift(base_path) unless $LOAD_PATH.include?(base_path)
|
|
3
3
|
|
4
4
|
require 'rspec'
|
5
5
|
require 'simplecov'
|
6
|
+
require 'coveralls'
|
7
|
+
|
8
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
Coveralls::SimpleCov::Formatter
|
11
|
+
]
|
6
12
|
|
7
|
-
SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
|
8
13
|
SimpleCov.add_filter "/spec/"
|
9
14
|
SimpleCov.add_filter do |source_file|
|
10
15
|
source_file.lines.count < 3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: louis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stelfox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coveralls
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.0
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: pry
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,6 +143,7 @@ files:
|
|
129
143
|
- Rakefile
|
130
144
|
- data/mac_oui_manuf.txt
|
131
145
|
- lib/louis.rb
|
146
|
+
- lib/louis/const.rb
|
132
147
|
- lib/louis/version.rb
|
133
148
|
- louis.gemspec
|
134
149
|
- spec/louis_spec.rb
|