Groups (risksense_api.__subject.__groups.__groups)

Group module defined for different group related api endpoints.

class risksense_api.__subject.__groups.__groups.Groups(profile)[source]

Bases: Subject

Class for group function definitions.

Parameters:

profile (object) – Profile Object

To utlise group function:

Usage:

self.{risksenseobjectname}.groups.{function}

Examples

To create a group using create() function

>>> self.{risksenseobjectname}.groups.create(args)
__init__(profile)[source]

Initialization of Groups object.

Parameters:

profile (object) – Profile Object

downloadfilterinexport(filename, filters, client_id=None)[source]

Download group data based on search filters.

Parameters:
  • filename (str) – Name of the file

  • filters (list) – A list of dictionaries containing filter parameters

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Note

IGNORE - Internal funtion for csv dump

list_group_filter_fields(client_id=None)[source]

List filter endpoints.

Parameters:

client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

dict

Returns:

The JSON output from the platform is returned, listing the available filters.

Examples

>>> apiobj = self.{risksenseobject}.groups.list_group_filter_fields()
get_single_search_page(search_filters, projection='basic', page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None, csvdump=False)[source]

Searches for and returns groups based on the provided filter(s) and other parameters.

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • projection (str) – Projection to use

  • page_num (int) – The page number of results to be returned.

  • page_size (int) – The number of results per page to be returned.

  • sort_field (str) – The field to be used for sorting the results returned.

  • sort_dir (str) – The direction of sorting to be used. (SortDirection.ASC or SortDirection.DESC)

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

dict

Returns:

The JSON response from the platform is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.get_single_search_page([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}])

Note

You can also dump the data of the group search in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.get_single_search_page([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}],csvdump=True)
search(search_filters, projection='detail', page_size=150, sort_field='id', sort_dir='ASC', client_id=None, csvdump=False)[source]

Searches for and returns groups based on the provided filter(s) and other parameters. Rather than returning paginated results, this function cycles through all pages of results and returns them all in a single list.

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • projection (str) – Projection to use

  • page_size (int) – The number of results per page to be returned.

  • sort_field (int) – The field to be used for sorting the results returned.

  • sort_dir (int) – The direction of sorting to be used. (SortDirection.ASC or SortDirection.DESC)

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

list

Returns:

A list containing all host findings returned by the search using the filter provided.

Examples

>>> apiobj = self.{risksenseobject}.groups.search([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}])

Note

You can also dump the data of the group search in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.search([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}],csvdump=True)
create(name, description, client_id=None, csvdump=False)[source]

Creates a new group.

Parameters:
  • name (str) – The name to be used for the new group.

  • description (str) – Group creation description

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

int

Returns:

The new group ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.create('test','test')

Note

You can also dump the data of the group job id in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.create('test','test',csvdump=True)
history(groupid, client_id=None, csvdump=False)[source]

Get group history.

Parameters:
  • groupid (int) – The id to be used to fetch group history.

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

dict

Returns:

The history of group id.

Examples

>>> apiobj = self.{risksenseobject}.groups.history(1234)

Note

You can also dump the data of the group history in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.history(1234,csvdump=True)
delete(search_filters, client_id=None, csvdump=False)[source]

Deletes groups as specified in search_filters.

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

int

Returns:

Job Id

Examples

>>> apiobj = self.{risksenseobject}.groups.delete([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}])

Note

You can also dump the data of the group to be deleted in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.get_single_search_page([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}],csvdump=True)
update_single_group(group_id, client_id=None, csvdump=False, **kwargs)[source]

Updates a group name and/or asset criticality.

Parameters:
  • group_id (int) – The group ID.

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Keyword Args: name (str): The new name. description (str): The new Description

Return type:

int

Returns:

The job ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.update_single_group(1234)

Note

You can also dump the data of the group job id in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.update_single_group(1234,csvdump=True)
assign(search_filters, user_ids, client_id=None, csvdump=False)[source]

Assign group(s) to user IDs, based on specified filter(s)

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • user_ids (list) – A list of user IDs.

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

int

Returns:

The job ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.assign([{"field":"name","exclusive":False,"operator":"EXACT","value":"test","implicitFilters":[]}],[1234])

Note

You can also dump the data of the group job id in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.assign([{"field":"name","exclusive":False,"operator":"EXACT","value":"test","implicitFilters":[]}],[1234],csvdump=True)
unassign(search_filters, user_ids, client_id=None, csvdump=False)[source]

Unassign group(s) from user IDs, based on specified filter(s)

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • user_ids (list) – A list of user IDs.

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

int

Returns:

The job ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.unassign([{"field":"name","exclusive":False,"operator":"EXACT","value":"test","implicitFilters":[]}],[1234])

Note

You can also dump the data of the group job id in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.unassign([{"field":"name","exclusive":False,"operator":"EXACT","value":"test","implicitFilters":[]}],[1234],csvdump=True)
get_model(client_id=None)[source]

Get available projections and models for Groups.

Parameters:

client_id (typing.Optional[int]) – Client ID

Return type:

dict

Returns:

Group projections and models are returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.get_model()
suggest(search_filter, suggest_filter, client_id=None)[source]

Suggest values for filter fields.

Parameters:
  • search_filter (list) – Search Filter

  • suggest_filter (dict) – Suggest Filter

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

dict

Returns:

Value suggestions

Examples

>>> apiobj = self.{risksenseobject}.groups.suggest([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}])
getexporttemplate(client_id=None)[source]

Gets configurable export template for application findings.

Parameters:

client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

list

Returns:

The Exportable fields

Examples

>>> apiobj = self.{risksenseobject}.groups.getexporttemplate()
export(search_filters, file_name, row_count='All', file_type='CSV', client_id=None, csvdump=False)[source]

Initiates an export job on the platform for group(s) based on the provided filter(s).

Parameters:
  • search_filters (list) – A list of dictionaries containing filter parameters.

  • file_name (str) – The name to be used for the exported file.

  • row_count (str) – No of rows to be exported. Possible options : ExportRowNumbers.ROW_5000, ExportRowNumbers.ROW_10000, ExportRowNumbers.ROW_25000, ExportRowNumbers.ROW_50000”, ExportRowNumbers.ROW_100000”, ExportRowNumbers.ROW_ALL

  • file_type (str) – File type to export. ExportFileType.CSV, ExportFileType.XML, or ExportFileType.XLSX

  • client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

  • csvdump (bool) – Toggle to dump data in csv

Return type:

int

Returns:

The Export job ID in the platform from is returned.

Examples

>>> apiobj = self.{risksenseobject}.groups.export([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}],'test')

Note

You can also dump the data of the group in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.groups.export([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"test*","implicitFilters":[]}],csvdump=True)
subscribe_change_in_grouprs3(client_id=None)[source]

Subscribe change in group rs3 notification

Parameters:

client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

dict

Returns:

Jsonified response

Examples

>>> apiobj = self.{risksenseobject}.groups.subscribe_change_in_grouprs3()
unsubscribe_change_in_grouprs3(client_id=None)[source]

Unsubscribe change in group rs3 notification

Parameters:

client_id (typing.Optional[int]) – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

dict

Returns:

Jsonified response

Examples

>>> apiobj = self.{risksenseobject}.groups.unsubscribe_change_in_grouprs3()