Assessments (risksense_api.__subject.__assessments.__assessments)

Assessment module defined for different assessment related api endpoints.

class risksense_api.__subject.__assessments.__assessments.Assessments(profile)[source]

Bases: Subject

Class for assessment function definitions.

Parameters:

profile (object) – Profile Object

To utlise assessment function:

Usage:

self.{risksenseobjectname}.assessments.{function}

Examples

To create an assessment using create() function

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

Initialization of Assessments object.

Parameters:

profile (object) – Profile Object

create(name, start_date, notes='', client_id=None, csvdump=False)[source]

Creates an assessment.

Parameters:
  • name (str) – The name for new assessment.

  • start_date (datetime.date) – The date for the new assessment. Should be in “YYYY-MM-DD” format.

  • notes (str) – Any notes to associated with the assessment.

  • 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:

Assessment job id

Examples

>>> apiobj = self.{risksenseobject}.assessments.create('hello','2022-02-11','testingtherisksense')

Note

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

>>>  self.{risksenseobject}.assessments.create('hello','2022-02-11','testingtherisksense',csvdump=True)
update(assessment_id, client_id=None, csvdump=False, **kwargs)[source]

Update an assessment

Parameters:
  • assessment_id (int) – The assessment 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 Arguments:
  • name (str) – The name to assign to the assessment.

  • start_date (str) – The start date to assign to the assessment. Should be in “YYYY-MM-DD” format.

  • notes (str) – Notes to assign to the assessment.

Return type:

int

Returns:

The job ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.assessments.update(216917, start_date='2022-08-01', name='testcase_aug_test', notes='')

Note

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

>>>  self.{risksenseobject}.assessments.update(216917, start_date='2022-08-01', name='testcase_aug_test',csvdump=True)
delete(assessment_id, client_id=None, csvdump=False)[source]

Deletes an assessment.

Parameters:
  • assessment_id (int) – Assessment 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

Return type:

int

Returns:

The job ID is returned.

Examples

>>> apiobj = self.{risksenseobject}.assessments.delete(216917)

Note

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

>>>  self.{risksenseobject}.assessments.delete(216917,csvdump=True)
get_model(client_id=None)[source]

Get available projections and models for Assessments.

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:

Assessment projections and models are returned.

Examples

>>> apiobj = self.{risksenseobject}.assessments.get_model(123)
list_assessment_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}.assessments.list_assessment_filter_fields(123)
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}.assessments.suggest([],{"field":"name","exclusive":False,"operator":"WILDCARD","value":"testcase_aug_test,","implicitFilters":[]}))
get_single_search_page(search_filters, page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None)[source]

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

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

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

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

  • sort_field (str) – Name of field to sort results on.

  • sort_dir (str) – Direction to sort. 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.

Return type:

dict

Returns:

The paginated JSON response from the platform is returned.

Examples

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

Searches for and returns assessments 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.

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

  • sort_field (str) – Name of field to sort results on.

  • sort_dir (str) – Direction to sort. 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 hosts returned by the search using the filter provided.

Examples

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

Note

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

>>>  self.{risksenseobject}.assessments.search([{"field":"name","exclusive":False,"operator":"WILDCARD","value":"testcase_aug_test,","implicitFilters":[]}],csvdump=True)
update_assessment_status(assessment_id, status, client_id=None, csvdump=False)[source]

Update the status of the assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • status (str) – Update the status either “LOCKED” or “UNLOCKED”

  • 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 jsonified data of the status

Examples

>>> apiobj = self.{risksenseobject}.assessments.update_assessment_status(216917)

Note

You can also dump the data of the assessment that will be updated in a csv file. Just make csvdump as True:

>>>  self.{risksenseobject}.assessments.update_assessment_status(216917)
get_assessment_history(assessment_id, csvdump=False, client_id=None)[source]

Get history of assessments

Parameters:
  • assessment_id (int) – The assessment ID.

  • csvdump (bool) – Whether to dump the assessment history in a csv, true to dump and false to not dump

  • 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 jsonified data of the status

Examples

>>> apiobj = self.{risksenseobject}.assessments.get_assessment_history(216917)

Note

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

>>>  self.{risksenseobject}.assessments.get_assessment_history(216917,csvdump=True)
list_attachments(assessment_id, csvdump=False, client_id=None)[source]

Lists attachments associated with an assessment.

Parameters:
  • assessment_id (int) – The assessment ID

  • csvdump (bool) – Whether to dump the attachment data in a csv, true to dump and false to not dump

  • 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:

A list of attachments associated with the assessment is returned.

Examples

>>> apiobj = self.{risksenseobject}.assessments.list_attachments(216917)

Note

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

>>>  self.{risksenseobject}.assessments.list_attachments(216917)
get_attachment(assessment_id, attachment_uuid, filename, client_id=None)[source]

Download an attachment associated with an assessment.

Parameters:
  • assessment_id (int) – The assessment ID.

  • attachment_uuid (str) – The unique ID associated with the attachment.

  • filename (str) – The filename to be used for the downloaded file along with the file type extension.

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

Return type:

bool

Returns:

True/False indicating whether or not the operation was successful.

Examples

>>> apiobj = self.{risksenseobject}.assessments.get_attachment(216917,'123-456')
get_attachment_metadata(assessment_id, attachment_uuid, client_id=None)[source]

Get the metadata associated with an assessment’s attachment.

Parameters:
  • assessment_id (int) – The assessment ID.

  • attachment_uuid (str) – The unique ID associated with the attachment.

  • 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:

A dictionary containing the metadata for the attachment is returned.

Examples

>>> apiobj = self.{risksenseobject}.assessments.get_attachment_metadata(216917,'123-456')
edit_network_internalreport(assessment_id, conclusion, constraints, client_id=None)[source]

Edit network internal report for an assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • conclusion (str) – Conclusion statement for internal report

  • constraints (str) – Constraints statement for internal report

  • 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 data of the response

Examples

>>> apiobj = self.{risksenseobject}.assessments.edit_network_internalreport(216917,'abc','abc')
edit_application_report(assessment_id, conclusion, constraints, client_id=None)[source]

Edit application report for an assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • conclusion (str) – Conclusion statement for internal report

  • constraints (str) – Constraints statement for internal report

  • 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 data of the response

Examples

>>> apiobj = self.{risksenseobject}.assessments.edit_application_report(216917,'abc','abc')
edit_networkexternal_report(assessment_id, conclusion, constraints, client_id=None)[source]

Edit network external report for an assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • conclusion (str) – Conclusion statement for internal report

  • constraints (str) – Constraints statement for internal report

  • 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 data of the response

Examples

>>> apiobj = self.{risksenseobject}.assessments.edit_networkexternal_report(216917,'abc','abc')
lock_assessment(assessment_id, client_id=None)[source]

Lock an assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • 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 jsonified data of the status

Examples

>>> apiobj = self.{risksenseobject}.assessments.lock_assessment(216917)
unlock_assessment(assessment_id, client_id=None)[source]

Unlock an assessment

Parameters:
  • assessment_id (int) – The assessment ID.

  • 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 jsonified data of the status

Examples

>>> apiobj = self.{risksenseobject}.assessments.unlock_assessment(216917)