Module: Zanshin::SDK::OrganizationScanTargets

Included in:
Client
Defined in:
lib/zanshin/organization_scan_targets.rb

Overview

Zanshin SDK Organization Scan Target

Instance Method Summary collapse

Instance Method Details

#check_organization_scan_target(organization_id, scan_target_id) ⇒ Object

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • a Object representing the scan target


131
132
133
134
135
136
# File 'lib/zanshin/organization_scan_targets.rb', line 131

def check_organization_scan_target(organization_id, scan_target_id)
  @http.request(
    'POST',
    "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}/check"
  )
end

#create_organization_scan_target(organization_id, name, credential, schedule = '0 0 * * *') ⇒ Object

Create a new scan target in organization [#reference](api.zanshin.tenchisecurity.com/#operation/createOrganizationScanTargets)

Parameters:

Returns:

  • an Object representing the newly created scan target


37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/zanshin/organization_scan_targets.rb', line 37

def create_organization_scan_target(organization_id, name, credential, schedule = '0 0 * * *')
  unless [ScanTarget::AWS, ScanTarget::Azure, ScanTarget::GCP,
          ScanTarget::HUAWEI, ScanTarget::DOMAIN].include? credential.class
    raise "#{credential.class} is invalid instance of Zanshin::SDK::ScanTarget classes"
  end

  body = {
    'kind' => credential.class::KIND, 'name' => name,
    'credential' => credential.to_json, 'schedule' => schedule
  }
  @http.request('POST', "/organizations/#{validate_uuid(organization_id)}/scantargets", body)
end

#delete_organization_scan_target(organization_id, scan_target_id) ⇒ Object

Delete scan target of organization [#reference](api.zanshin.tenchisecurity.com/#operation/deleteOrganizationScanTargetById)

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • a Boolean with result


89
90
91
92
# File 'lib/zanshin/organization_scan_targets.rb', line 89

def delete_organization_scan_target(organization_id, scan_target_id)
  @http.request('DELETE',
                "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}")
end

#get_organization_scan_target(organization_id, scan_target_id) ⇒ Object

Get scan target details of organization [#reference](api.zanshin.tenchisecurity.com/#operation/getOrganizationScanTargetById)

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • a Object representing the scan target


57
58
59
60
# File 'lib/zanshin/organization_scan_targets.rb', line 57

def get_organization_scan_target(organization_id, scan_target_id)
  @http.request('GET',
                "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}")
end

#get_organization_scan_target_scan(organization_id, scan_target_id, scan_id) ⇒ Object

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

  • scan_id (UUID)

    of the scan

Returns:

  • a Object representing the scan


168
169
170
171
172
173
174
# File 'lib/zanshin/organization_scan_targets.rb', line 168

def get_organization_scan_target_scan(organization_id, scan_target_id, scan_id)
  @http.request(
    'GET',
    "/organizations/#{validate_uuid(organization_id)}/scantargets/#{
      validate_uuid(scan_target_id)}/scans/#{validate_uuid(scan_id)}"
  )
end

#iter_organization_scan_target_scans(organization_id, scan_target_id) ⇒ Object

Scans Enumerator of an Scan Target [#reference](api.zanshin.tenchisecurity.com/#operation/getOrganizationScanTargetScans)

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • an Scans Enumerator object


149
150
151
152
153
154
155
156
157
158
# File 'lib/zanshin/organization_scan_targets.rb', line 149

def iter_organization_scan_target_scans(organization_id, scan_target_id)
  Enumerator.new do |yielder|
    @http.request(
      'GET',
      "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}/scans"
    ).each do |e|
      yielder.yield e
    end
  end
end

#iter_organization_scan_targets(organization_id) ⇒ Object

Scan Targets Enumerator of an organization [#reference](api.zanshin.tenchisecurity.com/#operation/getOrganizationScanTargets)

Parameters:

  • organization_id (UUID)

    of the organization

Returns:

  • an Scan Targets Enumerator object


19
20
21
22
23
24
25
# File 'lib/zanshin/organization_scan_targets.rb', line 19

def iter_organization_scan_targets(organization_id)
  Enumerator.new do |yielder|
    @http.request('GET', "/organizations/#{validate_uuid(organization_id)}/scantargets").each do |e|
      yielder.yield e
    end
  end
end

#start_organization_scan_target_scan(organization_id, scan_target_id) ⇒ Object

Starts a scan on the specified scan target [#reference](api.zanshin.tenchisecurity.com/#operation/scanOrganizationScanTarget)

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • a Boolean with result


101
102
103
104
105
106
# File 'lib/zanshin/organization_scan_targets.rb', line 101

def start_organization_scan_target_scan(organization_id, scan_target_id)
  @http.request(
    'POST',
    "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}/scan"
  )
end

#stop_organization_scan_target_scan(organization_id, scan_target_id) ⇒ Object

Stop a scan on the specific scan target

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

Returns:

  • a Boolean with result


117
118
119
120
121
122
# File 'lib/zanshin/organization_scan_targets.rb', line 117

def stop_organization_scan_target_scan(organization_id, scan_target_id)
  @http.request(
    'POST',
    "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}/stop"
  )
end

#update_organization_scan_target(organization_id, scan_target_id, name = nil, schedule = nil) ⇒ Object

Update scan target of organization [#reference](api.zanshin.tenchisecurity.com/#operation/editOrganizationMembersById)

Parameters:

  • organization_id (UUID)

    of the organization

  • scan_target_id (UUID)

    of the scan target

  • name (String) (defaults to: nil)

    of the scan target

  • schedule (Cron) (defaults to: nil)

    of the schedule

Returns:

  • a Object representing the scan target updated


71
72
73
74
75
76
77
78
79
80
# File 'lib/zanshin/organization_scan_targets.rb', line 71

def update_organization_scan_target(organization_id, scan_target_id, name = nil, schedule = nil)
  body = {
    'name' => name,
    'schedule' => schedule
  }

  @http.request('PUT',
                "/organizations/#{validate_uuid(organization_id)}/scantargets/#{validate_uuid(scan_target_id)}",
                body)
end