prevoty 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +8 -0
- data/lib/prevoty.rb +31 -0
- data/lib/prevoty/client.rb +341 -0
- data/lib/prevoty/crypto.rb +33 -0
- data/lib/prevoty/exceptions/account_quota_exceeded.rb +4 -0
- data/lib/prevoty/exceptions/bad_api_key.rb +4 -0
- data/lib/prevoty/exceptions/bad_input_parameter.rb +4 -0
- data/lib/prevoty/exceptions/internal_error.rb +4 -0
- data/lib/prevoty/hash.rb +12 -0
- data/lib/prevoty/pattern.rb +18 -0
- data/lib/prevoty/responses/api_key_info.rb +12 -0
- data/lib/prevoty/responses/decrypt_result.rb +9 -0
- data/lib/prevoty/responses/delete_token.rb +10 -0
- data/lib/prevoty/responses/ecdsa_private_key.rb +19 -0
- data/lib/prevoty/responses/ecdsa_public_key.rb +19 -0
- data/lib/prevoty/responses/ecdsa_signature.rb +17 -0
- data/lib/prevoty/responses/encrypt_result.rb +25 -0
- data/lib/prevoty/responses/filter_content.rb +11 -0
- data/lib/prevoty/responses/filter_statistics.rb +28 -0
- data/lib/prevoty/responses/generate_token.rb +10 -0
- data/lib/prevoty/responses/hash_result.rb +9 -0
- data/lib/prevoty/responses/input_validation.rb +10 -0
- data/lib/prevoty/responses/query_analysis.rb +87 -0
- data/lib/prevoty/responses/rsa_private_key.rb +22 -0
- data/lib/prevoty/responses/rsa_public_key.rb +17 -0
- data/lib/prevoty/responses/rsa_signature.rb +15 -0
- data/lib/prevoty/responses/signature_verify.rb +13 -0
- data/lib/prevoty/responses/validate_token.rb +10 -0
- data/lib/prevoty/version.rb +3 -0
- data/prevoty.gemspec +25 -0
- data/test/specs/client_spec.rb +563 -0
- data/test/test_helper.rb +10 -0
- metadata +124 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module Prevoty
|
2
|
+
module Crypto
|
3
|
+
module Algorithms
|
4
|
+
AES = 1
|
5
|
+
TriDES = 2
|
6
|
+
end
|
7
|
+
|
8
|
+
module Modes
|
9
|
+
CBC = 1
|
10
|
+
CFB = 2
|
11
|
+
CTR = 3
|
12
|
+
OFB = 4
|
13
|
+
end
|
14
|
+
|
15
|
+
module KeyAlgorithms
|
16
|
+
RSA_PKCS = 1
|
17
|
+
RSA_PSS = 2
|
18
|
+
ECDSA = 3
|
19
|
+
end
|
20
|
+
|
21
|
+
module Curves
|
22
|
+
P224 = 1
|
23
|
+
P256 = 2
|
24
|
+
P384 = 3
|
25
|
+
P521 = 4
|
26
|
+
end
|
27
|
+
|
28
|
+
module PSSSaltOptions
|
29
|
+
PSSSaltLengthAuto = 1
|
30
|
+
PSSSaltLengthEqualsHash = -1
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/prevoty/hash.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Prevoty
|
2
|
+
module Pattern
|
3
|
+
ALPHA = 'alpha'
|
4
|
+
ALPHANUMERIC = 'alphanumeric'
|
5
|
+
BASE64 = 'base64'
|
6
|
+
CREDITCARD = 'creditcard'
|
7
|
+
EMAIL = 'email'
|
8
|
+
IP = 'ip'
|
9
|
+
IPV6 = 'ipv6'
|
10
|
+
MAC = 'mac'
|
11
|
+
NUMERIC = 'numeric'
|
12
|
+
URL = 'url'
|
13
|
+
UUID = 'uuid'
|
14
|
+
UUID3 = 'uuid3'
|
15
|
+
UUID4 = 'uuid4'
|
16
|
+
UUID5 = 'uuid5'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class ECDSAPrivateKey < ECDSAPublicKey
|
3
|
+
attr_accessor :d
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
super(data)
|
7
|
+
@d = data["d"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_json(*a)
|
11
|
+
{
|
12
|
+
x: @x,
|
13
|
+
y: @y,
|
14
|
+
curve_id: @curve_id,
|
15
|
+
d: @d
|
16
|
+
}.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class ECDSAPublicKey
|
3
|
+
attr_accessor :x, :y, :curve_id
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@x = data["x"]
|
7
|
+
@y = data["y"]
|
8
|
+
@curve_id = data["curve_id"]
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_json(*a)
|
12
|
+
{
|
13
|
+
x: @x,
|
14
|
+
y: @y,
|
15
|
+
curve_id: @curve_id
|
16
|
+
}.to_json
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class EncryptResult
|
3
|
+
attr_accessor :algorithm, :mode, :mac_key, :key, :mac, :cipher_text
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@algorithm = data["algorithm"]
|
7
|
+
@mode = data["mode"]
|
8
|
+
@mac_key = data["mac_key"]
|
9
|
+
@key = data["key"]
|
10
|
+
@mac = data["mac"]
|
11
|
+
@cipher_text = data["cipher_text"]
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_json(*a)
|
15
|
+
{
|
16
|
+
algorithm: @algorithm,
|
17
|
+
mode: @mode,
|
18
|
+
mac_key: @mac_key,
|
19
|
+
key: @key,
|
20
|
+
mac: @mac,
|
21
|
+
cipher_text: @cipher_text
|
22
|
+
}.to_json
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class FilterStatistics
|
3
|
+
attr_accessor :bytes,
|
4
|
+
:invalid_attributes, :invalid_protocols, :invalid_tags,
|
5
|
+
:blacklisted_phrases, :flagged_phrases,
|
6
|
+
:javascript_attributes, :javascript_protocols, :javascript_tags,
|
7
|
+
:prevoty_profanity_features, :prevoty_spam_features,
|
8
|
+
:prevoty_link_metadata, :prevoty_link_density,
|
9
|
+
:tags_balanced, :transformations
|
10
|
+
def initialize(data)
|
11
|
+
@bytes = data["bytes"]
|
12
|
+
@invalid_attributes = data["invalid_attributes"]
|
13
|
+
@invalid_protocols = data["invalid_protocols"]
|
14
|
+
@invalid_tags = data["invalid_tags"]
|
15
|
+
@blacklisted_phrases = data["blacklisted_phrases"]
|
16
|
+
@flagged_phrases = data["flagged_phrases"]
|
17
|
+
@javascript_attributes = data["javascript_attributes"]
|
18
|
+
@javascript_protocols = data["javascript_protocols"]
|
19
|
+
@javascript_tags = data["javascript_tags"]
|
20
|
+
@prevoty_profanity_features = data["prevoty_profanity_features"]
|
21
|
+
@prevoty_spam_features = data["prevoty_spam_features"]
|
22
|
+
@prevoty_link_metadata = data["prevoty_link_metadata"]
|
23
|
+
@prevoty_link_density = data["prevoty_link_density"]
|
24
|
+
@tags_balanced = data["tags_balanced"]
|
25
|
+
@transformations = data["transformations"]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class QueryAnalysis
|
3
|
+
attr_accessor :version, :processed, :compliant, :statements, :error
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
@version = data["version"]
|
7
|
+
@processed = data["processed"]
|
8
|
+
@compliant = data["compliant"]
|
9
|
+
@statements = data["statements"].map {|statement| Statement.new(statement)}
|
10
|
+
@error = data["error"]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Statement
|
15
|
+
attr_accessor :intelligence, :violations
|
16
|
+
|
17
|
+
def initialize(data)
|
18
|
+
@intelligence = Intelligence.new(data["intelligence"])
|
19
|
+
@violations = Violations.new(data["violations"])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Intelligence
|
24
|
+
attr_accessor :statement_type, :row_creates, :column_reads, :column_updates,
|
25
|
+
:row_deletes, :has_admin, :function_calls, :joins, :unions,
|
26
|
+
:subqueries
|
27
|
+
|
28
|
+
def initialize(data)
|
29
|
+
@statement_type = data["statement_type"]
|
30
|
+
@row_creates = data["row_creates"].map {|el| Table.new(el)}
|
31
|
+
@column_reads = data["column_reads"].map {|el| Column.new(el)}
|
32
|
+
@column_updates = data["column_updates"].map {|el| Column.new(el)}
|
33
|
+
@row_deletes = data["row_deletes"].map {|el| Table.new(el)}
|
34
|
+
@has_admin = data["has_admin"]
|
35
|
+
@function_calls = data["function_calls"].map {|el| FunctionCall.new(el)}
|
36
|
+
@joins = data["joins"].map {|el| Table.new(el)}
|
37
|
+
@unions = data["unions"].map {|el| Table.new(el)}
|
38
|
+
@subqueries = data["subqueries"].map {|el| Table.new(el)}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
class Table
|
43
|
+
attr_accessor :database, :table
|
44
|
+
|
45
|
+
def initialize(data)
|
46
|
+
@database = data["database"]
|
47
|
+
@table = data["table"]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class Column
|
52
|
+
attr_accessor :database, :table, :column
|
53
|
+
|
54
|
+
def initialize(data)
|
55
|
+
@database = data["database"]
|
56
|
+
@table = data["table"]
|
57
|
+
@column = data["column"]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class FunctionCall
|
62
|
+
attr_accessor :name, :arguments
|
63
|
+
|
64
|
+
def initialize(data)
|
65
|
+
@name = data["name"]
|
66
|
+
@arguments = data["arguments"]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class Violations
|
71
|
+
attr_accessor :row_create_violations, :column_read_violations, :column_update_violations,
|
72
|
+
:row_delete_violation, :admin_violation, :union_violations, :join_violations,
|
73
|
+
:subquery_violations, :function_violations
|
74
|
+
|
75
|
+
def initialize(data)
|
76
|
+
row_create_violations = data["row_create_violations"].map {|el| Table.new(el)}
|
77
|
+
column_read_violations = data["column_read_violations"].map {|el| Column.new(el)}
|
78
|
+
column_update_violations = data["column_update_violations"].map {|el| Column.new(el)}
|
79
|
+
row_delete_violations = data["row_delete_violations"].map {|el| Table.new(el)}
|
80
|
+
admin_violation = data["admin_violation"]
|
81
|
+
union_violations = data["union_violations"].map {|el| Table.new(el)}
|
82
|
+
join_violations = data["join_violations"].map {|el| Table.new(el)}
|
83
|
+
subquery_violations = data["subquery_violations"].map {|el| Table.new(el)}
|
84
|
+
function_violations = data["function_violations"].map {|el| FunctionCall.new(el)}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Prevoty
|
2
|
+
class RSAPrivateKey < RSAPublicKey
|
3
|
+
attr_accessor :d, :primes, :precomputed
|
4
|
+
|
5
|
+
def initialize(data)
|
6
|
+
super(data)
|
7
|
+
@d = data["D"]
|
8
|
+
@primes = data["Primes"]
|
9
|
+
@precomputed = data["Precomputed"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_json(*a)
|
13
|
+
{
|
14
|
+
E: @e,
|
15
|
+
N: @n,
|
16
|
+
D: @d,
|
17
|
+
Primes: @primes,
|
18
|
+
Precomputed: @precomputed
|
19
|
+
}.to_json
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|