cyberhaven-incidents 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e1852bcc7cbcbb90acce8ad0a6958b9987b5dc77c81def0f2a3acf9704f5b759
4
+ data.tar.gz: 3fc25b31c33f5acd2cfc9977779fadf5df4ccb213680ea971ebfda52edf05602
5
+ SHA512:
6
+ metadata.gz: e44d80eaab68028327e398fa3d88ce749d94c9a83876fbb34f6120f9e1f84f6ed8d58e483e17333272beb2f00e495bb315ab49eda46b3b882f0d9fe3f9389004
7
+ data.tar.gz: 90c4298aadf9d12d5e81eb35d611c6b0e6a8cef73d260f046664d1e1ddbc72f52241771ccb3ac6b545aaf12679848620b55ac42c8764f1198b80953494066da5
data/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+
2
+ ## 0.4.0
3
+ Add: add user incidenetss for status and number of events
4
+
5
+ ## 0.3.1
6
+ Add: add json and yaml output formats for detailed view
7
+
8
+
9
+ ## 0.3.0
10
+ Add: add json and yaml output formats for summary view
11
+
12
+ ## 0.2.5
13
+ Add: incident totals for status'
14
+
15
+
16
+ ## 0.2.4
17
+ Add: output in raw json
18
+
19
+ ## 0.2.3
20
+ Add: split incident by ID into id.rb
21
+
22
+ ## 0.2.2
23
+ Add: get incident details (verbose raw output)
24
+ Add: get incident summary (formatted output)
25
+
26
+
27
+ ## 0.2.0
28
+ Add: get incident details by incident id
29
+
30
+
31
+ ## 0.1.0
32
+ - Initial Build
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 nic scott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ # Cyberhaven::Incidents
2
+
3
+
4
+ ## Summary
5
+ A ruby gem to interact with the Cyberhaven incident API. Tested on Cyberhaven version 23.11.
6
+
7
+ ---
8
+ ## Installation
9
+
10
+ `sudo gem install cyberhaven-incidents`
11
+
12
+ ---
13
+ ## Usage
14
+
15
+ In order to run Cyberhaven Incidents, you are required to add these two variables to the top of your file, under the require `cyberhaven-incidents` line.
16
+
17
+ ```ruby
18
+ #!/usr/bin/ruby
19
+
20
+ require "cyberhaven-incidents"
21
+
22
+ ## UPDATE THESE VARIABLES ------------------------------------------------------
23
+ $refreshToken = "API-REFRESH-TOKEN"
24
+ $deployment = "company.cyberhaven.io"
25
+ ```
26
+
27
+ ---
28
+ ## Example Commands
29
+
30
+ ```ruby
31
+ ## COMMANDS ########################################
32
+ Cyberhaven::Incidents::getBearerToken
33
+
34
+ ## Incident Totals
35
+ Cyberhaven::Incidents::totalIncidents
36
+ Cyberhaven::Incidents::totalUnresolvedIncidents
37
+ Cyberhaven::Incidents::totalIgnoredIncidents
38
+ Cyberhaven::Incidents::totalInProgressIncidents
39
+ Cyberhaven::Incidents::totalResolvedIncidents
40
+
41
+ ## Detailed Incident details by ID
42
+ Cyberhaven::Incidents::Id::DetailedJson("#{incidentID}")
43
+ Cyberhaven::Incidents::Id::DetailedYaml("#{incidentID}")
44
+ Cyberhaven::Incidents::Id::DetailedReport("#{incidentID}")
45
+
46
+ ## Summaried Incidents details by ID
47
+ Cyberhaven::Incidents::Id::SummaryJson("#{incidentID}")
48
+ Cyberhaven::Incidents::Id::SummaryYaml("#{incidentID}")
49
+ Cyberhaven::Incidents::Id::SummaryReport("#{incidentID}")
50
+
51
+ ## Incident details by user
52
+ puts Cyberhaven::Incidents::User::DetailedRaw("username", "status", numberOfEvents)
53
+ puts Cyberhaven::Incidents::User::DetailedJson("username", "status", numberOfEvents)
54
+
55
+ #example
56
+ puts Cyberhaven::Incidents::User::DetailedJson("joedaily", "unresolved", 100)
57
+
58
+ • status options are: "ignored", "in_progress", "resolved", or "unresolved"
59
+ ```
60
+
61
+ ---
62
+ ## Reference
63
+ https://storage.googleapis.com/cyberhaven-docs/redoc-static.html#/paths/~1api~1rest~1v1~1incidents~1list/post*
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/cyberhaven/incidents/version"
4
+ require_relative "lib/cyberhaven/incidents/id"
5
+ require_relative "lib/cyberhaven/incidents/user"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "cyberhaven-incidents"
9
+ spec.version = Cyberhaven::Incidents::VERSION
10
+ spec.authors = ["nic scott"]
11
+ spec.email = ["nls.inbox@gmail.com"]
12
+
13
+ spec.summary = "A ruby gem that interacts with the Cyberhaven Incident API"
14
+ spec.homepage = "https://github.com/nlscott/cyberhaven-incidents"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.6.0"
17
+
18
+ spec.files = Dir.chdir(__dir__) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ (File.expand_path(f) == __FILE__) ||
21
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
22
+ end
23
+ end
24
+
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+ end
@@ -0,0 +1,338 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ module Cyberhaven
5
+ module Incidents
6
+ module Id
7
+ ## DETAILED VERBOSE ----------------------------------------------------
8
+ def self.DetailedRaw(incidentID)
9
+ $query ={
10
+ "filters":{
11
+ "incident_ids": [
12
+ "#{incidentID}"
13
+ ],
14
+ },
15
+ "sort_by": "event_time",
16
+ "page_size": 1,
17
+ "sort_desc": true
18
+ }.to_json
19
+
20
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
21
+ https = Net::HTTP.new(url.host, url.port)
22
+ https.use_ssl = true
23
+ request = Net::HTTP::Get.new(url)
24
+ request["Content-Type"] = "application/json"
25
+ request["Authorization"] = "Bearer #{$bearerToken}"
26
+ request.body = $query
27
+ response = https.request(request)
28
+ status = response.code
29
+ results = JSON.parse(response.read_body)
30
+
31
+ $data = results["incidents"]
32
+ end
33
+
34
+ def self.DetailedJson(incidentID)
35
+ DetailedRaw("#{incidentID}")
36
+ puts $data.to_json
37
+ end
38
+
39
+ def self.DetailedYaml(incidentID)
40
+ DetailedRaw("#{incidentID}")
41
+ puts $data.to_yaml
42
+ end
43
+
44
+ def self.DetailedReport(incidentID)
45
+ $query ={
46
+ "filters":{
47
+ "incident_ids": [
48
+ "#{incidentID}"
49
+ ],
50
+ },
51
+ "sort_by": "event_time",
52
+ "page_size": 1,
53
+ "sort_desc": true
54
+ }.to_json
55
+
56
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
57
+ https = Net::HTTP.new(url.host, url.port)
58
+ https.use_ssl = true
59
+ request = Net::HTTP::Get.new(url)
60
+ request["Content-Type"] = "application/json"
61
+ request["Authorization"] = "Bearer #{$bearerToken}"
62
+ request.body = $query
63
+ response = https.request(request)
64
+ status = response.code
65
+ results = JSON.parse(response.read_body)
66
+
67
+ results["incidents"].each do |item|
68
+ puts "INCIDENT ID: #{item["id"]}"
69
+ puts " EVENT TIME: #{item["event_time"]}"
70
+ puts " TRIGGER TIME: #{item["trigger_time"]}"
71
+ puts " POLICY NAME: #{item["category"]["name"]}"
72
+ puts " POLICY SEVERITY: #{item["category"]["severity"]}"
73
+ puts " USER: #{item["user"]}"
74
+ puts " STATUS: #{item["resolution_status"]}"
75
+ puts " OUTDATED POLICY: #{item["outdated_policy"]}"
76
+ puts " FILE: #{item["file"]}"
77
+ puts " FILE PATH: #{item["data"]["path"]}"
78
+ puts " SOURCE DATA: #{item["source_data"]["path"]}"
79
+ puts " PERSONAL INFO:"
80
+ if ! item["personal_info"].nil?
81
+ item["personal_info"].each do |personalItem|
82
+ puts " #{personalItem}"
83
+ end
84
+ end
85
+ puts " ASSIGNEE: #{item["assignee"]}"
86
+ puts " CONTENT TAGS: #{item["content_tags"]}"
87
+ puts " RESPONSE: #{item["incident_response"]}"
88
+ puts " REACTION: #{item["incident_reactions"]}"
89
+ puts " ADMIN HISTORY: #{item["admin_history"]}"
90
+ puts " CATEGOERY MODIFIED: #{item["category_last_modified"]}"
91
+ puts " DATASET MODIFIED: #{item["dataset_last_modified"]}"
92
+ puts " ALERT ID: #{item["alert_id"]}"
93
+ puts " SCREENSHOT GUID: #{item["screenshot_guid"]}"
94
+ puts ""
95
+
96
+ puts " DATASET:"
97
+ puts " ID: #{item["dataset"]["id"]}"
98
+ puts " NAME: #{item["dataset"]["name"]}"
99
+ puts " SENSITIVITY: #{item["dataset"]["sensitivity"]}"
100
+ puts " LAST MODIFIED: #{item["dataset"]["last_modified"]}"
101
+ puts ""
102
+
103
+ puts " POLICY:"
104
+ puts " ID: #{item["category"]["id"]}"
105
+ puts " NAME: #{item["category"]["name"]}"
106
+ puts " SEVERITY: #{item["category"]["severity"]}"
107
+ puts " DATASET IDS: #{item["category"]["dataset_ids"]}"
108
+ puts " EXCLUDE ORIGIN: #{item["category"]["exclude_origin"]}"
109
+ puts " LAST MODIFIED: #{item["category"]["last_modified"]}"
110
+ puts " SELECTION TYPE: #{item["category"]["selection_type"]}"
111
+ puts " RULE:"
112
+ puts " ID: #{item["category"]["rule"]["id"]}"
113
+ puts " STATUS: #{item["category"]["rule"]["status"]}"
114
+ puts " CREATE INCIDENT: #{item["category"]["rule"]["create_incident"]}"
115
+ puts " RECORD SCREENSHOT: #{item["category"]["rule"]["record_screenshots"]}"
116
+ puts " NOTIFY ENABLED: #{item["category"]["rule"]["notify_enabled"]}"
117
+ puts " NOTIFY STATUS: #{item["category"]["rule"]["notify_status"]}"
118
+ puts " NOTIFY EMAIL: #{item["category"]["rule"]["notify_email"]}"
119
+ puts " SHOW TITLE: #{item["category"]["rule"]["show_title"]}"
120
+ puts " SHOW LOGO: #{item["category"]["rule"]["show_logo"]}"
121
+ puts " REQUIRE JUSTIFICATION: #{item["category"]["rule"]["require_justification"]}"
122
+ puts " REQUIRE ACKNOWLEDGEMENT: #{item["category"]["rule"]["should_ack_warning"]}"
123
+ puts " ALLOW REVIEW: #{item["category"]["rule"]["allow_request_review"]}"
124
+ puts " OVERRIDE ENABLED: #{item["category"]["rule"]["override_enabled"]}"
125
+ puts " BLOCKING ACTION: #{item["category"]["rule"]["blocking_action"]}"
126
+ puts " INCIDENT ACTION: #{item["category"]["rule"]["incident_action"]}"
127
+ puts " WARNING MESSAGE:"
128
+ puts " TITLE: #{item["category"]["rule"]["warning_dialog"]["title"]}"
129
+ puts " EXPLANATION: #{item["category"]["rule"]["warning_dialog"]["explanation"]}"
130
+ puts " PLACEHOLDER: #{item["category"]["rule"]["warning_dialog"]["placeholder"]}"
131
+ puts " CHECK TEXT: #{item["category"]["rule"]["warning_dialog"]["check_text"]}"
132
+ puts " REVIEW CHECK TEXT: #{item["category"]["rule"]["warning_dialog"]["review_check_text"]}"
133
+ puts " SUBMIT LABEL: #{item["category"]["rule"]["warning_dialog"]["submit_label"]}"
134
+ puts " ALLOW LABEL: #{item["category"]["rule"]["warning_dialog"]["allow_label"]}"
135
+ puts " BLOCKING MESSAGE:"
136
+ puts " TITLE: #{item["category"]["rule"]["blocking_dialog"]["title"]}"
137
+ puts " EXPLANATION: #{item["category"]["rule"]["blocking_dialog"]["explanation"]}"
138
+ puts " PLACEHOLDER: #{item["category"]["rule"]["blocking_dialog"]["placeholder"]}"
139
+ puts " CHECK TEXT: #{item["category"]["rule"]["blocking_dialog"]["check_text"]}"
140
+ puts " REVIEW CHECK TEXT: #{item["category"]["rule"]["blocking_dialog"]["review_check_text"]}"
141
+ puts " SUBMIT LABEL: #{item["category"]["rule"]["blocking_dialog"]["submit_label"]}"
142
+ puts " ALLOW LABEL: #{item["category"]["rule"]["blocking_dialog"]["allow_label"]}"
143
+ puts ""
144
+
145
+ puts " SOURCE INFORMATION:"
146
+ puts " PATH: #{item["edge"]["source"]["path"]}"
147
+ puts " EXTENSION: #{item["edge"]["source"]["extension"]}"
148
+ puts " URL: #{item["edge"]["source"]["url"]}"
149
+ puts " BROWSER URL: #{item["edge"]["source"]["browser_page_url"]}"
150
+ puts " BROWSER DOMAIN: #{item["edge"]["source"]["browser_page_domain"]}"
151
+ puts " BROWSER TITLE: #{item["edge"]["source"]["browser_page_title"]}"
152
+ puts " HOSTNAME: #{item["edge"]["source"]["hostname"]}"
153
+ puts " URI: #{item["edge"]["source"]["content_uri"]}"
154
+ puts " LOCATION: #{item["edge"]["source"]["location"]}"
155
+ puts " LOCATION OUTLINE: #{item["edge"]["source"]["location_outline"]}"
156
+ puts " CATEGORY: #{item["edge"]["source"]["category"]}"
157
+ puts " LINKS: #{item["edge"]["source"]["links"]}"
158
+ puts " ID: #{item["edge"]["source"]["raw_id"]}"
159
+ puts " TAGS: #{item["edge"]["source"]["tags_applied"]}"
160
+ puts " UPLOAD URI: #{item["edge"]["source"]["content_upload_uri"]}"
161
+ puts " REPORT URI: #{item["edge"]["source"]["content_report_uri"]}"
162
+ puts " TAGS: #{item["edge"]["source"]["tags_applied"]}"
163
+ puts " EVENT TYPE: #{item["edge"]["source"]["event_type"]}"
164
+ puts " SENSOR: #{item["edge"]["source"]["sensor_name"]}"
165
+ puts " USERNAME: #{item["edge"]["source"]["local_user_name"]}"
166
+ puts " USER ID: #{item["edge"]["source"]["local_user_sid"]}"
167
+ puts " LOCAL TIME: #{item["edge"]["source"]["local_time"]}"
168
+ puts " MACHINE NAME: #{item["edge"]["source"]["local_machine_name"]}"
169
+ puts " ENDPIONT ID: #{item["edge"]["source"]["endpoint_id"]}"
170
+ puts " GROUP NAME: #{item["edge"]["source"]["group_name"]}"
171
+ puts " LOCAL ID: #{item["edge"]["source"]["local_id"]}"
172
+ puts " BLOCKED: #{item["edge"]["source"]["blocked"]}"
173
+ puts " DATA SIZE: #{item["edge"]["source"]["data_size"]}"
174
+ puts ""
175
+
176
+ puts " DESTINATION INFORMATION:"
177
+ puts " PATH: #{item["edge"]["destination"]["path"]}"
178
+ puts " EXTENSION: #{item["edge"]["destination"]["extension"]}"
179
+ puts " UPLOAD FILE ID: #{item["edge"]["destination"]["upload_file_id"]}"
180
+ puts " URL: #{item["edge"]["destination"]["url"]}"
181
+ puts " BROWSER TITLE: #{item["edge"]["destination"]["browser_page_title"]}"
182
+ puts " HOSTNAME: #{item["edge"]["destination"]["hostname"]}"
183
+ puts " MD5: #{item["edge"]["destination"]["md5_hash"]}"
184
+ puts " FILE SIZE: #{item["edge"]["destination"]["file_size"]}"
185
+ puts " PATH COMPONENTS: #{item["edge"]["destination"]["path_components"]}"
186
+ puts " BASENAME: #{item["edge"]["destination"]["path_basename"]}"
187
+ puts " DOMAIN COMPONENTS: #{item["edge"]["destination"]["domain_components"]}"
188
+ puts " DOMAIN: #{item["edge"]["destination"]["domain"]}"
189
+ puts " URI: #{item["edge"]["destination"]["content_uri"]}"
190
+ puts " LOCATION: #{item["edge"]["destination"]["location"]}"
191
+ puts " LOCATION OUTLINE: #{item["edge"]["destination"]["location_outline"]}"
192
+ puts " CATEGORY: #{item["edge"]["destination"]["category"]}"
193
+ puts " LINKS: #{item["edge"]["destination"]["links"]}"
194
+ puts " RAW ID: #{item["edge"]["destination"]["raw_id"]}"
195
+ puts " TAGS: #{item["edge"]["destination"]["tags_applied"]}"
196
+ puts " CONTENT UPLOAD URI: #{item["edge"]["destination"]["content_upload_uri"]}"
197
+ puts " CONTENT REPORT URI: #{item["edge"]["destination"]["content_report_uri"]}"
198
+ puts " EVENT TYPE: #{item["edge"]["destination"]["event_type"]}"
199
+ puts " SENSOR: #{item["edge"]["destination"]["sensor_name"]}"
200
+ puts " LOCAL USERNAME: #{item["edge"]["destination"]["local_user_name"]}"
201
+ puts " LOCAL USERID: #{item["edge"]["destination"]["local_user_sid"]}"
202
+ puts " LOCAL TIME: #{item["edge"]["destination"]["local_time"]}"
203
+ puts " LOCAL MACHINE NAME: #{item["edge"]["destination"]["local_machine_name"]}"
204
+ puts " ENDPOINT ID: #{item["edge"]["destination"]["endpoint_id"]}"
205
+ puts " GROUP NAMES: #{item["edge"]["destination"]["group_name"]}"
206
+ puts " BLOCKED: #{item["edge"]["destination"]["blocked"]}"
207
+ puts " DATA SIZE: #{item["edge"]["destination"]["data_size"]}"
208
+ puts " LOCAL ID: #{item["edge"]["destination"]["local_id"]}"
209
+ puts " GDRIVE FILE ID: #{item["edge"]["destination"]["gdrive_file_id"]}"
210
+ puts " CLOUD PROVIDER: #{item["edge"]["destination"]["cloud_provider"]}"
211
+ puts " CLOUD APP: #{item["edge"]["destination"]["cloud_app"]}"
212
+ puts " CLOUD ACCOUNT: #{item["edge"]["destination"]["cloud_app_account"]}"
213
+ puts " DLP SCAN ID: #{item["edge"]["destination"][" dlp_scan_linking_id"]}"
214
+ puts ""
215
+ end
216
+ end
217
+
218
+
219
+ ## SUMMARIES -----------------------------------------------------------
220
+ def self.SummaryRaw(incidentID)
221
+ $query ={
222
+ "filters":{
223
+ "incident_ids": [
224
+ "#{incidentID}"
225
+ ],
226
+ },
227
+ "sort_by": "event_time",
228
+ "page_size": 1,
229
+ "sort_desc": true
230
+ }.to_json
231
+
232
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
233
+ https = Net::HTTP.new(url.host, url.port)
234
+ https.use_ssl = true
235
+ request = Net::HTTP::Get.new(url)
236
+ request["Content-Type"] = "application/json"
237
+ request["Authorization"] = "Bearer #{$bearerToken}"
238
+ request.body = $query
239
+ response = https.request(request)
240
+ status = response.code
241
+ results = JSON.parse(response.read_body)
242
+
243
+ results["incidents"].each do |item|
244
+ $data = {
245
+ values: {
246
+ "incident_id": " #{item["id"]}".to_s,
247
+ "event_time": " #{item["event_time"]}".to_s,
248
+ "policy_name": "#{item["category"]["name"]}".to_s,
249
+ "policy_severity": " #{item["category"]["severity"]}".to_s,
250
+ "user": "#{item["user"]}".to_s,
251
+ "status": "#{item["resolution_status"]}".to_s,
252
+ "dataset": "#{item["dataset"]["name"]}".to_s,
253
+ "dataset_sensitivity": "#{item["dataset"]["sensitivity"]}".to_i,
254
+ "ploiicy_severity": "#{item["category"]["severity"]}".to_i,
255
+ "create_incident": " #{item["category"]["rule"]["create_incident"]}".to_s,
256
+ "incident_action": "#{item["category"]["rule"]["incident_action"]}".to_s,
257
+ "src_url": "#{item["edge"]["source"]["url"]}".to_s,
258
+ "src_browser_url": "#{item["edge"]["source"]["browser_page_url"]}".to_s,
259
+ "src_browser_domain": " #{item["edge"]["source"]["browser_page_domain"]}".to_s,
260
+ "src_browser_title": "#{item["edge"]["source"]["browser_page_title"]}".to_s,
261
+ "src_location": "#{item["edge"]["destination"]["location"]}".to_s,
262
+ "src_location_outline": "#{item["edge"]["source"]["location_outline"]}".to_s,
263
+ "src_category": "#{item["edge"]["source"]["category"]}".to_s,
264
+ "dst_browser_title": "#{item["edge"]["destination"]["browser_page_title"]}".to_s,
265
+ "dst_basename": "#{item["edge"]["destination"]["path_basename"]}".to_s,
266
+ "dst_domain": "#{item["edge"]["destination"]["domain"]}".to_s,
267
+ "dest_location": "#{item["edge"]["destination"]["location"]}".to_s,
268
+ "dst_location_outline": "#{item["edge"]["destination"]["location_outline"]}".to_s,
269
+ "dst_category": "#{item["edge"]["destination"]["category"]}".to_s,
270
+ "dst_event_type": "#{item["edge"]["destination"]["event_type"]}".to_s,
271
+ "dst_sensor": "#{item["edge"]["destination"]["sensor_name"]}".to_s,
272
+ "dst_local_username": "#{item["edge"]["destination"]["local_user_name"]}".to_s,
273
+ "dst_local_machine_name": "#{item["edge"]["destination"]["local_machine_name"]}".to_s,
274
+ "dst_blocked": "#{item["edge"]["destination"]["blocked"]}".to_s,
275
+ "dst_data_size": "#{item["edge"]["destination"]["data_size"]}".to_s,
276
+ "dst_gdrive_file_id": "#{item["edge"]["destination"]["gdrive_file_id"]}".to_s,
277
+ "dst_cloud_provider": "#{item["edge"]["destination"]["cloud_provider"]}".to_s,
278
+ "dst_cloud_app": "#{item["edge"]["destination"]["cloud_app"]}".to_s,
279
+ "dst_cloud_account": "#{item["edge"]["destination"]["cloud_app_account"]}".to_s,
280
+ }}
281
+ return $data
282
+ end
283
+ end
284
+
285
+ def self.SummaryJson(incidentID)
286
+ SummaryRaw("#{incidentID}")
287
+ puts $data.to_json
288
+ end
289
+
290
+ def self.SummaryYaml(incidentID)
291
+ SummaryRaw("#{incidentID}")
292
+ puts $data.to_yaml
293
+ end
294
+
295
+ def self.SummaryReport(incidentID)
296
+ SummaryRaw("#{incidentID}")
297
+
298
+ puts "Incident ID: #{$data[:values][:incident_id]}"
299
+ puts " Event Time: #{$data[:values][:event_time]}"
300
+ puts " Policy Name: #{$data[:values][:policy_name]}"
301
+ puts " Policy Severity: #{$data[:values][:policy_severity]}"
302
+ puts " User: #{$data[:values][:user]}"
303
+ puts " Status: #{$data[:values][:status]}"
304
+ puts " Dataset Name: #{$data[:values][:dataset]}"
305
+ puts " Dataset Sensitivity: #{$data[:values][:dataset_sensitivity]}"
306
+ puts " Policy Severity: #{$data[:values][:ploiicy_severity]}"
307
+ puts " Create Incident: #{$data[:values][:create_incident]}"
308
+ puts " Incident Action: #{$data[:values][:incident_action]}"
309
+ puts " Source Information:"
310
+ puts " Url: #{$data[:values][:src_url]}"
311
+ puts " Browser Url: #{$data[:values][:src_browser_url]}"
312
+ puts " Browser Domain: #{$data[:values][:src_browser_domain]}"
313
+ puts " Browser Title: #{$data[:values][:src_browser_title]}"
314
+ puts " Location: #{$data[:values][:src_location]}"
315
+ puts " Location Outline: #{$data[:values][:src_location_outline]}"
316
+ puts " Category: #{$data[:values][:src_category]}"
317
+ puts " Destination Information:"
318
+ puts " Browser Title: #{$data[:values][:dst_browser_title]}"
319
+ puts " Basename: #{$data[:values][:dst_basename]}"
320
+ puts " Domain: #{$data[:values][:dst_domain]}"
321
+ puts " Location: #{$data[:values][:dest_location]}"
322
+ puts " Location Outline: #{$data[:values][:dst_location_outline]}"
323
+ puts " Category: #{$data[:values][:dst_category]}"
324
+ puts " Event Type: #{$data[:values][:dst_event_type]}"
325
+ puts " Sensor: #{$data[:values][:dst_sensor]}"
326
+ puts " Local Username: #{$data[:values][:dst_local_username]}"
327
+ puts " Local Machine Name: #{$data[:values][:dst_local_machine_name]}"
328
+ puts " Blocked: #{$data[:values][:dst_blocked]}"
329
+ puts " Data Size: #{$data[:values][:dst_data_size]}"
330
+ puts " Google Drive File ID: #{$data[:values][:dst_gdrive_file_id]}"
331
+ puts " Cloud Provider: #{$data[:values][:dst_cloud_provider]}"
332
+ puts " Cloud App: #{$data[:values][:dst_cloud_app]}"
333
+ puts " Cloud Account: #{$data[:values][:dst_cloud_account]}"
334
+ end
335
+
336
+ end
337
+ end
338
+ end
@@ -0,0 +1,356 @@
1
+ # frozen_string_literal: true
2
+
3
+
4
+ module Cyberhaven
5
+ module Incidents
6
+ module User
7
+ ## DETAILED VERBOSE ----------------------------------------------------
8
+ def self.DetailedRaw(username, status, numberOfEvents)
9
+
10
+ $pageToken = "1"
11
+ loop do
12
+ unless $pageToken.empty?
13
+
14
+ if $pageToken == "1"
15
+ $pageToken = ""
16
+ end
17
+
18
+ $query ={
19
+ "filters":{
20
+ "resolution_statuses": [
21
+ "#{status}"
22
+ ],
23
+ "users": [
24
+ "#{username}"
25
+ ],
26
+ },
27
+ "sort_by": "event_time",
28
+ "page_size": numberOfEvents,
29
+ "sort_desc": true
30
+ }.to_json
31
+
32
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
33
+ https = Net::HTTP.new(url.host, url.port)
34
+ https.use_ssl = true
35
+ request = Net::HTTP::Get.new(url)
36
+ request["Content-Type"] = "application/json"
37
+ request["Authorization"] = "Bearer #{$bearerToken}"
38
+ request.body = $query
39
+ response = https.request(request)
40
+ status = response.code
41
+ results = JSON.parse(response.read_body)
42
+
43
+ pageToken = results["next_page_id"]
44
+ $data = results["incidents"]
45
+ return $data
46
+ else
47
+ break
48
+ end
49
+ end
50
+ end
51
+
52
+ def self.DetailedJson(username, status, numberOfEvents)
53
+ DetailedRaw("#{username}", "#{status}", numberOfEvents)
54
+ return $data.to_json
55
+ end
56
+
57
+ # def self.DetailedYaml(incidentID)
58
+ # DetailedRaw("#{incidentID}")
59
+ # puts $data.to_yaml
60
+ # end
61
+
62
+ # def self.DetailedReport(incidentID)
63
+ # $query ={
64
+ # "filters":{
65
+ # "incident_ids": [
66
+ # "#{incidentID}"
67
+ # ],
68
+ # },
69
+ # "sort_by": "event_time",
70
+ # "page_size": 1,
71
+ # "sort_desc": true
72
+ # }.to_json
73
+
74
+ # url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
75
+ # https = Net::HTTP.new(url.host, url.port)
76
+ # https.use_ssl = true
77
+ # request = Net::HTTP::Get.new(url)
78
+ # request["Content-Type"] = "application/json"
79
+ # request["Authorization"] = "Bearer #{$bearerToken}"
80
+ # request.body = $query
81
+ # response = https.request(request)
82
+ # status = response.code
83
+ # results = JSON.parse(response.read_body)
84
+
85
+ # results["incidents"].each do |item|
86
+ # puts "INCIDENT ID: #{item["id"]}"
87
+ # puts " EVENT TIME: #{item["event_time"]}"
88
+ # puts " TRIGGER TIME: #{item["trigger_time"]}"
89
+ # puts " POLICY NAME: #{item["category"]["name"]}"
90
+ # puts " POLICY SEVERITY: #{item["category"]["severity"]}"
91
+ # puts " USER: #{item["user"]}"
92
+ # puts " STATUS: #{item["resolution_status"]}"
93
+ # puts " OUTDATED POLICY: #{item["outdated_policy"]}"
94
+ # puts " FILE: #{item["file"]}"
95
+ # puts " FILE PATH: #{item["data"]["path"]}"
96
+ # puts " SOURCE DATA: #{item["source_data"]["path"]}"
97
+ # puts " PERSONAL INFO:"
98
+ # if ! item["personal_info"].nil?
99
+ # item["personal_info"].each do |personalItem|
100
+ # puts " #{personalItem}"
101
+ # end
102
+ # end
103
+ # puts " ASSIGNEE: #{item["assignee"]}"
104
+ # puts " CONTENT TAGS: #{item["content_tags"]}"
105
+ # puts " RESPONSE: #{item["incident_response"]}"
106
+ # puts " REACTION: #{item["incident_reactions"]}"
107
+ # puts " ADMIN HISTORY: #{item["admin_history"]}"
108
+ # puts " CATEGOERY MODIFIED: #{item["category_last_modified"]}"
109
+ # puts " DATASET MODIFIED: #{item["dataset_last_modified"]}"
110
+ # puts " ALERT ID: #{item["alert_id"]}"
111
+ # puts " SCREENSHOT GUID: #{item["screenshot_guid"]}"
112
+ # puts ""
113
+
114
+ # puts " DATASET:"
115
+ # puts " ID: #{item["dataset"]["id"]}"
116
+ # puts " NAME: #{item["dataset"]["name"]}"
117
+ # puts " SENSITIVITY: #{item["dataset"]["sensitivity"]}"
118
+ # puts " LAST MODIFIED: #{item["dataset"]["last_modified"]}"
119
+ # puts ""
120
+
121
+ # puts " POLICY:"
122
+ # puts " ID: #{item["category"]["id"]}"
123
+ # puts " NAME: #{item["category"]["name"]}"
124
+ # puts " SEVERITY: #{item["category"]["severity"]}"
125
+ # puts " DATASET IDS: #{item["category"]["dataset_ids"]}"
126
+ # puts " EXCLUDE ORIGIN: #{item["category"]["exclude_origin"]}"
127
+ # puts " LAST MODIFIED: #{item["category"]["last_modified"]}"
128
+ # puts " SELECTION TYPE: #{item["category"]["selection_type"]}"
129
+ # puts " RULE:"
130
+ # puts " ID: #{item["category"]["rule"]["id"]}"
131
+ # puts " STATUS: #{item["category"]["rule"]["status"]}"
132
+ # puts " CREATE INCIDENT: #{item["category"]["rule"]["create_incident"]}"
133
+ # puts " RECORD SCREENSHOT: #{item["category"]["rule"]["record_screenshots"]}"
134
+ # puts " NOTIFY ENABLED: #{item["category"]["rule"]["notify_enabled"]}"
135
+ # puts " NOTIFY STATUS: #{item["category"]["rule"]["notify_status"]}"
136
+ # puts " NOTIFY EMAIL: #{item["category"]["rule"]["notify_email"]}"
137
+ # puts " SHOW TITLE: #{item["category"]["rule"]["show_title"]}"
138
+ # puts " SHOW LOGO: #{item["category"]["rule"]["show_logo"]}"
139
+ # puts " REQUIRE JUSTIFICATION: #{item["category"]["rule"]["require_justification"]}"
140
+ # puts " REQUIRE ACKNOWLEDGEMENT: #{item["category"]["rule"]["should_ack_warning"]}"
141
+ # puts " ALLOW REVIEW: #{item["category"]["rule"]["allow_request_review"]}"
142
+ # puts " OVERRIDE ENABLED: #{item["category"]["rule"]["override_enabled"]}"
143
+ # puts " BLOCKING ACTION: #{item["category"]["rule"]["blocking_action"]}"
144
+ # puts " INCIDENT ACTION: #{item["category"]["rule"]["incident_action"]}"
145
+ # puts " WARNING MESSAGE:"
146
+ # puts " TITLE: #{item["category"]["rule"]["warning_dialog"]["title"]}"
147
+ # puts " EXPLANATION: #{item["category"]["rule"]["warning_dialog"]["explanation"]}"
148
+ # puts " PLACEHOLDER: #{item["category"]["rule"]["warning_dialog"]["placeholder"]}"
149
+ # puts " CHECK TEXT: #{item["category"]["rule"]["warning_dialog"]["check_text"]}"
150
+ # puts " REVIEW CHECK TEXT: #{item["category"]["rule"]["warning_dialog"]["review_check_text"]}"
151
+ # puts " SUBMIT LABEL: #{item["category"]["rule"]["warning_dialog"]["submit_label"]}"
152
+ # puts " ALLOW LABEL: #{item["category"]["rule"]["warning_dialog"]["allow_label"]}"
153
+ # puts " BLOCKING MESSAGE:"
154
+ # puts " TITLE: #{item["category"]["rule"]["blocking_dialog"]["title"]}"
155
+ # puts " EXPLANATION: #{item["category"]["rule"]["blocking_dialog"]["explanation"]}"
156
+ # puts " PLACEHOLDER: #{item["category"]["rule"]["blocking_dialog"]["placeholder"]}"
157
+ # puts " CHECK TEXT: #{item["category"]["rule"]["blocking_dialog"]["check_text"]}"
158
+ # puts " REVIEW CHECK TEXT: #{item["category"]["rule"]["blocking_dialog"]["review_check_text"]}"
159
+ # puts " SUBMIT LABEL: #{item["category"]["rule"]["blocking_dialog"]["submit_label"]}"
160
+ # puts " ALLOW LABEL: #{item["category"]["rule"]["blocking_dialog"]["allow_label"]}"
161
+ # puts ""
162
+
163
+ # puts " SOURCE INFORMATION:"
164
+ # puts " PATH: #{item["edge"]["source"]["path"]}"
165
+ # puts " EXTENSION: #{item["edge"]["source"]["extension"]}"
166
+ # puts " URL: #{item["edge"]["source"]["url"]}"
167
+ # puts " BROWSER URL: #{item["edge"]["source"]["browser_page_url"]}"
168
+ # puts " BROWSER DOMAIN: #{item["edge"]["source"]["browser_page_domain"]}"
169
+ # puts " BROWSER TITLE: #{item["edge"]["source"]["browser_page_title"]}"
170
+ # puts " HOSTNAME: #{item["edge"]["source"]["hostname"]}"
171
+ # puts " URI: #{item["edge"]["source"]["content_uri"]}"
172
+ # puts " LOCATION: #{item["edge"]["source"]["location"]}"
173
+ # puts " LOCATION OUTLINE: #{item["edge"]["source"]["location_outline"]}"
174
+ # puts " CATEGORY: #{item["edge"]["source"]["category"]}"
175
+ # puts " LINKS: #{item["edge"]["source"]["links"]}"
176
+ # puts " ID: #{item["edge"]["source"]["raw_id"]}"
177
+ # puts " TAGS: #{item["edge"]["source"]["tags_applied"]}"
178
+ # puts " UPLOAD URI: #{item["edge"]["source"]["content_upload_uri"]}"
179
+ # puts " REPORT URI: #{item["edge"]["source"]["content_report_uri"]}"
180
+ # puts " TAGS: #{item["edge"]["source"]["tags_applied"]}"
181
+ # puts " EVENT TYPE: #{item["edge"]["source"]["event_type"]}"
182
+ # puts " SENSOR: #{item["edge"]["source"]["sensor_name"]}"
183
+ # puts " USERNAME: #{item["edge"]["source"]["local_user_name"]}"
184
+ # puts " USER ID: #{item["edge"]["source"]["local_user_sid"]}"
185
+ # puts " LOCAL TIME: #{item["edge"]["source"]["local_time"]}"
186
+ # puts " MACHINE NAME: #{item["edge"]["source"]["local_machine_name"]}"
187
+ # puts " ENDPIONT ID: #{item["edge"]["source"]["endpoint_id"]}"
188
+ # puts " GROUP NAME: #{item["edge"]["source"]["group_name"]}"
189
+ # puts " LOCAL ID: #{item["edge"]["source"]["local_id"]}"
190
+ # puts " BLOCKED: #{item["edge"]["source"]["blocked"]}"
191
+ # puts " DATA SIZE: #{item["edge"]["source"]["data_size"]}"
192
+ # puts ""
193
+
194
+ # puts " DESTINATION INFORMATION:"
195
+ # puts " PATH: #{item["edge"]["destination"]["path"]}"
196
+ # puts " EXTENSION: #{item["edge"]["destination"]["extension"]}"
197
+ # puts " UPLOAD FILE ID: #{item["edge"]["destination"]["upload_file_id"]}"
198
+ # puts " URL: #{item["edge"]["destination"]["url"]}"
199
+ # puts " BROWSER TITLE: #{item["edge"]["destination"]["browser_page_title"]}"
200
+ # puts " HOSTNAME: #{item["edge"]["destination"]["hostname"]}"
201
+ # puts " MD5: #{item["edge"]["destination"]["md5_hash"]}"
202
+ # puts " FILE SIZE: #{item["edge"]["destination"]["file_size"]}"
203
+ # puts " PATH COMPONENTS: #{item["edge"]["destination"]["path_components"]}"
204
+ # puts " BASENAME: #{item["edge"]["destination"]["path_basename"]}"
205
+ # puts " DOMAIN COMPONENTS: #{item["edge"]["destination"]["domain_components"]}"
206
+ # puts " DOMAIN: #{item["edge"]["destination"]["domain"]}"
207
+ # puts " URI: #{item["edge"]["destination"]["content_uri"]}"
208
+ # puts " LOCATION: #{item["edge"]["destination"]["location"]}"
209
+ # puts " LOCATION OUTLINE: #{item["edge"]["destination"]["location_outline"]}"
210
+ # puts " CATEGORY: #{item["edge"]["destination"]["category"]}"
211
+ # puts " LINKS: #{item["edge"]["destination"]["links"]}"
212
+ # puts " RAW ID: #{item["edge"]["destination"]["raw_id"]}"
213
+ # puts " TAGS: #{item["edge"]["destination"]["tags_applied"]}"
214
+ # puts " CONTENT UPLOAD URI: #{item["edge"]["destination"]["content_upload_uri"]}"
215
+ # puts " CONTENT REPORT URI: #{item["edge"]["destination"]["content_report_uri"]}"
216
+ # puts " EVENT TYPE: #{item["edge"]["destination"]["event_type"]}"
217
+ # puts " SENSOR: #{item["edge"]["destination"]["sensor_name"]}"
218
+ # puts " LOCAL USERNAME: #{item["edge"]["destination"]["local_user_name"]}"
219
+ # puts " LOCAL USERID: #{item["edge"]["destination"]["local_user_sid"]}"
220
+ # puts " LOCAL TIME: #{item["edge"]["destination"]["local_time"]}"
221
+ # puts " LOCAL MACHINE NAME: #{item["edge"]["destination"]["local_machine_name"]}"
222
+ # puts " ENDPOINT ID: #{item["edge"]["destination"]["endpoint_id"]}"
223
+ # puts " GROUP NAMES: #{item["edge"]["destination"]["group_name"]}"
224
+ # puts " BLOCKED: #{item["edge"]["destination"]["blocked"]}"
225
+ # puts " DATA SIZE: #{item["edge"]["destination"]["data_size"]}"
226
+ # puts " LOCAL ID: #{item["edge"]["destination"]["local_id"]}"
227
+ # puts " GDRIVE FILE ID: #{item["edge"]["destination"]["gdrive_file_id"]}"
228
+ # puts " CLOUD PROVIDER: #{item["edge"]["destination"]["cloud_provider"]}"
229
+ # puts " CLOUD APP: #{item["edge"]["destination"]["cloud_app"]}"
230
+ # puts " CLOUD ACCOUNT: #{item["edge"]["destination"]["cloud_app_account"]}"
231
+ # puts " DLP SCAN ID: #{item["edge"]["destination"][" dlp_scan_linking_id"]}"
232
+ # puts ""
233
+ # end
234
+ # end
235
+
236
+
237
+ # ## SUMMARIES -----------------------------------------------------------
238
+ # def self.SummaryRaw(incidentID)
239
+ # $query ={
240
+ # "filters":{
241
+ # "incident_ids": [
242
+ # "#{incidentID}"
243
+ # ],
244
+ # },
245
+ # "sort_by": "event_time",
246
+ # "page_size": 1,
247
+ # "sort_desc": true
248
+ # }.to_json
249
+
250
+ # url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
251
+ # https = Net::HTTP.new(url.host, url.port)
252
+ # https.use_ssl = true
253
+ # request = Net::HTTP::Get.new(url)
254
+ # request["Content-Type"] = "application/json"
255
+ # request["Authorization"] = "Bearer #{$bearerToken}"
256
+ # request.body = $query
257
+ # response = https.request(request)
258
+ # status = response.code
259
+ # results = JSON.parse(response.read_body)
260
+
261
+ # results["incidents"].each do |item|
262
+ # $data = {
263
+ # values: {
264
+ # "incident_id": " #{item["id"]}".to_s,
265
+ # "event_time": " #{item["event_time"]}".to_s,
266
+ # "policy_name": "#{item["category"]["name"]}".to_s,
267
+ # "policy_severity": " #{item["category"]["severity"]}".to_s,
268
+ # "user": "#{item["user"]}".to_s,
269
+ # "status": "#{item["resolution_status"]}".to_s,
270
+ # "dataset": "#{item["dataset"]["name"]}".to_s,
271
+ # "dataset_sensitivity": "#{item["dataset"]["sensitivity"]}".to_i,
272
+ # "ploiicy_severity": "#{item["category"]["severity"]}".to_i,
273
+ # "create_incident": " #{item["category"]["rule"]["create_incident"]}".to_s,
274
+ # "incident_action": "#{item["category"]["rule"]["incident_action"]}".to_s,
275
+ # "src_url": "#{item["edge"]["source"]["url"]}".to_s,
276
+ # "src_browser_url": "#{item["edge"]["source"]["browser_page_url"]}".to_s,
277
+ # "src_browser_domain": " #{item["edge"]["source"]["browser_page_domain"]}".to_s,
278
+ # "src_browser_title": "#{item["edge"]["source"]["browser_page_title"]}".to_s,
279
+ # "src_location": "#{item["edge"]["destination"]["location"]}".to_s,
280
+ # "src_location_outline": "#{item["edge"]["source"]["location_outline"]}".to_s,
281
+ # "src_category": "#{item["edge"]["source"]["category"]}".to_s,
282
+ # "dst_browser_title": "#{item["edge"]["destination"]["browser_page_title"]}".to_s,
283
+ # "dst_basename": "#{item["edge"]["destination"]["path_basename"]}".to_s,
284
+ # "dst_domain": "#{item["edge"]["destination"]["domain"]}".to_s,
285
+ # "dest_location": "#{item["edge"]["destination"]["location"]}".to_s,
286
+ # "dst_location_outline": "#{item["edge"]["destination"]["location_outline"]}".to_s,
287
+ # "dst_category": "#{item["edge"]["destination"]["category"]}".to_s,
288
+ # "dst_event_type": "#{item["edge"]["destination"]["event_type"]}".to_s,
289
+ # "dst_sensor": "#{item["edge"]["destination"]["sensor_name"]}".to_s,
290
+ # "dst_local_username": "#{item["edge"]["destination"]["local_user_name"]}".to_s,
291
+ # "dst_local_machine_name": "#{item["edge"]["destination"]["local_machine_name"]}".to_s,
292
+ # "dst_blocked": "#{item["edge"]["destination"]["blocked"]}".to_s,
293
+ # "dst_data_size": "#{item["edge"]["destination"]["data_size"]}".to_s,
294
+ # "dst_gdrive_file_id": "#{item["edge"]["destination"]["gdrive_file_id"]}".to_s,
295
+ # "dst_cloud_provider": "#{item["edge"]["destination"]["cloud_provider"]}".to_s,
296
+ # "dst_cloud_app": "#{item["edge"]["destination"]["cloud_app"]}".to_s,
297
+ # "dst_cloud_account": "#{item["edge"]["destination"]["cloud_app_account"]}".to_s,
298
+ # }}
299
+ # return $data
300
+ # end
301
+ # end
302
+
303
+ # def self.SummaryJson(incidentID)
304
+ # SummaryRaw("#{incidentID}")
305
+ # puts $data.to_json
306
+ # end
307
+
308
+ # def self.SummaryYaml(incidentID)
309
+ # SummaryRaw("#{incidentID}")
310
+ # puts $data.to_yaml
311
+ # end
312
+
313
+ # def self.SummaryReport(incidentID)
314
+ # SummaryRaw("#{incidentID}")
315
+
316
+ # puts "INCIDENT ID: #{$data[:values][:incident_id]}"
317
+ # puts " EVENT TIME: #{$data[:values][:event_time]}"
318
+ # puts " POLICY NAME: #{$data[:values][:policy_name]}"
319
+ # puts " POLICY SEVERITY: #{$data[:values][:policy_severity]}"
320
+ # puts " USER: #{$data[:values][:user]}"
321
+ # puts " STATUS: #{$data[:values][:status]}"
322
+ # puts " DATASET NAME: #{$data[:values][:dataset]}"
323
+ # puts " DATASET SENSITIVITY: #{$data[:values][:dataset_sensitivity]}"
324
+ # puts " POLICY SEVERITY: #{$data[:values][:ploiicy_severity]}"
325
+ # puts " CREATE INCIDENT: #{$data[:values][:create_incident]}"
326
+ # puts " INCIDENT ACTION: #{$data[:values][:incident_action]}"
327
+ # puts " SOURCE INFORMATION:"
328
+ # puts " URL: #{$data[:values][:src_url]}"
329
+ # puts " BROWSER URL: #{$data[:values][:src_browser_url]}"
330
+ # puts " BROWSER DOMAIN: #{$data[:values][:src_browser_domain]}"
331
+ # puts " BROWSER TITLE: #{$data[:values][:src_browser_title]}"
332
+ # puts " LOCATION: #{$data[:values][:src_location]}"
333
+ # puts " LOCATION OUTLINE: #{$data[:values][:src_location_outline]}"
334
+ # puts " CATEGORY: #{$data[:values][:src_category]}"
335
+ # puts " DESTINATION INFORMATION:"
336
+ # puts " BROWSER TITLE: #{$data[:values][:dst_browser_title]}"
337
+ # puts " BASENAME: #{$data[:values][:dst_basename]}"
338
+ # puts " DOMAIN: #{$data[:values][:dst_domain]}"
339
+ # puts " LOCATION: #{$data[:values][:dest_location]}"
340
+ # puts " LOCATION OUTLINE: #{$data[:values][:dst_location_outline]}"
341
+ # puts " CATEGORY: #{$data[:values][:dst_category]}"
342
+ # puts " EVENT TYPE: #{$data[:values][:dst_event_type]}"
343
+ # puts " SENSOR: #{$data[:values][:dst_sensor]}"
344
+ # puts " LOCAL USERNAME: #{$data[:values][:dst_local_username]}"
345
+ # puts " LOCAL MACHINE NAME: #{$data[:values][:dst_local_machine_name]}"
346
+ # puts " BLOCKED: #{$data[:values][:dst_blocked]}"
347
+ # puts " DATA SIZE: #{$data[:values][:dst_data_size]}"
348
+ # puts " GDRIVE FILE ID: #{$data[:values][:dst_gdrive_file_id]}"
349
+ # puts " CLOUD PROVIDER: #{$data[:values][:dst_cloud_provider]}"
350
+ # puts " CLOUD APP: #{$data[:values][:dst_cloud_app]}"
351
+ # puts " CLOUD ACCOUNT: #{$data[:values][:dst_cloud_account]}"
352
+ # end
353
+
354
+ end
355
+ end
356
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cyberhaven
4
+ module Incidents
5
+ VERSION = "0.4.0"
6
+ end
7
+ end
@@ -0,0 +1,139 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "json"
5
+ require 'yaml'
6
+ require "net/http"
7
+ require 'openssl'
8
+ require 'base64'
9
+ require_relative "incidents/version"
10
+ require_relative "incidents/id"
11
+ require_relative "incidents/user"
12
+
13
+ module Cyberhaven
14
+ module Incidents
15
+
16
+ def self.getBearerToken
17
+ decode = Base64.decode64("#{$refreshToken}")
18
+ $query = decode
19
+
20
+ url = URI("https://#{$deployment}/user-management/auth/token")
21
+ https = Net::HTTP.new(url.host, url.port)
22
+ https.use_ssl = true
23
+ request = Net::HTTP::Post.new(url)
24
+ request["Content-Type"] = "application/json"
25
+ request.body = $query
26
+ response = https.request(request)
27
+ $bearerToken = response.read_body.strip
28
+ end
29
+
30
+ def self.totalIncidents
31
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
32
+ https = Net::HTTP.new(url.host, url.port)
33
+ https.use_ssl = true
34
+ request = Net::HTTP::Get.new(url)
35
+ request["Content-Type"] = "application/json"
36
+ request["Authorization"] = "Bearer #{$bearerToken}"
37
+ request.body = JSON.dump({})
38
+ response = https.request(request)
39
+ status = response.code
40
+ results = JSON.parse(response.read_body)
41
+ puts results["total"].to_i
42
+ end
43
+
44
+ def self.totalUnresolvedIncidents
45
+ $query ={
46
+ "filters":{
47
+ "resolution_statuses":[
48
+ "unresolved"
49
+ ],
50
+ },
51
+ "page_size": 1,
52
+ }.to_json
53
+
54
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
55
+ https = Net::HTTP.new(url.host, url.port)
56
+ https.use_ssl = true
57
+ request = Net::HTTP::Get.new(url)
58
+ request["Content-Type"] = "application/json"
59
+ request["Authorization"] = "Bearer #{$bearerToken}"
60
+ request.body = $query
61
+ response = https.request(request)
62
+ status = response.code
63
+ results = JSON.parse(response.read_body)
64
+ puts results["total"].to_i
65
+ end
66
+
67
+ def self.totalIgnoredIncidents
68
+ $query ={
69
+ "filters":{
70
+ "resolution_statuses":[
71
+ "ignored"
72
+ ]
73
+ },
74
+ "sort_by": "event_time",
75
+ "page_size": 1,
76
+ "sort_desc": true
77
+ }.to_json
78
+
79
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
80
+ https = Net::HTTP.new(url.host, url.port)
81
+ https.use_ssl = true
82
+ request = Net::HTTP::Get.new(url)
83
+ request["Content-Type"] = "application/json"
84
+ request["Authorization"] = "Bearer #{$bearerToken}"
85
+ request.body = $query
86
+ response = https.request(request)
87
+ status = response.code
88
+ results = JSON.parse(response.read_body)
89
+ puts results["total"].to_i
90
+ end
91
+
92
+ def self.totalInProgressIncidents
93
+ $query ={
94
+ "filters":{
95
+ "resolution_statuses":[
96
+ "in_progress"
97
+ ],
98
+ },
99
+ "page_size": 100,
100
+ }.to_json
101
+
102
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
103
+ https = Net::HTTP.new(url.host, url.port)
104
+ https.use_ssl = true
105
+ request = Net::HTTP::Get.new(url)
106
+ request["Content-Type"] = "application/json"
107
+ request["Authorization"] = "Bearer #{$bearerToken}"
108
+ request.body = $query
109
+ response = https.request(request)
110
+ status = response.code
111
+ results = JSON.parse(response.read_body)
112
+ puts results["total"].to_i
113
+ end
114
+
115
+ def self.totalResolvedIncidents
116
+ $query ={
117
+ "filters":{
118
+ "resolution_statuses":[
119
+ "resolved"
120
+ ],
121
+ },
122
+ "page_size": 100,
123
+ }.to_json
124
+
125
+ url = URI("https://#{$deployment}/api/rest/v1/incidents/list")
126
+ https = Net::HTTP.new(url.host, url.port)
127
+ https.use_ssl = true
128
+ request = Net::HTTP::Get.new(url)
129
+ request["Content-Type"] = "application/json"
130
+ request["Authorization"] = "Bearer #{$bearerToken}"
131
+ request.body = $query
132
+ response = https.request(request)
133
+ status = response.code
134
+ results = JSON.parse(response.read_body)
135
+ puts results["total"].to_i
136
+ end
137
+
138
+ end
139
+ end
@@ -0,0 +1,6 @@
1
+ module Cyberhaven
2
+ module Incidents
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cyberhaven-incidents
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0
5
+ platform: ruby
6
+ authors:
7
+ - nic scott
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - nls.inbox@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG.md
21
+ - LICENSE.txt
22
+ - README.md
23
+ - Rakefile
24
+ - cyberhaven-incidents.gemspec
25
+ - lib/cyberhaven/incidents.rb
26
+ - lib/cyberhaven/incidents/id.rb
27
+ - lib/cyberhaven/incidents/user.rb
28
+ - lib/cyberhaven/incidents/version.rb
29
+ - sig/cyberhaven/incidents.rbs
30
+ homepage: https://github.com/nlscott/cyberhaven-incidents
31
+ licenses:
32
+ - MIT
33
+ metadata: {}
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.6.0
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ requirements: []
49
+ rubygems_version: 3.2.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: A ruby gem that interacts with the Cyberhaven Incident API
53
+ test_files: []