wazuh-ruby-client 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/CHANGELOG.md +0 -0
  6. data/Gemfile +5 -0
  7. data/LICENSE +21 -0
  8. data/README.md +74 -0
  9. data/Rakefile +6 -0
  10. data/docs/.nojekyll +0 -0
  11. data/docs/Wazuh/Api/Endpoints/ActiveResponse.html +278 -0
  12. data/docs/Wazuh/Api/Endpoints/Agents.html +1877 -0
  13. data/docs/Wazuh/Api/Endpoints/Cache.html +415 -0
  14. data/docs/Wazuh/Api/Endpoints/Ciscat.html +418 -0
  15. data/docs/Wazuh/Api/Endpoints/Cluster.html +2270 -0
  16. data/docs/Wazuh/Api/Endpoints/Decoders.html +860 -0
  17. data/docs/Wazuh/Api/Endpoints/Experimental.html +2610 -0
  18. data/docs/Wazuh/Api/Endpoints/Lists.html +452 -0
  19. data/docs/Wazuh/Api/Endpoints/Manager.html +1596 -0
  20. data/docs/Wazuh/Api/Endpoints/Rootcheck.html +1025 -0
  21. data/docs/Wazuh/Api/Endpoints/Rules.html +872 -0
  22. data/docs/Wazuh/Api/Endpoints/SecurityConfigurationAssessment.html +680 -0
  23. data/docs/Wazuh/Api/Endpoints/Summary.html +199 -0
  24. data/docs/Wazuh/Api/Endpoints/Syscheck.html +755 -0
  25. data/docs/Wazuh/Api/Endpoints/Syscollector.html +2069 -0
  26. data/docs/Wazuh/Api/Endpoints.html +292 -0
  27. data/docs/Wazuh/Api/Errors/TooManyRequestsError.html +398 -0
  28. data/docs/Wazuh/Api/Errors/WazuhError.html +290 -0
  29. data/docs/Wazuh/Api/Errors.html +117 -0
  30. data/docs/Wazuh/Api.html +133 -0
  31. data/docs/Wazuh/Client.html +521 -0
  32. data/docs/Wazuh/Config.html +223 -0
  33. data/docs/Wazuh/Faraday/Connection.html +110 -0
  34. data/docs/Wazuh/Faraday/Request.html +335 -0
  35. data/docs/Wazuh/Faraday/Response/RaiseError.html +191 -0
  36. data/docs/Wazuh/Faraday/Response.html +115 -0
  37. data/docs/Wazuh/Faraday.html +117 -0
  38. data/docs/Wazuh/Logger.html +201 -0
  39. data/docs/Wazuh.html +256 -0
  40. data/docs/WazuhRubyClient.html +121 -0
  41. data/docs/_index.html +391 -0
  42. data/docs/class_list.html +51 -0
  43. data/docs/css/common.css +1 -0
  44. data/docs/css/full_list.css +58 -0
  45. data/docs/css/style.css +496 -0
  46. data/docs/file.README.html +142 -0
  47. data/docs/file_list.html +56 -0
  48. data/docs/frames.html +17 -0
  49. data/docs/index.html +142 -0
  50. data/docs/js/app.js +292 -0
  51. data/docs/js/full_list.js +216 -0
  52. data/docs/js/jquery.js +4 -0
  53. data/docs/method_list.html +1059 -0
  54. data/docs/top-level-namespace.html +110 -0
  55. data/lib/tasks/api.rake +78 -0
  56. data/lib/wazuh/api/endpoints/active_response.rb +22 -0
  57. data/lib/wazuh/api/endpoints/agents.rb +175 -0
  58. data/lib/wazuh/api/endpoints/cache.rb +38 -0
  59. data/lib/wazuh/api/endpoints/ciscat.rb +43 -0
  60. data/lib/wazuh/api/endpoints/cluster.rb +199 -0
  61. data/lib/wazuh/api/endpoints/decoders.rb +91 -0
  62. data/lib/wazuh/api/endpoints/experimental.rb +309 -0
  63. data/lib/wazuh/api/endpoints/lists.rb +42 -0
  64. data/lib/wazuh/api/endpoints/manager.rb +156 -0
  65. data/lib/wazuh/api/endpoints/rootcheck.rb +93 -0
  66. data/lib/wazuh/api/endpoints/rules.rb +80 -0
  67. data/lib/wazuh/api/endpoints/security_configuration_assessment.rb +73 -0
  68. data/lib/wazuh/api/endpoints/summary.rb +15 -0
  69. data/lib/wazuh/api/endpoints/syscheck.rb +75 -0
  70. data/lib/wazuh/api/endpoints/syscollector.rb +227 -0
  71. data/lib/wazuh/api/endpoints.rb +37 -0
  72. data/lib/wazuh/api/error.rb +6 -0
  73. data/lib/wazuh/api/errors/too_many_requests_error.rb +22 -0
  74. data/lib/wazuh/api/errors/wazuh_error.rb +14 -0
  75. data/lib/wazuh/client.rb +27 -0
  76. data/lib/wazuh/config.rb +42 -0
  77. data/lib/wazuh/faraday/connection.rb +38 -0
  78. data/lib/wazuh/faraday/request.rb +38 -0
  79. data/lib/wazuh/faraday/response/raise_error.rb +11 -0
  80. data/lib/wazuh/logger.rb +13 -0
  81. data/lib/wazuh/version.rb +4 -0
  82. data/lib/wazuh-ruby-client/version.rb +3 -0
  83. data/lib/wazuh-ruby-client.rb +17 -0
  84. data/lib/wazuh_ruby_client.rb +2 -0
  85. data/wazuh-ruby-client.gemspec +43 -0
  86. metadata +200 -0
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ module Wazuh
3
+ module Config
4
+ extend self
5
+
6
+ ATTRIBUTES = %i[
7
+ user_agent
8
+ client_cert
9
+ client_key
10
+ basic_user
11
+ basic_password
12
+ verify_ssl
13
+ logger
14
+ endpoint
15
+ ].freeze
16
+
17
+ attr_accessor(*Config::ATTRIBUTES)
18
+
19
+ def reset
20
+ self.endpoint = nil
21
+ self.user_agent = "Wazuh Ruby Client/#{Wazuh::VERSION}"
22
+ self.client_cert = nil
23
+ self.client_key = nil
24
+ self.basic_user = nil
25
+ self.basic_password = nil
26
+ self.verify_ssl = true
27
+ self.logger = nil
28
+ end
29
+ end
30
+
31
+ class << self
32
+ def configure
33
+ block_given? ? yield(Config) : Config
34
+ end
35
+
36
+ def config
37
+ Config
38
+ end
39
+ end
40
+ end
41
+
42
+ Wazuh::Config.reset
@@ -0,0 +1,38 @@
1
+ module Wazuh
2
+ module Faraday
3
+ module Connection
4
+ private
5
+
6
+ def connection
7
+ options = {
8
+ headers: { 'Accept' => 'application/json; charset=utf-8' },
9
+ ssl: {}
10
+ }
11
+
12
+ options[:headers]['User-Agent'] = user_agent if user_agent
13
+ # options[:certificate] = certificate if cartificate
14
+ # options[:private_key] = private_key if private_key
15
+ options[:ssl].merge!({ client_cert: client_cert, client_key: client_key }) if client_cert || client_key
16
+
17
+ if basic_user || basic_password
18
+ authorization_header = "Basic " + Base64.encode64(basic_user + ':' + basic_password).strip
19
+ options[:headers].merge!({'Authorization' => authorization_header})
20
+ end
21
+
22
+ options[:ssl].merge!({ verify: false }) unless verify_ssl
23
+
24
+ # request_options = {}
25
+
26
+ ::Faraday::Connection.new(endpoint, options) do |connection|
27
+ connection.use ::Faraday::Request::Multipart
28
+ connection.use ::Faraday::Request::UrlEncoded
29
+ connection.use ::Faraday::Response::RaiseError
30
+ connection.use ::Wazuh::Faraday::Response::RaiseError
31
+ connection.use ::FaradayMiddleware::ParseJson
32
+ connection.response :logger, logger if logger
33
+ connection.adapter ::Faraday.default_adapter
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+ module Wazuh
3
+ module Faraday
4
+ module Request
5
+ def get(path, options = {})
6
+ request(:get, path, options)
7
+ end
8
+
9
+ def post(path, options = {})
10
+ request(:post, path, options)
11
+ end
12
+
13
+ def put(path, options = {})
14
+ request(:put, path, options)
15
+ end
16
+
17
+ def delete(path, options = {})
18
+ request(:delete, path, options)
19
+ end
20
+
21
+ private
22
+
23
+ def request(method, path, options)
24
+ response = connection.send(method) do |request|
25
+ case method
26
+ when :get, :delete
27
+ request.url(path, options)
28
+ when :post, :put
29
+ request.path = path
30
+ request.body = options unless options.empty?
31
+ end
32
+ request.options.merge!(options.delete(:request)) if options.key?(:request)
33
+ end
34
+ response.body
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+ module Wazuh
3
+ module Faraday
4
+ module Response
5
+ class RaiseError < ::Faraday::Response::Middleware
6
+ def on_complete(env)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require 'logger'
2
+
3
+ module Wazuh
4
+ class Logger < ::Logger
5
+ def self.default
6
+ return @default if @default
7
+
8
+ logger = new STDOUT
9
+ logger.level = Logger::WARN
10
+ @default = logger
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+ module Wazuh
3
+ VERSION = '0.0.1'
4
+ end
@@ -0,0 +1,3 @@
1
+ module WazuhRubyClient
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'wazuh/version'
2
+ require_relative 'wazuh/logger'
3
+
4
+ require 'faraday'
5
+ require 'faraday_middleware'
6
+ require 'json'
7
+ require 'logger'
8
+ require 'base64'
9
+
10
+ require_relative 'wazuh/config'
11
+ require_relative 'wazuh/faraday/response/raise_error'
12
+ require_relative 'wazuh/faraday/connection'
13
+ require_relative 'wazuh/faraday/request'
14
+ require_relative 'wazuh/api/endpoints'
15
+ require_relative 'wazuh/api/errors/wazuh_error'
16
+ require_relative 'wazuh/api/error'
17
+ require_relative 'wazuh/client'
@@ -0,0 +1,2 @@
1
+ # frozen_string_literal: true
2
+ require 'wazuh-ruby-client'
@@ -0,0 +1,43 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "wazuh-ruby-client/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "wazuh-ruby-client"
7
+ spec.version = WazuhRubyClient::VERSION
8
+ spec.authors = ["mrtc0"]
9
+ spec.email = ["mrtc0@ssrf.in"]
10
+
11
+ spec.summary = %q{Wazuh API client for Ruby}
12
+ spec.description = %q{Wazuh API client for Ruby}
13
+ spec.homepage = "https://github.com/mrtc0/wazuh-ruby-client"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ # spec.metadata["allowed_push_host"] = "https://github.com/mrtc0/wazuh-ruby-client"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/mrtc0/wazuh-ruby-client"
22
+ spec.metadata["changelog_uri"] = "https://github.com/mrtc0/wazuh-ruby-client/blob/master/CHANGELOG.md"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.17"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "rspec", "~> 3.0"
40
+
41
+ spec.add_dependency 'faraday', '>= 0.9'
42
+ spec.add_dependency 'faraday_middleware'
43
+ end
metadata ADDED
@@ -0,0 +1,200 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wazuh-ruby-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mrtc0
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0.9'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Wazuh API client for Ruby
84
+ email:
85
+ - mrtc0@ssrf.in
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - docs/.nojekyll
99
+ - docs/Wazuh.html
100
+ - docs/Wazuh/Api.html
101
+ - docs/Wazuh/Api/Endpoints.html
102
+ - docs/Wazuh/Api/Endpoints/ActiveResponse.html
103
+ - docs/Wazuh/Api/Endpoints/Agents.html
104
+ - docs/Wazuh/Api/Endpoints/Cache.html
105
+ - docs/Wazuh/Api/Endpoints/Ciscat.html
106
+ - docs/Wazuh/Api/Endpoints/Cluster.html
107
+ - docs/Wazuh/Api/Endpoints/Decoders.html
108
+ - docs/Wazuh/Api/Endpoints/Experimental.html
109
+ - docs/Wazuh/Api/Endpoints/Lists.html
110
+ - docs/Wazuh/Api/Endpoints/Manager.html
111
+ - docs/Wazuh/Api/Endpoints/Rootcheck.html
112
+ - docs/Wazuh/Api/Endpoints/Rules.html
113
+ - docs/Wazuh/Api/Endpoints/SecurityConfigurationAssessment.html
114
+ - docs/Wazuh/Api/Endpoints/Summary.html
115
+ - docs/Wazuh/Api/Endpoints/Syscheck.html
116
+ - docs/Wazuh/Api/Endpoints/Syscollector.html
117
+ - docs/Wazuh/Api/Errors.html
118
+ - docs/Wazuh/Api/Errors/TooManyRequestsError.html
119
+ - docs/Wazuh/Api/Errors/WazuhError.html
120
+ - docs/Wazuh/Client.html
121
+ - docs/Wazuh/Config.html
122
+ - docs/Wazuh/Faraday.html
123
+ - docs/Wazuh/Faraday/Connection.html
124
+ - docs/Wazuh/Faraday/Request.html
125
+ - docs/Wazuh/Faraday/Response.html
126
+ - docs/Wazuh/Faraday/Response/RaiseError.html
127
+ - docs/Wazuh/Logger.html
128
+ - docs/WazuhRubyClient.html
129
+ - docs/_index.html
130
+ - docs/class_list.html
131
+ - docs/css/common.css
132
+ - docs/css/full_list.css
133
+ - docs/css/style.css
134
+ - docs/file.README.html
135
+ - docs/file_list.html
136
+ - docs/frames.html
137
+ - docs/index.html
138
+ - docs/js/app.js
139
+ - docs/js/full_list.js
140
+ - docs/js/jquery.js
141
+ - docs/method_list.html
142
+ - docs/top-level-namespace.html
143
+ - lib/tasks/api.rake
144
+ - lib/wazuh-ruby-client.rb
145
+ - lib/wazuh-ruby-client/version.rb
146
+ - lib/wazuh/api/endpoints.rb
147
+ - lib/wazuh/api/endpoints/active_response.rb
148
+ - lib/wazuh/api/endpoints/agents.rb
149
+ - lib/wazuh/api/endpoints/cache.rb
150
+ - lib/wazuh/api/endpoints/ciscat.rb
151
+ - lib/wazuh/api/endpoints/cluster.rb
152
+ - lib/wazuh/api/endpoints/decoders.rb
153
+ - lib/wazuh/api/endpoints/experimental.rb
154
+ - lib/wazuh/api/endpoints/lists.rb
155
+ - lib/wazuh/api/endpoints/manager.rb
156
+ - lib/wazuh/api/endpoints/rootcheck.rb
157
+ - lib/wazuh/api/endpoints/rules.rb
158
+ - lib/wazuh/api/endpoints/security_configuration_assessment.rb
159
+ - lib/wazuh/api/endpoints/summary.rb
160
+ - lib/wazuh/api/endpoints/syscheck.rb
161
+ - lib/wazuh/api/endpoints/syscollector.rb
162
+ - lib/wazuh/api/error.rb
163
+ - lib/wazuh/api/errors/too_many_requests_error.rb
164
+ - lib/wazuh/api/errors/wazuh_error.rb
165
+ - lib/wazuh/client.rb
166
+ - lib/wazuh/config.rb
167
+ - lib/wazuh/faraday/connection.rb
168
+ - lib/wazuh/faraday/request.rb
169
+ - lib/wazuh/faraday/response/raise_error.rb
170
+ - lib/wazuh/logger.rb
171
+ - lib/wazuh/version.rb
172
+ - lib/wazuh_ruby_client.rb
173
+ - wazuh-ruby-client.gemspec
174
+ homepage: https://github.com/mrtc0/wazuh-ruby-client
175
+ licenses: []
176
+ metadata:
177
+ homepage_uri: https://github.com/mrtc0/wazuh-ruby-client
178
+ source_code_uri: https://github.com/mrtc0/wazuh-ruby-client
179
+ changelog_uri: https://github.com/mrtc0/wazuh-ruby-client/blob/master/CHANGELOG.md
180
+ post_install_message:
181
+ rdoc_options: []
182
+ require_paths:
183
+ - lib
184
+ required_ruby_version: !ruby/object:Gem::Requirement
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ version: '0'
194
+ requirements: []
195
+ rubyforge_project:
196
+ rubygems_version: 2.7.6
197
+ signing_key:
198
+ specification_version: 4
199
+ summary: Wazuh API client for Ruby
200
+ test_files: []