browser_sniffer 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +35 -0
- data/README.md +1 -1
- data/browser_sniffer.gemspec +1 -1
- data/lib/browser_sniffer/patterns.rb +13 -1
- data/lib/browser_sniffer/version.rb +1 -1
- data/test/shopify_agents_test.rb +118 -20
- metadata +4 -4
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a77c63b7563c544ce8ca42c0025fb9bad4dffe07be91652510f78d8e95c1c77
|
4
|
+
data.tar.gz: dd49278682198e0563dcd22171fdaa7fa5a2f7364e3c0e5bd52dad6c2fd68b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab86e531c4cebcd5d6a5537e6a41cba81865b875f588d0d44296f89773321b935d9026ef5e3e2d05f1b30ae2082a603f6899b0b72e2eb3cf566141466ba347b7
|
7
|
+
data.tar.gz: 35fc400e3501ff5ed0f3682c914c80221c7c9c83a02f3f924792edf0eed98c8e32708c3b44658afbf68fe71577624e4a916d025e6a7ccca646c7f6d8ef6012af
|
@@ -0,0 +1,35 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches: master
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
test:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
name: Ruby ${{ matrix.version }}
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
version:
|
16
|
+
- 2.0
|
17
|
+
- 2.1
|
18
|
+
- 2.2
|
19
|
+
- 2.3
|
20
|
+
- 2.4
|
21
|
+
- 2.5
|
22
|
+
- 2.6
|
23
|
+
- 2.7
|
24
|
+
- 3.0
|
25
|
+
- 3.1
|
26
|
+
- jruby
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby ${{ matrix.version }}
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
bundler-cache: true
|
33
|
+
ruby-version: ${{ matrix.version }}
|
34
|
+
- name: Run Tests
|
35
|
+
run: bundle exec rake test
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
[![Build Status](https://
|
1
|
+
[![Build Status](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/Shopify/browser_sniffer/actions/workflows/test.yml)
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/browser_sniffer.png)](http://badge.fury.io/rb/browser_sniffer)
|
3
3
|
|
4
4
|
# BrowserSniffer
|
data/browser_sniffer.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.required_ruby_version = ">=
|
18
|
+
spec.required_ruby_version = ">= 2.0.0"
|
19
19
|
|
20
20
|
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
21
21
|
|
@@ -60,8 +60,11 @@ class BrowserSniffer
|
|
60
60
|
# Shopify POS for Android (Native App)
|
61
61
|
%r{.*(\sPOS\s-).*\s([\d+\.]+)(\/\d*)*\s}i,
|
62
62
|
], [[:name, 'Shopify POS'], :version], [
|
63
|
-
# Shopify POS for Android (Native App)
|
63
|
+
# Shopify POS for Android (React Native App)
|
64
64
|
%r{(Shopify POS)\/([\d\.]+)[^\/]*\/(Android)\/(\d+)}i,
|
65
|
+
], [[:name, 'Shopify POS'], :version], [
|
66
|
+
# Shopify POS for iOS (React Native App)
|
67
|
+
%r{(Shopify POS)\/([\d\.]+)[^\/]*\/(iOS)\/([\d\.]+)}i,
|
65
68
|
], [[:name, 'Shopify POS'], :version], [
|
66
69
|
# Shopify POS for Android (SmartWebView)
|
67
70
|
%r{.*(Shopify\sPOS)\s.*Android.*\s([\d+\.]+)(\/\d*)*\s}i,
|
@@ -174,6 +177,12 @@ class BrowserSniffer
|
|
174
177
|
# Shopify POS Next for iPod touch
|
175
178
|
%r{.*(?:Shopify POS Next|Shopify POS)/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPod)([\d,]+)}i
|
176
179
|
], [[:type, :handheld], :model], [
|
180
|
+
# Shopify POS for iOS iPhone/iPod (React Native App)
|
181
|
+
%r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/[\d\.]+\/Apple\/((iPhone|iPod)[^\/]*)\/}i,
|
182
|
+
], [[:type, :handheld], :model], [
|
183
|
+
# Shopify POS for iOS iPad (React Native App)
|
184
|
+
%r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/[\d\.]+\/Apple\/(iPad[^\/]*)\/}i,
|
185
|
+
], [[:type, :tablet], :model], [
|
177
186
|
# Shopify Ping for iPhone
|
178
187
|
%r{.*Shopify Ping/(?:iPhone\sOS|iOS)/[\d\.]+ \((iPhone)([\d,]+)}i
|
179
188
|
], [[:type, :handheld], :model], [
|
@@ -297,6 +306,9 @@ class BrowserSniffer
|
|
297
306
|
# Shopify POS Next for iPhone or iPad
|
298
307
|
%r{.*(Shopify POS Next|Shopify POS)\/(?:iPhone\sOS|iOS)[\/\d\.]* \((iPhone|iPad|iPod).*\/([\d\.]+)\)}i
|
299
308
|
], [[:type, :ios], [:name, 'iOS'], :version], [
|
309
|
+
# Shopify POS for iOS (React Native App)
|
310
|
+
%r{.*Shopify POS\/[\d\.]+[^\/]*\/(iOS)\/([\d\.]+)\/(Apple)\/(iPhone|iPad|iPod)[^\/]*\/}i
|
311
|
+
], [[:type, :ios], :version, [:name, 'iOS']], [
|
300
312
|
# Shopify Ping for iOS
|
301
313
|
%r{.*Shopify Ping\/(iOS)\/[\d\.]+ \(.*\/([\d\.]+)\)}i
|
302
314
|
], [[:type, :ios], :version, [:name, 'iOS']], [
|
data/test/shopify_agents_test.rb
CHANGED
@@ -554,7 +554,7 @@ describe "Shopify agents" do
|
|
554
554
|
assert_equal sniffer.os_info, sniffer_with_suffix.os_info
|
555
555
|
end
|
556
556
|
|
557
|
-
it "Shopify POS on Android can be sniffed (Native App)
|
557
|
+
it "Shopify POS on Android can be sniffed (React Native App)" do
|
558
558
|
user_agent = "com.jadedpixel.pos Shopify POS/4.23.0/Android/12/google/Pixel 5/production MobileMiddlewareSupported"
|
559
559
|
sniffer = BrowserSniffer.new(user_agent)
|
560
560
|
|
@@ -582,6 +582,69 @@ describe "Shopify agents" do
|
|
582
582
|
assert_equal sniffer.os_info, sniffer_with_suffix.os_info
|
583
583
|
end
|
584
584
|
|
585
|
+
it "Shopify POS on iPhone can be sniffed (React Native App)" do
|
586
|
+
user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPhone 11/production"
|
587
|
+
sniffer = BrowserSniffer.new(user_agent)
|
588
|
+
|
589
|
+
assert_equal ({
|
590
|
+
name: 'Shopify POS',
|
591
|
+
version: '7.0.0',
|
592
|
+
}), sniffer.browser_info
|
593
|
+
|
594
|
+
assert_equal ({
|
595
|
+
type: :handheld,
|
596
|
+
model: 'iPhone 11',
|
597
|
+
}), sniffer.device_info
|
598
|
+
|
599
|
+
assert_equal ({
|
600
|
+
type: :ios,
|
601
|
+
version: '15.4',
|
602
|
+
name: 'iOS',
|
603
|
+
}), sniffer.os_info
|
604
|
+
end
|
605
|
+
|
606
|
+
it "Shopify POS on iPad can be sniffed (React Native App)" do
|
607
|
+
user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPad/production"
|
608
|
+
sniffer = BrowserSniffer.new(user_agent)
|
609
|
+
|
610
|
+
assert_equal ({
|
611
|
+
name: 'Shopify POS',
|
612
|
+
version: '7.0.0',
|
613
|
+
}), sniffer.browser_info
|
614
|
+
|
615
|
+
assert_equal ({
|
616
|
+
type: :tablet,
|
617
|
+
model: 'iPad',
|
618
|
+
}), sniffer.device_info
|
619
|
+
|
620
|
+
assert_equal ({
|
621
|
+
type: :ios,
|
622
|
+
version: '15.4',
|
623
|
+
name: 'iOS',
|
624
|
+
}), sniffer.os_info
|
625
|
+
end
|
626
|
+
|
627
|
+
it "Shopify POS on iPod Touch can be sniffed (React Native App)" do
|
628
|
+
user_agent = "com.jadedpixel.pos Shopify POS/7.0.0/iOS/15.4/Apple/iPod Touch/production"
|
629
|
+
sniffer = BrowserSniffer.new(user_agent)
|
630
|
+
|
631
|
+
assert_equal ({
|
632
|
+
name: 'Shopify POS',
|
633
|
+
version: '7.0.0',
|
634
|
+
}), sniffer.browser_info
|
635
|
+
|
636
|
+
assert_equal ({
|
637
|
+
type: :handheld,
|
638
|
+
model: 'iPod Touch',
|
639
|
+
}), sniffer.device_info
|
640
|
+
|
641
|
+
assert_equal ({
|
642
|
+
type: :ios,
|
643
|
+
version: '15.4',
|
644
|
+
name: 'iOS',
|
645
|
+
}), sniffer.os_info
|
646
|
+
end
|
647
|
+
|
585
648
|
it "Shopify Mobile in debug mode can be parsed" do
|
586
649
|
user_agent = "Shopify Mobile/Android/6.0.0 (debug) (Build 1 with API 25 on Unknown Android SDK built for x86)"
|
587
650
|
sniffer = BrowserSniffer.new(user_agent)
|
@@ -708,33 +771,68 @@ describe "Shopify agents" do
|
|
708
771
|
}), sniffer.os_info
|
709
772
|
end
|
710
773
|
|
711
|
-
INCOMPATIBLE_USER_AGENTS =
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
"Mozilla/5.0 (
|
717
|
-
|
718
|
-
|
774
|
+
INCOMPATIBLE_USER_AGENTS = {
|
775
|
+
'missing' => nil,
|
776
|
+
|
777
|
+
# Safari on iOS 12 is broken
|
778
|
+
'iOS 12.0' => "Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) GSA/87.0.279142407 Mobile/15E148 Safari/605.1",
|
779
|
+
'iOS 12.2' => "Mozilla/5.0 (iPhone; CPU iPhone OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1 Mobile/15E148 Safari/604.1",
|
780
|
+
|
781
|
+
# Safari on MacOS 14 is broken
|
782
|
+
'MacOS 10.14 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Safari/605.1.15",
|
783
|
+
'MacOS 10.14 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko)",
|
784
|
+
|
785
|
+
# UC Browser versions before 12.13.2 are broken
|
786
|
+
'UC Browser 11.3.8' => "Mozilla/5.0 (Linux; U; Android 7.0; en-US; SM-G935F Build/NRD90M) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.3.8.976 U3/0.8.0 Mobile Safari/534.30",
|
787
|
+
'UC Browser 12.13.0' => "Mozilla/5.0 (Linux; U; Android 8.0.0; en-US; moto g⁶ play Build/OPP27.91-88) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.13.0.1207 Mobile Safari/537.36",
|
719
788
|
|
720
|
-
|
721
|
-
|
789
|
+
# Chrome and Chromium versions between 51 and 66 inclusive are broken
|
790
|
+
'Chrome 51' => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
|
791
|
+
'Chrome 66' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36",
|
792
|
+
|
793
|
+
'Chromium 51' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36",
|
794
|
+
'Chromium 66' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/66.0.3359.181 Chrome/66.0.3359.181 Safari/537.36",
|
795
|
+
}
|
796
|
+
|
797
|
+
INCOMPATIBLE_USER_AGENTS.each do |label, user_agent|
|
798
|
+
it "#{label} user agent is correctly marked as incompatible" do
|
722
799
|
sniffer = BrowserSniffer.new(user_agent)
|
723
800
|
|
724
801
|
refute sniffer.same_site_none_compatible?
|
725
802
|
end
|
726
803
|
end
|
727
804
|
|
728
|
-
COMPATIBLE_USER_AGENTS =
|
729
|
-
"Mozilla/5.0 (
|
730
|
-
|
731
|
-
"Mozilla/5.0 (Macintosh; Intel Mac OS X
|
732
|
-
|
733
|
-
|
734
|
-
|
805
|
+
COMPATIBLE_USER_AGENTS = {
|
806
|
+
'iOS 13' => "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1",
|
807
|
+
|
808
|
+
'MacOS 10.13 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6",
|
809
|
+
|
810
|
+
'MacOS 10.14 Chrome' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36",
|
811
|
+
|
812
|
+
'MacOS 10.15 Safari' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15",
|
813
|
+
|
814
|
+
'MacOS 10.15 Firefox' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0",
|
815
|
+
|
816
|
+
'UC Browser 13.3.8' => "Mozilla/5.0 (Linux; U; Android 11; en-US; SM-A715F Build/RP1A.200720.012) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/78.0.3904.108 UCBrowser/13.3.8.1305 Mobile Safari/537.36",
|
817
|
+
|
818
|
+
'Chrome 50' => "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36",
|
819
|
+
'Chrome 67' => "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36",
|
820
|
+
|
821
|
+
'Chromium 50' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36",
|
822
|
+
'Chromium 67' => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67.0.3396.99 Safari/537.36",
|
823
|
+
|
824
|
+
# False negative: library doesn't recognise WebKit user agents that aren't Safari or Chrome
|
825
|
+
# (These may be e.g. Webkit nightly builds)
|
826
|
+
# 'MacOS 10.13 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)",
|
827
|
+
# 'MacOS 10.15 WebKit' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko)",
|
828
|
+
|
829
|
+
# False negative: library explicitly treats iOS 11 Safari as incompatible while reference code does not:
|
830
|
+
# https://www.chromium.org/updates/same-site/incompatible-clients
|
831
|
+
# 'iOS 11' => "Mozilla/5.0 (iPhone; CPU iPhone OS 11_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.0 Mobile/15E148 Safari/604.1",
|
832
|
+
}
|
735
833
|
|
736
|
-
COMPATIBLE_USER_AGENTS.each do |user_agent|
|
737
|
-
it "user agent
|
834
|
+
COMPATIBLE_USER_AGENTS.each do |label, user_agent|
|
835
|
+
it "#{label} user agent is correctly marked as compatible" do
|
738
836
|
sniffer = BrowserSniffer.new(user_agent)
|
739
837
|
|
740
838
|
assert sniffer.same_site_none_compatible?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: browser_sniffer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -60,8 +60,8 @@ extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
62
|
- ".github/probots.yml"
|
63
|
+
- ".github/workflows/test.yml"
|
63
64
|
- ".gitignore"
|
64
|
-
- ".travis.yml"
|
65
65
|
- Gemfile
|
66
66
|
- LICENSE.txt
|
67
67
|
- README.md
|
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
92
|
+
version: 2.0.0
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ">="
|