Tags (risksense_api.__subject.__tags.__tags)

Tags module defined for different tags related api endpoints.

class risksense_api.__subject.__tags.__tags.TagType[source]

Bases: object

TagType class and attributes

COMPLIANCE = 'COMPLIANCE'
LOCATION = 'LOCATION'
CUSTOM = 'CUSTOM'
REMEDIATION = 'REMEDIATION'
PEOPLE = 'PEOPLE'
PROJECT = 'PROJECT'
SCANNER = 'SCANNER'
CMDB = 'CMDB'
class risksense_api.__subject.__tags.__tags.Tags(profile)[source]

Bases: Subject

Class for Tags function defintions.

To utlise Tags function:

Parameters:

profile (object) – Profile Object

Usage:

self.{risksenseobjectname}.Tags.{function}

Examples

To search for tags using search() function

>>> self.{risksenseobject}.tags.search({filterobject})
__init__(profile)[source]

Initialization of Tags object.

profile: Profile Object :type profile: _profile

Parameters:

profile (object) –

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

Exports and Downloads a file based on the filters defined .

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

  • filters (list) – Tag search filters based on which the export performs

  • client_id (typing.Optional[int]) – The client id to get the data from. If not supplied, takes default client id

IGNORE INTERNAL FUNCTION

Examples

>>>  self.{risksenseobject}.tags.downloadfilterinexport('applicationfindingsdata',[])
create(tag_type, name, desc, owner, color='#648d9f', locked=False, propagate=True, csvdump=False, client_id=None)[source]

Create a new tag for the client.

Parameters:
  • tag_type (str) – Type of tag to be created.TagType.COMPLIANCE, TagType.LOCATION, TagType.CUSTOM, TagType.REMEDIATION, TagType.PEOPLE, TagType.PROJECT, TagType.SCANNER, TagType.CMDB

  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • propagate (bool) – Propagate tag to all findings?

  • csvdump (bool) – dumps the data in csv

  • client_id – Client ID. If an ID isn’t passed, will use the profile’s default Client ID.

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a tag of type people and give it a name rspackagetest and assign to user id 123

>>> self.rs.tags.create("PEOPLE",'rspackagetest','none',123)

Note

You can also dump the tag id created in a csv using csvdump=True:

>>> self.rs.tags.create("PEOPLE",'rspackagetest','none',123,csvdump=True)

For type specific tag creation , please view private functions section way below

getexporttemplate(client_id=None)[source]

Gets configurable export template for Tags.

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

Example

An example to use getexporttemplate

>>> self.{risksenseobject}.tag.getexporttemplate()

This gets all the export templates for tags

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

list

Returns:

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

Examples

>>>  self.{risksenseobject}.tags.list_tag_filter_fields()
export(search_filters, file_name, row_count='All', file_type='CSV', client_id=None)[source]

Initiates an export job on the platform for Tag(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. Available options ExportRowNumbers.ROW_10000, ExportRowNumbers.ROW_25000, ExportRowNumbers.ROW_50000, ExportRowNumbers.ROW_100000, ExportRowNumbers.ROW_ALL

  • exportable_filter – Exportable filter

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

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

Return type:

int

Returns:

The job ID in the platform from is returned.

Example

An example to use export is

>>> self.{risksenseobject}.tags.export([],'testingexport')

You can change the filetype to any of the names above or even the other positional arguments as mentioned

>>> self.{risksenseobject}.tags.export([],'testingexport',file_type=ExportFileType.JSON)
update(tag_id, tag_type, name, desc, owner, color, locked, propagate=True, csvdump=False, client_id=None)[source]

Update an existing tag.

Parameters:
  • tag_id (int) – The tag ID to be updated.

  • tag_type (str) – The type of tag.

  • name (str) – The name of the tag.

  • desc (str) – A description for the tag.

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – The color for the tag. A hex value.

  • locked (bool) – Whether or not the tag should be locked.

  • propagate (bool) – Propagate tag to all findings?

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The job ID will be returned.

Example

To update a tag id 123 of type people and give it a name rspackagetest and assign to user id 123

>>> self.rs.tags.update(123,"PEOPLE",'rspackagetest','none',123)

Note

You can also dump the tag based data in a csv using csvdump=True:

>>> self.rs.tags.update(123,"PEOPLE",'rspackagetest','none',123,csvdump=True)

For lock unlock specific tag update, please view private functions way below

delete(tag_id, force_delete=True, csvdump=False, client_id=None)[source]

Delete a tag.

Parameters:
  • tag_id (int) – Tag ID to delete.

  • force_delete (bool) – Indicates whether or not deletion should be forced.

  • csvdump (bool) – dumps the data in csv

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

Boolean reflecting the indication from the platform as to whether or not the deletion was successful.

Example

To delete a tag of id 123

>>> self.rs.tags.delete(123)

You can also dump the tag based data in a csv using csvdump=True argument:

>>> self.rs.tags.delete(269662,csvdump=True)
bulk_tag_delete(search_filters, force_delete=True, csvdump=False, client_id=None)[source]

Delete a bunch of tags.

Parameters:
  • search_filters (list) – Tag ID to delete.

  • force_delete (bool) – Indicates whether or not deletion should be forced.

  • csvdump (bool) – dumps the data in csv

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

Boolean reflecting the indication from the platform as to whether

or not the deletion was successful.

Example

To perform bulk tag delete

>>> self.rs.tags.bulk_tag_delete([])

Note

You can also dump the tags that are going to be deleted using csvdump=True argument:

>>> self.rs.tags.bulk_tag_delete([],csvdump=True)
get_history(tag_id, page_num=0, page_size=20, csvdump=False, client_id=None)[source]

Get the history for a tag.

Parameters:
  • tag_id (int) – Tag ID

  • page_num (int) – Page number to retrieve.

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

  • csvdump (bool) – dumps the data in csv

  • 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 paginated JSON response from the platform is returned.

Example

To get history of the tag 123

>>> self.rs.tags.get_history(123)

Note

You can also dump the tag history by id created in a csv using csvdump=True:

>>> self.rs.tags.get_history(123,csvdump=True)
get_single_search_page(search_filters, projection='basic', page_num=0, page_size=150, sort_field='id', sort_dir='ASC', client_id=None)[source]

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

  • projection (str) – Projection to use for query. Default is “basic”

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

A paginated JSON response from the platform is returned.

Example

An example to get single search page of tags data

>>> self.{risksenseobject}.tags.get_single_search_page([])

You can also try changing the other arguments to your liking to reflect the data as you suffice such as change page_size or page_num etc.

>>> self.{risksenseobject}.tags.get_single_search_page([],page_num=2,page_size=10)
search(search_filters, projection='basic', page_size=150, sort_field='id', sort_dir='ASC', csvdump=False, client_id=None)[source]

Searches for and returns tags 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 – Projection to be used in API request. “basic” or “detail”

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

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

  • sort_dir (int) – Direction to sort. SortDirection.ASC or SortDirection.DESC

  • csvdump (bool) – dumps the data in csv

  • 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 containing all tags returned by the search using the filter provided.

Example

An example to search for tags data is

>>> self.{risksenseobject}.tags.search([])

Note

You can also dump the search based data in a csv by simply providing csvdump=True argument

>>> self.{risksenseobject}.tags.search([],csvdump=True)
get_model(client_id=None)[source]

Get available projections and models for Tags.

Parameters:

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

Return type:

dict

Returns:

Tags projections and models are returned.

Example

An example to use get_model is

>>> self.{risksenseobject}.tags.get_model()
suggest(search_filter_1, search_filter_2, client_id=None)[source]

Suggest values for filter fields.

Parameters:
  • search_filter_1 (list) – Search Filter 1

  • search_filter_2 (dict) – Search Filter 2

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

Return type:

list

Returns:

Value suggestions

Example

To use suggest function is

>>> self.{risksenseobject}.tags.suggest([],{})
create_compliance_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new COMPLIANCE tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a compliance tag ‘testing’ to user 123

>>> self.rs.tags.create_compliance_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_compliance_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_location_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new LOCATION tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a location tag ‘testing’ to user 123

>>> self.rs.tags.create_location_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_location_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_custom_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new CUSTOM tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • csvdump (bool) – dumps the data in csv

  • locked (bool) – Reflects whether or not the tag should be locked.

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

Return type:

int

Returns:

Tag ID

Example

To create a custom tag ‘testing’ to user 123

>>> self.rs.tags.create_custom_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_custom_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_remediation_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new REMEDIATION tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

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

  • csvdump (bool) – dumps the data in csv

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a remediation tag ‘testing’ to user 123

>>> self.rs.tags.create_remediation_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_remediation_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_people_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new PEOPLE tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a people tag ‘testing’ to user 123

>>> self.rs.tags.create_people_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_people_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_project_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new PROJECT tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

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

  • csvdump (bool) – dumps the data in csv

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a project tag ‘testing’ to user 123

>>> self.rs.tags.create_project_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_project_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_scanner_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new SCANNER tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a scanner tag ‘testing’ to user 123

>>> self.rs.tags.create_scanner_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_scanner_tag('testing','something',123,"#648d9f",True,csvdump=True)
create_cmdb_tag(name, desc, owner, color='#648d9f', locked=False, csvdump=False, client_id=None)[source]

Create a new CMDB tag.

Parameters:
  • name (str) – Name of tag

  • desc (str) – Description of tag

  • owner (str) – The owner(s) of the tag, represented by user IDs, delimited by commas. Ex: “1234,567,890”

  • color (str) – Hex value of the color to be used for this tag.

  • locked (bool) – Reflects whether or not the tag should be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The new tag ID will be returned.

Example

To create a cmdb tag ‘testing’ to user 123

>>> self.rs.tags.create_cmdb_tag('testing','something',123,"#648d9f",True)

Note

You can also dump the tag id in a csv using the csvdump=True argument

>>> self.rs.tags.create_cmdb_tag('testing','something',123,"#648d9f",True,csvdump=True)
lock_tag(tag_id, csvdump=False, client_id=None)[source]

Lock an existing tag.

Parameters:
  • tag_id (int) – The tag ID to be locked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The tag ID

Example

To lock a tag id 123

>>> self.rs.tags.lock_tag(123)

Note

You can also dump the tag data in a csv after locking by simply providing csvdump=True argument

>>> self.rs.tags.lock_tag(123,csvdump=True)
unlock_tag(tag_id, csvdump=False, client_id=None)[source]

Unlock an existing tag.

Parameters:
  • tag_id (int) – The tag ID to be unlocked.

  • csvdump (bool) – dumps the data in csv

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

Return type:

int

Returns:

The tag ID

Example

To unlock a tag id 123

>>> self.rs.tags.unlock_tag(123)

Note

You can also dump the tag data in a csv after unlocking by simply providing csvdump=True argument

>>> self.rs.tags.unlock_tag(123,csvdump=True)