tenable-ruby 0.3.7 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/error/tenable_error.rb +6 -0
- data/lib/tenable-ruby.rb +67 -26
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a307cd9672be72bc72d8aeee16cf07083250883bd6bb26c38a7e2a6344162b66
|
4
|
+
data.tar.gz: b415f2321cc7d6e14bb1ec621b33093424c05050fcb8da747beb10f554f236bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ef0ab799275410df467d988583b0dcb8d777aaf018806dd46eac988f0e93b0e1151f9fb18e2c313cf3617b0fb4bc656949c26c572a72aab6b36d87444798881
|
7
|
+
data.tar.gz: a5f78981f65993467351de830a3e1c76b85477e3efa049746078e78405c06b40c65dd15d7a804340ca0f1dd6d2a5c8b544ce87ad796cce3c688818703b2fcaca
|
data/lib/error/tenable_error.rb
CHANGED
data/lib/tenable-ruby.rb
CHANGED
@@ -307,6 +307,14 @@ module TenableRuby
|
|
307
307
|
http_put(options)
|
308
308
|
end
|
309
309
|
|
310
|
+
# Returns details of the specified asset.
|
311
|
+
#
|
312
|
+
# Reference:
|
313
|
+
# https://developer.tenable.com/reference#assets-asset-info
|
314
|
+
def asset_info(asset_uuid)
|
315
|
+
http_get(:uri => "/assets/#{asset_uuid}", :fields => header)
|
316
|
+
end
|
317
|
+
|
310
318
|
# Creates a scan
|
311
319
|
#
|
312
320
|
# Reference:
|
@@ -410,6 +418,15 @@ module TenableRuby
|
|
410
418
|
http_get(:uri => uri, :fields => header)
|
411
419
|
end
|
412
420
|
|
421
|
+
# Returns the output for a specified plugin.
|
422
|
+
#
|
423
|
+
# Reference:
|
424
|
+
# https://developer.tenable.com/reference#scans-plugin-output
|
425
|
+
def scans_plugin_output(scan_id, host_id, plugin_id)
|
426
|
+
uri = "/scans/#{scan_id}/hosts/#{host_id}/plugins/#{plugin_id}"
|
427
|
+
http_get(:uri => uri, :fields => header)
|
428
|
+
end
|
429
|
+
|
413
430
|
# Download an exported scan
|
414
431
|
#
|
415
432
|
# Reference:
|
@@ -549,33 +566,15 @@ module TenableRuby
|
|
549
566
|
scan_create(template_uuid, settings)
|
550
567
|
end
|
551
568
|
|
552
|
-
# Returns
|
569
|
+
# Returns the latest status for a scan.
|
570
|
+
#
|
571
|
+
# Reference: https://developer.tenable.com/reference#scans-get-latest-status
|
553
572
|
def scan_status(scan_id)
|
554
|
-
|
555
|
-
if
|
556
|
-
|
557
|
-
end
|
558
|
-
if not details['error'].nil?
|
559
|
-
raise TenableRuby::Error::TenableError, "Get scan_details returned the following error: #{details['error']}"
|
560
|
-
end
|
561
|
-
details['info']['status']
|
562
|
-
end
|
563
|
-
|
564
|
-
# Returns the status of the latest history object of a scan by performing a 'scan_details' API call.
|
565
|
-
# Note this is currently updated more frequently than the scan status in the tenable.io API
|
566
|
-
def scan_latest_history_status(scan_id)
|
567
|
-
details = scan_details(scan_id)
|
568
|
-
if details.nil?
|
569
|
-
raise TenableRuby::Error::TenableError, "Get scan_details returned nil"
|
570
|
-
end
|
571
|
-
if not details['error'].nil?
|
572
|
-
raise TenableRuby::Error::TenableError, "Get scan_details returned the following error: #{details['error']}"
|
573
|
-
end
|
574
|
-
history = details['history']
|
575
|
-
if history.nil? or history.length == 0
|
576
|
-
raise TenableRuby::Error::TenableError, "Get scan_details returned empty history object"
|
573
|
+
response = http_get(:uri => "/scans/#{scan_id}/latest-status", :fields => header)
|
574
|
+
if response.is_a?(Hash) and response.has_key?('status')
|
575
|
+
response['status']
|
577
576
|
else
|
578
|
-
|
577
|
+
raise TenableRuby::Error::TenableError, "Tenable.io did not return a valid status response"
|
579
578
|
end
|
580
579
|
end
|
581
580
|
|
@@ -698,6 +697,48 @@ module TenableRuby
|
|
698
697
|
http_get(:uri => "/container-security/api/v1/reports/by_image_digest?image_digest=#{image_digest}", :fields => header)
|
699
698
|
end
|
700
699
|
|
700
|
+
# Creates a new target group for the current user.
|
701
|
+
#
|
702
|
+
# Reference:
|
703
|
+
# https://developer.tenable.com/reference#target-groups-create
|
704
|
+
def create_target_group(name, members, acls: [])
|
705
|
+
http_post(:uri => "/target-groups", :fields => header,
|
706
|
+
:body => {:name => name, :members => members, :acls => alcs})
|
707
|
+
end
|
708
|
+
|
709
|
+
# Returns the current target groups.
|
710
|
+
#
|
711
|
+
# Reference:
|
712
|
+
# https://developer.tenable.com/reference#target-groups-list
|
713
|
+
def list_target_groups
|
714
|
+
http_get(:uri => "/target-groups", :fields => header)
|
715
|
+
end
|
716
|
+
|
717
|
+
# Returns details for the specified target group.
|
718
|
+
#
|
719
|
+
# Reference:
|
720
|
+
# https://developer.tenable.com/reference#target-groups-details
|
721
|
+
def get_target_group(group_id)
|
722
|
+
http_get(:uri => "/target-groups/#{group_id}", :fields => header)
|
723
|
+
end
|
724
|
+
|
725
|
+
# Updates a target group.
|
726
|
+
#
|
727
|
+
# Reference:
|
728
|
+
# https://developer.tenable.com/reference#target-groups-edit
|
729
|
+
def update_target_group(group_id:, name:, members:, acls: nil)
|
730
|
+
http_put(:uri => "/target-groups/#{group_id}", :fields => header,
|
731
|
+
:body => {:name => name, :members => members, :acls => acls})
|
732
|
+
end
|
733
|
+
|
734
|
+
# Deletes a target group.
|
735
|
+
#
|
736
|
+
# Reference:
|
737
|
+
# https://developer.tenable.com/reference#target-groups-delete
|
738
|
+
def delete_target_group(group_id)
|
739
|
+
http_delete(:uri => "/target-groups/#{group_id}", :fields => header)
|
740
|
+
end
|
741
|
+
|
701
742
|
private
|
702
743
|
|
703
744
|
# Perform HTTP put method with uri, data and fields
|
@@ -886,7 +927,7 @@ module TenableRuby
|
|
886
927
|
end
|
887
928
|
|
888
929
|
if response.code.to_s != "200"
|
889
|
-
raise TenableRuby::Error::TenableError,
|
930
|
+
raise TenableRuby::Error::TenableError.new(response: response),
|
890
931
|
"Tenable API request '#{opts[:uri]}' responded with response code #{response.code}"
|
891
932
|
end
|
892
933
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tenable-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Craston
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Ruby library for communicating with the tenable.io API.
|
@@ -25,7 +25,7 @@ homepage: https://gitlab.com/intruder/tenable-ruby
|
|
25
25
|
licenses:
|
26
26
|
- MIT
|
27
27
|
metadata: {}
|
28
|
-
post_install_message:
|
28
|
+
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|
31
31
|
- lib
|
@@ -40,8 +40,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
rubygems_version: 3.0.
|
44
|
-
signing_key:
|
43
|
+
rubygems_version: 3.0.3
|
44
|
+
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Ruby library for communicating with the tenable.io API
|
47
47
|
test_files: []
|