Class: CtdDocumentation::AlertsController

Inherits:
BaseController show all
Defined in:
lib/ctd_documentation/controllers/alerts_controller.rb

Overview

AlertsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from CtdDocumentation::BaseController

Instance Method Details

#find_alert_by_id(resource_id) ⇒ Alert

Get a single alert. to return

Parameters:

  • resource_id (String)

    Required parameter: Resource ID of the Alert

Returns:

  • (Alert)

    response from the API call



155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/ctd_documentation/controllers/alerts_controller.rb', line 155

def find_alert_by_id(resource_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/ranger/alerts/{resource_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(resource_id, key: 'resource_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(Alert.method(:from_hash)))
    .execute
end

#get_alerts(page: nil, per_page: nil, asset_id__exact: nil, asset__exact: nil, for_asset__exact: nil, q__exact: nil, primary_asset__exact: nil, non_primary_assets__exact: nil, virtual_zone__exact: nil, alert_id__exact: nil, ot_alerts__exact: nil, family__exact: nil, story_severity__exact: nil, id__exact: nil, site_id__exact: nil, data__exact: nil, description__exact: nil, type__exact: nil, category__exact: nil, severity__exact: nil, timestamp__exact: nil, last_updated__gte: nil, relevant__exact: nil, resolved__exact: nil, resolution__exact: nil, protocol__exact: nil, score__exact: nil, is_qualified__exact: nil, network_id__exact: nil, resolved_id__exact: nil, assigned_id__exact: nil, story_id__exact: nil, sort: nil) ⇒ GetAlertsResponse

Retrieves a list of Alerts in CTD, with optional filters. Note - All filters are optional. each page. (The maximum is 500). Asset of the primary asset that triggered the alert of the non-primary assets involved in the alert the Zone that triggered the alert Alert. You can add multiple IDs. Asset involved in the Alert, for example Policy Violation. Alert Families appear in the Advanced Options filter of Alerts. which the Alert occurred alert Threat, New Conflict Asset, etc. Integrity, 1 = Security Low, 1 = Medium, 2 = High, 3 = Critical the Alert occured. Format: YYYY-MM-DD**T**HH:MM:SS (in UTC) Example: 2022-11-01T16:22:05 the latest change on the Alert was made in the EMC. Format: YYYY-MM-DD**T**HH:MM:SS (in UTC) Example: 2022-11-01T16:22:05 Example: or not an Alert was resolved: True = resolved, False = not resolved resolution. alert, for example: S7Comm for this alert, on a score of 1-100 Example: which the Alert was assigned to which the Alert belongs - can be viewed in the UI by selecting “Group By Story” in ascending order of the sort attribute. The sorting prefix “-” sorts the results in descending order of the sort attribute.

Parameters:

  • page (Integer) (defaults to: nil)

    Optional parameter: Page offset

  • per_page (Integer) (defaults to: nil)

    Optional parameter: Number of Alerts to pull on

  • asset_id__exact (String) (defaults to: nil)

    Optional parameter: Resource ID of the

  • asset__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • for_asset__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • q__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • primary_asset__exact (String) (defaults to: nil)

    Optional parameter: The resource ID

  • non_primary_assets__exact (String) (defaults to: nil)

    Optional parameter: Resource IDs

  • virtual_zone__exact (String) (defaults to: nil)

    Optional parameter: The resource ID of

  • alert_id__exact (String) (defaults to: nil)

    Optional parameter: The resource ID of the

  • ot_alerts__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • family__exact (String) (defaults to: nil)

    Optional parameter: Model family of the

  • story_severity__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • id__exact (Integer) (defaults to: nil)

    Optional parameter: Example:

  • site_id__exact (Integer) (defaults to: nil)

    Optional parameter: ID of the Site on

  • data__exact (String) (defaults to: nil)

    Optional parameter: Example:

  • description__exact (String) (defaults to: nil)

    Optional parameter: Description of the

  • type__exact (Integer) (defaults to: nil)

    Optional parameter: Alert Type, such as Known

  • category__exact (Integer) (defaults to: nil)

    Optional parameter: Alert Category: 0 =

  • severity__exact (Integer) (defaults to: nil)

    Optional parameter: Alert Severity: 0 =

  • timestamp__exact (String) (defaults to: nil)

    Optional parameter: Timestamp on which

  • last_updated__gte (String) (defaults to: nil)

    Optional parameter: The timestamp when

  • relevant__exact (TrueClass|FalseClass) (defaults to: nil)

    Optional parameter:

  • resolved__exact (TrueClass|FalseClass) (defaults to: nil)

    Optional parameter: Whether

  • resolution__exact (Integer) (defaults to: nil)

    Optional parameter: Type of

  • protocol__exact (String) (defaults to: nil)

    Optional parameter: Protocol used in the

  • score__exact (Integer) (defaults to: nil)

    Optional parameter: Alert Score calculated

  • is_qualified__exact (TrueClass|FalseClass) (defaults to: nil)

    Optional parameter:

  • network_id__exact (Integer) (defaults to: nil)

    Optional parameter: Example:

  • resolved_id__exact (Integer) (defaults to: nil)

    Optional parameter: Example:

  • assigned_id__exact (Integer) (defaults to: nil)

    Optional parameter: ID of the User to

  • story_id__exact (Integer) (defaults to: nil)

    Optional parameter: ID of the Alert Story

  • sort (SortEnum) (defaults to: nil)

    Optional parameter: By default, results are sorted

Returns:



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/ctd_documentation/controllers/alerts_controller.rb', line 73

def get_alerts(page: nil,
               per_page: nil,
               asset_id__exact: nil,
               asset__exact: nil,
               for_asset__exact: nil,
               q__exact: nil,
               primary_asset__exact: nil,
               non_primary_assets__exact: nil,
               virtual_zone__exact: nil,
               alert_id__exact: nil,
               ot_alerts__exact: nil,
               family__exact: nil,
               story_severity__exact: nil,
               id__exact: nil,
               site_id__exact: nil,
               data__exact: nil,
               description__exact: nil,
               type__exact: nil,
               category__exact: nil,
               severity__exact: nil,
               timestamp__exact: nil,
               last_updated__gte: nil,
               relevant__exact: nil,
               resolved__exact: nil,
               resolution__exact: nil,
               protocol__exact: nil,
               score__exact: nil,
               is_qualified__exact: nil,
               network_id__exact: nil,
               resolved_id__exact: nil,
               assigned_id__exact: nil,
               story_id__exact: nil,
               sort: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/ranger/alerts',
                                 Server::DEFAULT)
               .query_param(new_parameter(page, key: 'page'))
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(asset_id__exact, key: 'asset_id__exact'))
               .query_param(new_parameter(asset__exact, key: 'asset__exact'))
               .query_param(new_parameter(for_asset__exact, key: 'for_asset__exact'))
               .query_param(new_parameter(q__exact, key: 'q__exact'))
               .query_param(new_parameter(primary_asset__exact, key: 'primary_asset__exact'))
               .query_param(new_parameter(non_primary_assets__exact, key: 'non_primary_assets__exact'))
               .query_param(new_parameter(virtual_zone__exact, key: 'virtual_zone__exact'))
               .query_param(new_parameter(alert_id__exact, key: 'alert_id__exact'))
               .query_param(new_parameter(ot_alerts__exact, key: 'ot_alerts__exact'))
               .query_param(new_parameter(family__exact, key: 'family__exact'))
               .query_param(new_parameter(story_severity__exact, key: 'story_severity__exact'))
               .query_param(new_parameter(id__exact, key: 'id__exact'))
               .query_param(new_parameter(site_id__exact, key: 'site_id__exact'))
               .query_param(new_parameter(data__exact, key: 'data__exact'))
               .query_param(new_parameter(description__exact, key: 'description__exact'))
               .query_param(new_parameter(type__exact, key: 'type__exact'))
               .query_param(new_parameter(category__exact, key: 'category__exact'))
               .query_param(new_parameter(severity__exact, key: 'severity__exact'))
               .query_param(new_parameter(timestamp__exact, key: 'timestamp__exact'))
               .query_param(new_parameter(last_updated__gte, key: 'last_updated__gte'))
               .query_param(new_parameter(relevant__exact, key: 'relevant__exact'))
               .query_param(new_parameter(resolved__exact, key: 'resolved__exact'))
               .query_param(new_parameter(resolution__exact, key: 'resolution__exact'))
               .query_param(new_parameter(protocol__exact, key: 'protocol__exact'))
               .query_param(new_parameter(score__exact, key: 'score__exact'))
               .query_param(new_parameter(is_qualified__exact, key: 'is_qualified__exact'))
               .query_param(new_parameter(network_id__exact, key: 'network_id__exact'))
               .query_param(new_parameter(resolved_id__exact, key: 'resolved_id__exact'))
               .query_param(new_parameter(assigned_id__exact, key: 'assigned_id__exact'))
               .query_param(new_parameter(story_id__exact, key: 'story_id__exact'))
               .query_param(new_parameter(sort, key: 'sort'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:custom_type_deserializer))
               .deserialize_into(GetAlertsResponse.method(:from_hash)))
    .execute
end