minfraud 1.1.0 → 1.2.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 +46 -0
- data/.rubocop.yml +127 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +4 -2
- data/README.md +1 -1
- data/Rakefile +18 -3
- data/bin/console +4 -3
- data/lib/maxmind/geoip2/model/city.rb +3 -3
- data/lib/maxmind/geoip2/model/country.rb +5 -5
- data/lib/maxmind/geoip2/record/traits.rb +1 -1
- data/lib/minfraud.rb +29 -6
- data/lib/minfraud/assessments.rb +6 -2
- data/lib/minfraud/components/account.rb +2 -0
- data/lib/minfraud/components/addressable.rb +9 -7
- data/lib/minfraud/components/base.rb +6 -4
- data/lib/minfraud/components/billing.rb +2 -0
- data/lib/minfraud/components/credit_card.rb +4 -2
- data/lib/minfraud/components/custom_inputs.rb +2 -0
- data/lib/minfraud/components/device.rb +4 -2
- data/lib/minfraud/components/email.rb +2 -0
- data/lib/minfraud/components/event.rb +13 -11
- data/lib/minfraud/components/order.rb +3 -1
- data/lib/minfraud/components/payment.rb +14 -2
- data/lib/minfraud/components/report/transaction.rb +6 -6
- data/lib/minfraud/components/shipping.rb +2 -0
- data/lib/minfraud/components/shopping_cart.rb +4 -1
- data/lib/minfraud/components/shopping_cart_item.rb +2 -2
- data/lib/minfraud/enum.rb +6 -3
- data/lib/minfraud/error_handler.rb +15 -15
- data/lib/minfraud/errors.rb +2 -0
- data/lib/minfraud/http_service.rb +14 -4
- data/lib/minfraud/http_service/request.rb +3 -0
- data/lib/minfraud/http_service/response.rb +4 -2
- data/lib/minfraud/model/address.rb +4 -4
- data/lib/minfraud/model/credit_card.rb +7 -7
- data/lib/minfraud/model/device.rb +2 -2
- data/lib/minfraud/model/email.rb +4 -4
- data/lib/minfraud/model/error.rb +1 -1
- data/lib/minfraud/model/insights.rb +5 -5
- data/lib/minfraud/model/issuer.rb +3 -3
- data/lib/minfraud/model/score.rb +6 -6
- data/lib/minfraud/model/shipping_address.rb +1 -1
- data/lib/minfraud/model/subscores.rb +35 -16
- data/lib/minfraud/model/warning.rb +2 -2
- data/lib/minfraud/report.rb +5 -3
- data/lib/minfraud/resolver.rb +14 -12
- data/lib/minfraud/version.rb +3 -1
- data/minfraud.gemspec +4 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5523cb6babed5c559ba622141b2db65a2396cbb016c6215ec641ba765fc01d10
|
4
|
+
data.tar.gz: 54dbf8b2cc34be45a428da2017f09b7cb2d7445c94ff7f37dda0a26c28a3fbfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80142ac976fb6df365a3192a96dbf62c8ea7935f4ca9fea89333d0e2f2e64f5e4af402dc03814f58f268e354ed7adcb5c61134fb2d526c0a06b48581cad3fc54
|
7
|
+
data.tar.gz: a9b6caf26aaee87f5ebc479391cda46d3489cf591315772c481d722b343399edfc5ad40fca8eac0d740d826c0021bcf33d3aade2419247d26d1787328763599b
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: ruby-versions
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
paths-ignore:
|
5
|
+
- "**.md"
|
6
|
+
pull_request:
|
7
|
+
paths-ignore:
|
8
|
+
- "**.md"
|
9
|
+
jobs:
|
10
|
+
run:
|
11
|
+
name: ruby
|
12
|
+
runs-on: ${{ matrix.os }}
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
17
|
+
version:
|
18
|
+
[
|
19
|
+
"2.2",
|
20
|
+
"2.3",
|
21
|
+
"2.4",
|
22
|
+
"2.5",
|
23
|
+
"2.6",
|
24
|
+
"2.7",
|
25
|
+
"head",
|
26
|
+
"jruby",
|
27
|
+
"jruby-head",
|
28
|
+
]
|
29
|
+
exclude:
|
30
|
+
- os: windows-latest
|
31
|
+
version: "jruby"
|
32
|
+
- os: windows-latest
|
33
|
+
version: "jruby-head"
|
34
|
+
steps:
|
35
|
+
- name: checkout
|
36
|
+
uses: actions/checkout@v2
|
37
|
+
|
38
|
+
- uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: ${{ matrix.version }}
|
41
|
+
- name: ruby version
|
42
|
+
run: ruby -v
|
43
|
+
- run: bundler install
|
44
|
+
name: install
|
45
|
+
- run: bundler exec rake -t
|
46
|
+
name: test
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
Gemspec/RequiredRubyVersion:
|
2
|
+
Enabled: false # We support 1.9, but newer rubocops don't.
|
3
|
+
|
4
|
+
# Metrics.
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Enabled: false # Default is true, but mostly hit in tests.
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Enabled: false # To allow for pre-existing code.
|
11
|
+
|
12
|
+
Metrics/ClassLength:
|
13
|
+
Enabled: false # To allow for pre-existing code.
|
14
|
+
|
15
|
+
Metrics/CyclomaticComplexity:
|
16
|
+
Enabled: false # To allow for pre-existing code.
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: false # To allow for pre-existing code.
|
20
|
+
|
21
|
+
Metrics/PerceivedComplexity:
|
22
|
+
Enabled: false # To allow for pre-existing code.
|
23
|
+
|
24
|
+
# Layout.
|
25
|
+
|
26
|
+
Layout/LineLength:
|
27
|
+
Max: 150 # Default is 120.
|
28
|
+
|
29
|
+
Layout/HashAlignment:
|
30
|
+
EnforcedHashRocketStyle: table # Default is key.
|
31
|
+
EnforcedColonStyle: table # Default is key.
|
32
|
+
|
33
|
+
Layout/ExtraSpacing:
|
34
|
+
ForceEqualSignAlignment: true # Default is false.
|
35
|
+
|
36
|
+
Layout/IndentationStyle:
|
37
|
+
IndentationWidth: 2 # Default is <none>.
|
38
|
+
|
39
|
+
# Style.
|
40
|
+
|
41
|
+
Style/HashSyntax:
|
42
|
+
EnforcedStyle: ruby19_no_mixed_keys # Default is ruby19.
|
43
|
+
|
44
|
+
Style/CollectionMethods:
|
45
|
+
Enabled: true # Default is false.
|
46
|
+
|
47
|
+
Style/NumericLiterals:
|
48
|
+
MinDigits: 4 # Default is 5.
|
49
|
+
|
50
|
+
Style/NegatedIf: # I disagree with this.
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/IfUnlessModifier: # This doesn't always make sense.
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/SymbolArray:
|
57
|
+
EnforcedStyle: brackets # Default is percent, but 1.9 doesn't support that.
|
58
|
+
|
59
|
+
# Trailing commas are often good.
|
60
|
+
Style/TrailingCommaInArguments:
|
61
|
+
Enabled: false
|
62
|
+
Style/TrailingCommaInArrayLiteral:
|
63
|
+
Enabled: false
|
64
|
+
Style/TrailingCommaInHashLiteral:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/SafeNavigation:
|
68
|
+
Enabled: false # Default is true, but this 1.9 doesn't support it.
|
69
|
+
|
70
|
+
# Default is both which is probably fine, but it changes code and I don't want
|
71
|
+
# to investigate any possible behavior change right now.
|
72
|
+
Style/EmptyElse:
|
73
|
+
EnforcedStyle: empty
|
74
|
+
|
75
|
+
Style/ConditionalAssignment:
|
76
|
+
Enabled: false # This produces kind of strange results.
|
77
|
+
|
78
|
+
Style/Dir:
|
79
|
+
Enabled: false # This is good, but not supported on 1.9.
|
80
|
+
|
81
|
+
Style/ExpandPathArguments:
|
82
|
+
Enabled: false # This causes us to use __dir__ which 1.9 doesn't support.
|
83
|
+
|
84
|
+
Style/GuardClause:
|
85
|
+
Enabled: false # Doesn't always make sense.
|
86
|
+
|
87
|
+
Style/Documentation:
|
88
|
+
Enabled: false # We should enable this, but allow for pre-existing code.
|
89
|
+
|
90
|
+
Style/FormatStringToken:
|
91
|
+
Enabled: false # Seems unnecessary.
|
92
|
+
|
93
|
+
# Naming.
|
94
|
+
|
95
|
+
Naming/VariableNumber:
|
96
|
+
Enabled: false # Doesn't always make sense.
|
97
|
+
|
98
|
+
# These are new and rubocop warns if you don't configure them.
|
99
|
+
|
100
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
101
|
+
Enabled: true
|
102
|
+
Layout/SpaceAroundMethodCallOperator:
|
103
|
+
Enabled: true
|
104
|
+
Lint/DeprecatedOpenSSLConstant:
|
105
|
+
Enabled: true
|
106
|
+
Lint/MixedRegexpCaptureTypes:
|
107
|
+
Enabled: true
|
108
|
+
Lint/RaiseException:
|
109
|
+
Enabled: true
|
110
|
+
Lint/StructNewOverride:
|
111
|
+
Enabled: true
|
112
|
+
Style/ExponentialNotation:
|
113
|
+
Enabled: true
|
114
|
+
Style/HashEachMethods:
|
115
|
+
Enabled: true
|
116
|
+
Style/HashTransformKeys:
|
117
|
+
Enabled: true
|
118
|
+
Style/HashTransformValues:
|
119
|
+
Enabled: true
|
120
|
+
Style/RedundantFetchBlock:
|
121
|
+
Enabled: true
|
122
|
+
Style/RedundantRegexpCharacterClass:
|
123
|
+
Enabled: true
|
124
|
+
Style/RedundantRegexpEscape:
|
125
|
+
Enabled: true
|
126
|
+
Style/SlicingWithRange:
|
127
|
+
Enabled: true
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Minfraud Changelog
|
2
2
|
|
3
|
+
## v1.2.0 (2020-07-15)
|
4
|
+
|
5
|
+
* Adds new processor types to `Minfraud::Components::Payment`: `:cashfree`,
|
6
|
+
`:first_atlantic_commerce`, `:komoju`, `:paytm`, `:razorpay`, and
|
7
|
+
`:systempay`.
|
8
|
+
* Adds support for three new Factors outputs: `/subscores/device` (the risk
|
9
|
+
associated with the device), `/subscores/email_local_part` (the risk
|
10
|
+
associated with the part of the email address before the @ symbol) and
|
11
|
+
`/subscores/shipping_address` (the risk associated with the shipping
|
12
|
+
address).
|
13
|
+
* Adds support for providing your MaxMind account ID using the `account_id`
|
14
|
+
attribute instead of the `user_id` attribute. In a future release,
|
15
|
+
support for the `user_id` attribute will be removed.
|
16
|
+
|
3
17
|
## v1.1.0 (2020-06-19)
|
4
18
|
|
5
19
|
* Adds support for the minFraud Report Transaction API. Reporting
|
data/Gemfile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# coveralls fails on Ruby 1.9. My understanding is we don't need to run this on
|
4
6
|
# more than one version anyway, so restrict to the current latest.
|
5
7
|
version_pieces = RUBY_VERSION.split('.')
|
6
|
-
major_version
|
7
|
-
minor_version
|
8
|
+
major_version = version_pieces[0]
|
9
|
+
minor_version = version_pieces[1]
|
8
10
|
if major_version == '2' && minor_version == '7'
|
9
11
|
gem 'coveralls', require: false
|
10
12
|
end
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
3
6
|
|
4
7
|
RSpec::Core::RakeTask.new(:spec)
|
5
8
|
|
6
|
-
|
9
|
+
RuboCop::RakeTask.new
|
10
|
+
|
11
|
+
task default: :spec
|
12
|
+
|
13
|
+
# The current version of rubocop supports Ruby 2.4+. While we could run its
|
14
|
+
# older versions, the config isn't backwards compatible. Let's run it only for
|
15
|
+
# 2.4+. This isn't perfect, but as long as 1.9+ tests pass we should be okay.
|
16
|
+
version_pieces = RUBY_VERSION.split('.')
|
17
|
+
major_version = version_pieces[0]
|
18
|
+
minor_version = version_pieces[1]
|
19
|
+
if major_version == '2' && minor_version.to_i >= 4
|
20
|
+
task default: :rubocop
|
21
|
+
end
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'minfraud'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "minfraud"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -68,9 +68,9 @@ module MaxMind
|
|
68
68
|
# @!visibility private
|
69
69
|
def initialize(record, locales)
|
70
70
|
super(record, locales)
|
71
|
-
@city
|
72
|
-
@location
|
73
|
-
@postal
|
71
|
+
@city = MaxMind::GeoIP2::Record::City.new(record['city'], locales)
|
72
|
+
@location = MaxMind::GeoIP2::Record::Location.new(record['location'])
|
73
|
+
@postal = MaxMind::GeoIP2::Record::Postal.new(record['postal'])
|
74
74
|
@subdivisions = create_subdivisions(record['subdivisions'], locales)
|
75
75
|
end
|
76
76
|
|
@@ -69,16 +69,16 @@ module MaxMind
|
|
69
69
|
|
70
70
|
# @!visibility private
|
71
71
|
def initialize(record, locales)
|
72
|
-
@continent
|
72
|
+
@continent = MaxMind::GeoIP2::Record::Continent.new(
|
73
73
|
record['continent'],
|
74
74
|
locales,
|
75
75
|
)
|
76
|
-
@country
|
76
|
+
@country = MaxMind::GeoIP2::Record::Country.new(
|
77
77
|
record['country'],
|
78
78
|
locales,
|
79
79
|
)
|
80
|
-
@maxmind
|
81
|
-
@registered_country
|
80
|
+
@maxmind = MaxMind::GeoIP2::Record::MaxMind.new(record['maxmind'])
|
81
|
+
@registered_country = MaxMind::GeoIP2::Record::Country.new(
|
82
82
|
record['registered_country'],
|
83
83
|
locales,
|
84
84
|
)
|
@@ -86,7 +86,7 @@ module MaxMind
|
|
86
86
|
record['represented_country'],
|
87
87
|
locales,
|
88
88
|
)
|
89
|
-
@traits
|
89
|
+
@traits = MaxMind::GeoIP2::Record::Traits.new(record['traits'])
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
@@ -35,7 +35,7 @@ module MaxMind
|
|
35
35
|
super(record)
|
36
36
|
if !record.key?('network') && record.key?('ip_address') &&
|
37
37
|
record.key?('prefix_length')
|
38
|
-
ip
|
38
|
+
ip = IPAddr.new(record['ip_address']).mask(record['prefix_length'])
|
39
39
|
# We could use ip.prefix instead of record['prefix_length'], but that
|
40
40
|
# method only becomes available in Ruby 2.5+.
|
41
41
|
record['network'] = format('%s/%d', ip.to_s, record['prefix_length'])
|
data/lib/minfraud.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'minfraud'
|
2
4
|
require 'minfraud/enum'
|
3
5
|
require 'minfraud/components/base'
|
@@ -27,20 +29,41 @@ require 'minfraud/report'
|
|
27
29
|
|
28
30
|
module Minfraud
|
29
31
|
class << self
|
30
|
-
#
|
31
|
-
#
|
32
|
+
# The MaxMind account ID that is used for authorization.
|
33
|
+
#
|
34
|
+
# @return [Integer, nil]
|
35
|
+
attr_accessor :account_id
|
36
|
+
|
37
|
+
# The host to use when connecting to the web service.
|
38
|
+
#
|
39
|
+
# @return [String, nil]
|
40
|
+
attr_accessor :host
|
41
|
+
|
42
|
+
# The MaxMind account ID that is used for authorization.
|
43
|
+
#
|
44
|
+
# @deprecated Use {::account_id} instead. This will be removed in the next
|
45
|
+
# major version.
|
46
|
+
#
|
47
|
+
# @return [Integer, nil]
|
32
48
|
attr_accessor :user_id
|
33
49
|
|
34
|
-
#
|
35
|
-
#
|
50
|
+
# The MaxMind license key that is used for authorization.
|
51
|
+
#
|
52
|
+
# @return [String, nil]
|
36
53
|
attr_accessor :license_key
|
37
54
|
|
38
|
-
#
|
55
|
+
# Yield self to accept configuration settings.
|
56
|
+
#
|
57
|
+
# @yield [self]
|
39
58
|
def configure
|
40
59
|
yield self
|
41
60
|
end
|
42
61
|
|
43
|
-
#
|
62
|
+
# The current Minfraud configuration.
|
63
|
+
#
|
64
|
+
# @deprecated This will be removed in the next major version.
|
65
|
+
#
|
66
|
+
# @return [Hash]
|
44
67
|
def configuration
|
45
68
|
{
|
46
69
|
user_id: @user_id,
|
data/lib/minfraud/assessments.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
class Assessments
|
3
5
|
include ::Minfraud::HTTPService
|
@@ -83,11 +85,13 @@ module Minfraud
|
|
83
85
|
define :factors
|
84
86
|
|
85
87
|
private
|
88
|
+
|
86
89
|
# Creates a unified request body from components converted to JSON
|
87
90
|
# @return [Hash] Request body
|
88
91
|
def request_body
|
89
|
-
MAPPING.keys.
|
90
|
-
next mem unless value = send(e)
|
92
|
+
MAPPING.keys.reduce({}) do |mem, e|
|
93
|
+
next mem unless (value = send(e))
|
94
|
+
|
91
95
|
mem.merge!(e.to_s => value.to_json)
|
92
96
|
end
|
93
97
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
3
5
|
class Addressable < Base
|
@@ -14,11 +16,11 @@ module Minfraud
|
|
14
16
|
attr_accessor :company
|
15
17
|
|
16
18
|
# @attribute address
|
17
|
-
# @return [String] The first line of the user
|
19
|
+
# @return [String] The first line of the user's billing / shipping address
|
18
20
|
attr_accessor :address
|
19
21
|
|
20
22
|
# @attribute address_2
|
21
|
-
# @return [String] The second line of the user
|
23
|
+
# @return [String] The second line of the user's billing / shipping address
|
22
24
|
attr_accessor :address_2
|
23
25
|
|
24
26
|
# @attribute city
|
@@ -26,23 +28,23 @@ module Minfraud
|
|
26
28
|
attr_accessor :city
|
27
29
|
|
28
30
|
# @attribute region
|
29
|
-
# @return [String] The ISO 3166-2 subdivision code for the user
|
31
|
+
# @return [String] The ISO 3166-2 subdivision code for the user's billing / shipping address
|
30
32
|
attr_accessor :region
|
31
33
|
|
32
34
|
# @attribute country
|
33
|
-
# @return [String] The two character ISO 3166-1 alpha-2 country code of the user
|
35
|
+
# @return [String] The two character ISO 3166-1 alpha-2 country code of the user's billing / shipping address
|
34
36
|
attr_accessor :country
|
35
37
|
|
36
38
|
# @attribute postal
|
37
|
-
# @return [String] The postal code of the user
|
39
|
+
# @return [String] The postal code of the user's billing / shipping address
|
38
40
|
attr_accessor :postal
|
39
41
|
|
40
42
|
# @attribute phone_number
|
41
|
-
# @return [String] The phone number without the country code for the user
|
43
|
+
# @return [String] The phone number without the country code for the user's billing / shipping address
|
42
44
|
attr_accessor :phone_number
|
43
45
|
|
44
46
|
# @attribute phone_country_code
|
45
|
-
# @return [String] The country code for phone number associated with the user
|
47
|
+
# @return [String] The country code for phone number associated with the user's billing / shipping address
|
46
48
|
attr_accessor :phone_country_code
|
47
49
|
|
48
50
|
# Creates Minfraud::Components::Addressable instance
|