pod_ident 1.0.8 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91627e7d83c5598628aa8a1a677e61931e15b322f63158bbfabec7f20443bad7
4
- data.tar.gz: 7b36f2fc9ee8f88bd23a623dfc49a767ebd8214cfcd8abe5b8acecc91722c3f9
3
+ metadata.gz: e198325ee4e089c59c75f1006e724fdd747178542003cb49806f2714bc3abd5e
4
+ data.tar.gz: ccae58509136c30d486261328ff800dbd7bf6502eaf872da32dfa89782fe7257
5
5
  SHA512:
6
- metadata.gz: 45dee4cda059fd68082b9c5c9e4269ce52fd797aa5176a20f3708a0dd19da568ae27cbe85a8ab6826408be01aecf44ee6f3a84f9c3e81cecc9cfe9520bda5d1f
7
- data.tar.gz: 245579bb696a18bd58ae234f9effdd801c24d404513ee9e33e6cfd05f80f8c68e6df60105372e9dc7092f8344d9c7941c297772ea13038663fe9c8c205d77840
6
+ metadata.gz: fdc493231340b1d3388e72495caae70b49a086625d2c26855023fd2b5302ed3be52ca708afb1cf69da3cad3007cd373231f96c21ddc425d6dabeea362f8ecbff
7
+ data.tar.gz: b68cbe2646ae9866ae4aa042d6b6a3b0e429588609112271961c2444748b4c95537cf52bbd5687f36904cf497f62de3d69982e4aa7e24d7fea9915e3c3be4a53
data/.rubocop.yml CHANGED
@@ -16,5 +16,5 @@ Metrics/BlockLength:
16
16
  - 'Rakefile'
17
17
  - '**/*.rake'
18
18
  - 'spec/**/*.rb'
19
- Lint/UnneededCopDisableDirective:
19
+ Lint/RedundantCopDisableDirective:
20
20
  Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.6
1
+ 3.2.2
data/Gemfile.lock CHANGED
@@ -1,39 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pod_ident (1.0.8)
4
+ pod_ident (1.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  coderay (1.1.3)
10
- diff-lcs (1.4.4)
10
+ diff-lcs (1.5.0)
11
11
  method_source (1.0.0)
12
- pry (0.13.1)
12
+ pry (0.14.2)
13
13
  coderay (~> 1.1)
14
14
  method_source (~> 1.0)
15
- rake (13.0.1)
16
- rspec (3.9.0)
17
- rspec-core (~> 3.9.0)
18
- rspec-expectations (~> 3.9.0)
19
- rspec-mocks (~> 3.9.0)
20
- rspec-core (3.9.2)
21
- rspec-support (~> 3.9.3)
22
- rspec-expectations (3.9.2)
15
+ rake (13.0.6)
16
+ rspec (3.12.0)
17
+ rspec-core (~> 3.12.0)
18
+ rspec-expectations (~> 3.12.0)
19
+ rspec-mocks (~> 3.12.0)
20
+ rspec-core (3.12.2)
21
+ rspec-support (~> 3.12.0)
22
+ rspec-expectations (3.12.3)
23
23
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.9.0)
25
- rspec-mocks (3.9.1)
24
+ rspec-support (~> 3.12.0)
25
+ rspec-mocks (3.12.5)
26
26
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.9.0)
28
- rspec-support (3.9.3)
29
- rspec_junit_formatter (0.4.1)
27
+ rspec-support (~> 3.12.0)
28
+ rspec-support (3.12.0)
29
+ rspec_junit_formatter (0.6.0)
30
30
  rspec-core (>= 2, < 4, != 2.12.0)
31
31
 
32
32
  PLATFORMS
33
33
  ruby
34
34
 
35
35
  DEPENDENCIES
36
- bundler (~> 1.16)
36
+ bundler (~> 2.0)
37
37
  pod_ident!
38
38
  pry
39
39
  rake (~> 13.0)
@@ -41,4 +41,4 @@ DEPENDENCIES
41
41
  rspec_junit_formatter
42
42
 
43
43
  BUNDLED WITH
44
- 1.17.3
44
+ 2.4.14
data/README.md CHANGED
@@ -57,6 +57,21 @@ puts result.platform
57
57
  => 'iPod'
58
58
  ```
59
59
 
60
+ ### Bot detection
61
+
62
+
63
+ ```ruby
64
+ require 'pod_ident'
65
+
66
+ user_agent = 'Mozilla/5.0 (compatible; archive.org_bot http://archive.org/details/archive.org_bot)'
67
+ result = PodIdent::Detector.detect(user_agent)
68
+
69
+ puts result.app
70
+ => 'Archive.org'
71
+ puts result.bot?
72
+ => true
73
+ ```
74
+
60
75
  ## Development
61
76
 
62
77
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -67,6 +82,12 @@ The detection rules are found as a yaml file under `lib/detection_rules.yml`.
67
82
 
68
83
  Please, only edit this file, and afterwards run `bin/parse-rules` in order to generate both the detection rules as a `rb` file for production usage, and the complete rules with their corresponding test cases for testing.
69
84
 
85
+ ### Update bot detection rules
86
+
87
+ For the bot detection rules we are using [ user-agents-v2](https://github.com/opawg/user-agents-v2/blob/master/src/bots.json), to import the json of this project and transform it into a yaml file readable by pod-ident you can run the following task: `rake update_bot_rules`.
88
+
89
+ Once the yml file created run `bin/parse-rules` to generate all rb detection rules files for bots.
90
+
70
91
  ## Contributing
71
92
 
72
93
  Bug reports and pull requests are welcome on GitHub at https://github.com/podigee/pod_ident.rb.
data/Rakefile CHANGED
@@ -1,6 +1,61 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'json'
4
+ require 'yaml'
5
+ require 'net/http'
6
+ require 'uri'
3
7
 
4
8
  RSpec::Core::RakeTask.new(:spec)
5
9
 
6
- task :default => :spec
10
+ task default: :spec
11
+
12
+ task :update_bot_rules do
13
+ BOT_JSON_SOURCE = 'https://raw.githubusercontent.com/opawg/user-agents-v2/master/src/bots.json'
14
+ BOT_JSON = File.expand_path('bots.json', __dir__)
15
+ BOT_YML = File.expand_path('lib/detection_rules_bots.yml', __dir__)
16
+
17
+ def update_bot_json
18
+ clean_json
19
+ uri = URI.parse(BOT_JSON_SOURCE)
20
+ response = Net::HTTP.get_response(uri)
21
+ File.open(BOT_JSON, 'w+') { |f| f.write(response.body) }
22
+ end
23
+
24
+ def clean_json
25
+ File.delete(BOT_JSON) if File.exist?(BOT_JSON)
26
+ end
27
+
28
+ def json_content
29
+ json = File.open(BOT_JSON).read
30
+ content = JSON.parse(json)
31
+ end
32
+
33
+ def generate_entry_yml(entry)
34
+ { 'app' => entry['name'],
35
+ 'match' => { 'regex' => (entry['pattern']) },
36
+ 'platform' => 'bot' }.merge(
37
+ entry_test_value(entry['examples'])
38
+ )
39
+ end
40
+
41
+ def entry_test_value(entry_examples)
42
+ return {} if entry_examples.nil?
43
+
44
+ examples = entry_examples.map do |example|
45
+ { 'userAgent' => example }
46
+ end
47
+
48
+ { 'test' => { 'userAgents' => examples } }
49
+ end
50
+
51
+ def write_yml_file(content)
52
+ File.open(BOT_YML, 'w+') { |f| f.write(content.to_yaml) }
53
+ clean_json
54
+ end
55
+
56
+ update_bot_json
57
+ all_entries = json_content['entries'].map do |entry|
58
+ generate_entry_yml(entry)
59
+ end
60
+ write_yml_file(all_entries)
61
+ end
@@ -53,16 +53,20 @@
53
53
  - app: Apple Podcasts
54
54
  match:
55
55
  includes: watchOS
56
+ excluding:
57
+ regex: '^atc/|\\(null\\) watchOS/'
56
58
  platform:
57
59
  text: watchOS
58
60
  test:
59
61
  userAgents:
60
- - userAgent: '(null)/(null) watchOS/5.0 model/Watch2,3 hwp/t8002 build/16R364 (6; dt:133)'
62
+ - userAgent: 'watchOS/5.0 model/Watch2,3 hwp/t8002 build/16R364 (6; dt:133)'
61
63
  platform: watchOS
62
64
 
63
65
  - app: Spotify
64
66
  match:
65
67
  startsWith: Spotify
68
+ excluding:
69
+ regex: '^Spotify/1\\.0$'
66
70
  platform:
67
71
  regexes:
68
72
  - '(Android|iOS)'
@@ -176,6 +180,8 @@
176
180
  - app: Overcast
177
181
  match:
178
182
  startsWith: Overcast
183
+ excluding:
184
+ regex: '^Overcast/1\\.0 Podcast Sync'
179
185
  platform:
180
186
  text: 'iOS'
181
187
  test:
@@ -429,6 +435,8 @@
429
435
  - app: Podbean
430
436
  match:
431
437
  startsWith: Podbean
438
+ excluding:
439
+ regex: "^Podbean Importer"
432
440
  platform:
433
441
  regex: '(iOS|Android)'
434
442
  test:
@@ -828,6 +836,8 @@
828
836
  - app: Twitter in-app browser
829
837
  match:
830
838
  includes: Twitter
839
+ excluding:
840
+ regex: "^TelegramBot "
831
841
  platform:
832
842
  regex: '(iPhone|iPad|Darwin|Android)'
833
843
  replacements:
@@ -946,6 +956,8 @@
946
956
  - app: Unknown client
947
957
  match:
948
958
  startsWith: '(null)'
959
+ excluding:
960
+ regex: '^atc/|\\(null\\) watchOS/'
949
961
  platform:
950
962
  regex: '(iPhone|iPad|iPod touch)'
951
963
  test:
@@ -966,6 +978,8 @@
966
978
  - app: Flipboard
967
979
  match:
968
980
  includes: Flipboard
981
+ excluding:
982
+ regex: FlipboardProxy/
969
983
  platform:
970
984
  regexes:
971
985
  - '(Android)'
@@ -979,8 +993,6 @@
979
993
  platform: Android
980
994
  - userAgent: Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E304 Flipboard/4.2.20
981
995
  platform: iPad
982
- - userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:49.0) Gecko/20100101 Firefox/49.0 (FlipboardProxy/1.2; +http://flipboard.com/browserproxy)
983
- platform: Mac
984
996
 
985
997
  - app: iVoox
986
998
  match:
@@ -1081,3 +1093,13 @@
1081
1093
  userAgents:
1082
1094
  - userAgent: "sp-agent"
1083
1095
  platform: Android
1096
+
1097
+ - app: RTL+
1098
+ match:
1099
+ startsWith: "RTL+"
1100
+ platform:
1101
+ regex: "(iOS|Android)"
1102
+ test:
1103
+ userAgents:
1104
+ - userAgent: "RTL+/2.8.4.5-live-prod (Linux;Android 12) ExoPlayerLib/2.18.0"
1105
+ platform: Android