contrast-agent-lib 0.1.2 → 0.1.4

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: b925fd5f5ea122270a496c35bd2f42a79e52649a3225951c2b15c759acfeabc2
4
- data.tar.gz: 483c20b4c47eeb729437d1a13e68de51f79d56addbcc67b46770464f07d7a191
3
+ metadata.gz: 33852f7c0ff32dda5f1bb383ea6e22cccbe9f6a8e9eb86d931d42fd87f4ba97d
4
+ data.tar.gz: f8d8483d5eccf6dac6a4c0d14fc0db4cd7a6310b0edaa6ee48d1e6cf2036637d
5
5
  SHA512:
6
- metadata.gz: 330f34fd95c3aa406c5d362f6ab560df495cd865f615a9665f7a413ae7b57ca397d8feaa4b6454792305a2a5fa40740fa07165fabe5fab08ded465b0b4d6b1e5
7
- data.tar.gz: 434401f7eedcc6152b379046c8623d93a4baefafdbd6c8874c68fff0e5cdcbedce233b4c40bc7d0bf924a70cc74e6b1245a0cbf31cbfac99353de8ef7d54020e
6
+ metadata.gz: 6223cc990aef9e0c680ff225a7e2a497fc1deb9760b2518a24d1d2dc7f7298f5806bdc6cc1caf1d2691248d13fe1f9a2f13e685e4eca6a539b383fe6be993505
7
+ data.tar.gz: 64d87019fb7f61c59d613efda6f06540261c8c52ae56918a70472f6d0edfaead92f24e54be21109550c14ce44a60429eb0a30ef8a83c3b2c886af5a8bdd93a05
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.0
1
+ 3.0.0
@@ -14,6 +14,38 @@ def self.add_authors spec
14
14
  ]
15
15
  end
16
16
 
17
+ # Adds files to the gemspec required for the agent lib.
18
+ # It is best to call the build of the gem inside the sdks/ruby dir.
19
+ def self.add_files spec
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ # Directories used for testing:
22
+ f.match(%r{^(spec|test)/}) ||
23
+ f.match(%r{^(\.github|bin|sig|vendor|docs|crates|ci_scripts|raw-protect-rules|scripts|target|utils)/}) ||
24
+ # Configuration and other files that don't belong to one directory
25
+ f.match(/(Dockerfile)/) ||
26
+ f.match(/(CODEOWNERS)/) ||
27
+ f.match(/(.*\.csv)/) ||
28
+ f.match(/(.*\.md)/) ||
29
+ f.match(/(.*\.sh)/) ||
30
+ f.match(/(.*\.xml)/) ||
31
+ f.match(/(.*\.toml)/) ||
32
+ f.match(/(.*\.lock)/) ||
33
+ f.match(/(.*\.json)/) ||
34
+ f.match(%r{^(spec|test)/}) ||
35
+ f.match(/(.*\.ya?ml)/)
36
+ end
37
+
38
+ # exclude . files:
39
+ spec.files -= `git ls-files -- .??*`.split("\n")
40
+
41
+ spec.files += Dir['lib/**/*.rb']
42
+ spec.files += Dir['scripts/**/*.sh']
43
+ spec.files += %w[LICENSE.txt Gemfile contrast-agent-lib.gemspec .ruby-version]
44
+ # add the binary files created.
45
+ spec.files += Dir['usage_files/**/*.dylib']
46
+ spec.files += Dir['usage_files/**/*.so']
47
+ end
48
+
17
49
  # Add dev dependencies
18
50
  def self.add_development_dependencies spec
19
51
  spec.add_development_dependency('ffi', '~> 1.15', '>= 1.15.5')
@@ -25,15 +57,12 @@ Gem::Specification.new do |spec|
25
57
  spec.summary = "This is the Ruby Interface for Rust Agent Library"
26
58
  spec.description = "Gem including the interface for the Rust Agent Library, which will be used within the Ruby-Agent"
27
59
  spec.email = %w[ruby@contrastsecurity.com]
28
- spec.files = %w[lib/utils/os.rb lib/contrast-agent-lib.rb usage_files/libcontrast_c.dylib
29
- usage_files/libcontrast_c.so usage_files/libcontrast_c_musl.so scripts/build_gem.sh
30
- .ruby-version contrast-agent-lib.gemspec Gemfile LICENSE.txt
31
- ]
32
60
  spec.require_paths = ['lib']
33
61
  spec.homepage = 'https://www.contrastsecurity.com'
34
62
  spec.license = 'CONTRAST SECURITY (see license file)'
35
- spec.required_ruby_version = ['>= 2.7.0', '< 3.2.0']
63
+ spec.required_ruby_version = ['>= 2.7.0', '<= 3.2.0']
36
64
 
37
65
  add_authors(spec)
66
+ add_files(spec)
38
67
  add_development_dependencies(spec)
39
- end
68
+ end
data/lib/consts.rb ADDED
@@ -0,0 +1,49 @@
1
+
2
+ # this file generated by c-bindings' build.rs file.
3
+ # DO NOT EDIT
4
+
5
+
6
+ module ContrastAgentLib
7
+ module EvalOptions
8
+ PREFER_WORTH_WATCHING = 1
9
+ end
10
+
11
+ module RuleType
12
+ UNSAFE_FILE_UPLOAD = 1
13
+ PATH_TRAVERSAL = 2
14
+ REFLECTED_XSS = 4
15
+ SQL_INJECTION = 8
16
+ CMD_INJECTION = 16
17
+ NOSQL_INJECTION_MONGO = 32
18
+ BOT_BLOCKER = 64
19
+ SSJS_INJECTION = 128
20
+ METHOD_TAMPERING = 256
21
+ PROTOTYPE_POLLUTION = 512
22
+ end
23
+
24
+ module InputType
25
+ COOKIE_NAME = 1
26
+ COOKIE_VALUE = 2
27
+ HEADER_KEY = 3
28
+ HEADER_VALUE = 4
29
+ JSON_KEY = 5
30
+ JSON_VALUE = 6
31
+ METHOD = 7
32
+ PARAMETER_KEY = 8
33
+ PARAMETER_VALUE = 9
34
+ URI_PATH = 10
35
+ URL_PARAMETER = 11
36
+ MULTIPART_NAME = 12
37
+ XML_VALUE = 13
38
+ end
39
+
40
+ module DbType
41
+ DB2 = 1
42
+ MYSQL = 2
43
+ ORACLE = 3
44
+ POSTGRES = 4
45
+ SQLITE = 5
46
+ SQLSERVER = 6
47
+ UNKNOWN = 7
48
+ end
49
+ end
@@ -3,17 +3,20 @@
3
3
 
4
4
  require 'ffi'
5
5
  require 'utils/os'
6
+ # Load the constants
7
+ require_relative 'consts'
6
8
 
7
9
  module ContrastAgentLib
8
10
  include ContrastAgentLib::OS
9
11
  LINUX_LIB = File.join(__dir__, '..', 'usage_files/libcontrast_c.so')
10
12
  MAC_LIB = File.join(__dir__, '..', 'usage_files/libcontrast_c.dylib')
13
+ MAC_M1_LIB = File.join(__dir__, '..', 'usage_files/libcontrast_darwin_arm.dylib')
11
14
  ALPINE_LIB = File.join(__dir__, '..', 'usage_files/libcontrast_c_musl.so')
12
15
  # Since we need two different extensions for each platform we
13
16
  # need to detect the used OS before loading the dynamic library.
14
17
  CONTRAST_C = if ContrastAgentLib::OS.linux?
15
18
  ContrastAgentLib::OS.alpine? ? ALPINE_LIB : LINUX_LIB
16
19
  else
17
- MAC_LIB
20
+ ContrastAgentLib::OS.m1_mac? ? MAC_M1_LIB : MAC_LIB
18
21
  end
19
- end
22
+ end
data/lib/utils/os.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
2
  # frozen_string_literal: true
3
3
 
4
+ require 'rbconfig'
5
+
4
6
  module ContrastAgentLib
5
7
  module OS
6
8
  class << self
@@ -17,6 +19,10 @@ module ContrastAgentLib
17
19
  @_mac
18
20
  end
19
21
 
22
+ def m1_mac?
23
+ mac? && RbConfig::CONFIG['host_cpu'].include?('arm64')
24
+ end
25
+
20
26
  def unix?
21
27
  !windows?
22
28
  end
@@ -0,0 +1,8 @@
1
+ # Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
2
+ # frozen_string_literal: true
3
+
4
+ module ContrastAgentLib
5
+ module Version
6
+ VERSION='0.1.4'
7
+ end
8
+ end
data/scripts/build_gem.sh CHANGED
@@ -5,6 +5,4 @@ set -Eeuo pipefail
5
5
  gem build contrast-agent-lib.gemspec
6
6
 
7
7
  # Push to RubyGems
8
- # Preferably will be moved as pipeline step on tag only
9
- #curl -u username https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials;
10
- #chmod 0600 ~/.gem/credentials
8
+ # This is moved as separate job in the pipeline
Binary file
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contrast-agent-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - teodor.raychev@contrastsecurity.com
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-07-20 00:00:00.000000000 Z
15
+ date: 2022-11-29 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: ffi
@@ -46,12 +46,15 @@ files:
46
46
  - Gemfile
47
47
  - LICENSE.txt
48
48
  - contrast-agent-lib.gemspec
49
+ - lib/consts.rb
49
50
  - lib/contrast-agent-lib.rb
50
51
  - lib/utils/os.rb
52
+ - lib/utils/version.rb
51
53
  - scripts/build_gem.sh
52
54
  - usage_files/libcontrast_c.dylib
53
55
  - usage_files/libcontrast_c.so
54
56
  - usage_files/libcontrast_c_musl.so
57
+ - usage_files/libcontrast_darwin_arm.dylib
55
58
  homepage: https://www.contrastsecurity.com
56
59
  licenses:
57
60
  - CONTRAST SECURITY (see license file)
@@ -65,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
68
  - - ">="
66
69
  - !ruby/object:Gem::Version
67
70
  version: 2.7.0
68
- - - "<"
71
+ - - "<="
69
72
  - !ruby/object:Gem::Version
70
73
  version: 3.2.0
71
74
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -74,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
77
  - !ruby/object:Gem::Version
75
78
  version: '0'
76
79
  requirements: []
77
- rubygems_version: 3.2.33
80
+ rubygems_version: 3.3.26
78
81
  signing_key:
79
82
  specification_version: 4
80
83
  summary: This is the Ruby Interface for Rust Agent Library