Applications (risksense_api.__subject.__applications.__applications
)¶
**Application module defined for different application related api endpoints.**
- class risksense_api.__subject.__applications.__applications.Applications(profile)[source]¶
Bases:
Subject
Class for Applications function defintions.
To utlise Applications function:
- Parameters:
profile – Profile Object
- Usage:
self.{risksenseobjectname}.applications.{function}
Examples
To delete application using
delete()
function>>> self.{risksenseobject}.applications.delete({applicationfilter})
- __init__(profile)[source]¶
Initialization of Applications Object .
- Parameters:
profile – Profile Object
- create(name, groupids, networkid, applicationurl, criticality, externality=False, csvdump=False, client_id=None)[source]¶
Create an application
- Parameters:
name (
str
) – Name of the application .groupids (
list
) – ids of the groups you want it to be assigned tonetworkid (
int
) – network id. Id of network the application to be a part ofapplicationurl (
str
) – url of the application.criticality (
int
) – the application criticalityexternality (
bool
) – the application whether external or internal. Externality is true if application is external , false if internalcsvdump (
bool
) – dumps the data in csvclient_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
To create an application:
>>> self.{risksenseobject}.applications.create('applicationname',[1,2,3],123,'webpagetest.org',5,False)
Note
You can also dump the job id of the created application using
csvdump=True
argument:>>> self.{risksenseobject}.applications.create('applicationname',[1,2,3],123,'webpagetest.org',5,False,csvdump=True)
- delete(filterrequest, csvdump=False, client_id=None)[source]¶
Deletes an application
- Parameters:
filterrequest (
list
) – Search filters .csvdump (
bool
) – dumps the data in csvclient_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 response.
Examples
To delete an application:
>>> self.{risksenseobject}.applications.delete([])
Note
You can also dump the application data that is going to be deleted by adding a
csvdump=True
argument:>>> self.{risksenseobject}.applications.delete([],csvdump=True)
- 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 asfilters (
dict
) – Application search filters based on which the export performsclient_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}.applications.downloadfilterinexport('applicationdata',[])
- list_application_filter_fields(client_id=None)[source]¶
Lists application filter fields.
- 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.
Example
>>> self.{risksenseobject}.applications.list_application_filter_fields()
- 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 applications based on the provided filter(s) and other parameters for a single page.
- Parameters:
search_filters (
list
) – 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.DESCclient_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.
Example
An example to get single search page of applications data
>>> self.{risksenseobject}.applications.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}.applications([],page_num=2,page_size=10)
- get_groupby_application(client_id=None)[source]¶
Get groupby keymetrics for applications
- Parameters:
client_id (
typing.Optional
[int
]) – The client id , if none, default client id is taken- Return type:
dict
- Returns:
The keymetrics for groupby
Example
>>> self.{risksenseobject}.applications.get_groupby_application()
IGNORE INTERNAL FUNCTION .. note:: This function just returns the groupby key metrics
- groupby_application(filters=[], sortorder=None, csvdump=False, client_id=None)[source]¶
Get groupby values for applications
- Parameters:
filters (
list
) – The filters which will populate in groupbysortorder (
typing.Optional
[str
]) – The order to sort the groupby values, please choose ASC for ascending and DESC for descendingcsvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.client_id (
typing.Optional
[bool
]) – The client id , if none, default client id is taken
- Return type:
dict
- Returns:
The groupby values of the application.
Example
>>> self.{risksenseobject}.applications.groupby_application({filter})
The filter must be provided for the group by to be used. The groupby fields will be displayed in the terminal and you must choose a group by filter to which the data will be populated
Note
This function also has an option to dump the data in a csv by a simple argument,
csvdump=True
>>> self.{risksenseobject}.applications.groupby_application({filter},csvdump=True)
- search(search_filters, page_size=150, sort_field='id', sort_dir='ASC', csvdump=False, client_id=None)[source]¶
Searches for and returns applications 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
) – The field to be used for sorting results returned.sort_dir (
str
) – The direction of sorting to be used. SortDirection.ASC or SortDirection.DESCcsvdump (
bool
) – dumps the data in csvclient_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 applications returned by the search using the filter provided.
- Example:
An example to search for application data is
>>> self.{risksenseobject}.applications.search([])
Note
You can also dump the search based data in a csv by simply providing
csvdump=True
argument>>> self.{risksenseobject}.applications.search([],csvdump=True)
- get_count(search_filters, client_id=None)[source]¶
Gets a count of applications identified using the provided filter(s).
- 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.
- Return type:
int
- Returns:
The number of applications identified using the filter(s).
Example
To get count of the appplications
>>> self.{risksenseobject}.applications.get_count([])
- merge_application(searchfilters, application_id_to_merge_to, csvdump=False, client_id=None)[source]¶
Merges applications based on search filters to the application id provided.
- Parameters:
searchfilters (
list
) – A list of dictionaries containing filter parameters.application_id_to_merge_to (
int
) – Application id to merge to.csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
An example to use merge_application is
>>> self.{risksenseobject}.applications.merge_application([],123)
Note
You can also dump the applications that are going to be merged before merging them by
csvdump=True
argument>>> self.{risksenseobject}.applications.merge_application([],123,csvdump=True)
- set_asset_criticality(filter, assetcriticality, csvdump=False, client_id=None)[source]¶
Set asset criticality for the application.
- Parameters:
filter (
list
) – A list of dictionaries containing filter parameters.assetcriticality (
int
) – The asset criticality to set the filter specified applications to.csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
To set asset criticality based on id
>>> self.{risksenseobject}.applications.set_asset_criticality([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"1234"}],3)
Note
You can also dump the applications to which asset criticality should be changed by
csvdump=True
argument>>> self.{risksenseobject}.applications.set_asset_criticality([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"1234"}],3,csvdump=True)
- set_address_type(filter, addresstype, csvdump=False, client_id=None)[source]¶
Set address type for the application.
- Parameters:
filter (
list
) – A list of dictionaries containing filter parameters.addresstype (
str
) – The address type whether external or internal, provide string external for external and internal for internalcsvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
To set address type based on id
>>> self.{risksenseobject}.applications.set_address_type([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"1234"}],"EXTERNAL")
Note
You can also dump the applications which the address type will be set by
csvdump=True
argument>>> self.{risksenseobject}.applications.set_address_type([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"1234"}],"EXTERNAL",csvdump=True)
- edit_application(filter, name, url, csvdump=True, client_id=None)[source]¶
Edit an application.
- Parameters:
filter (
list
) – A list of dictionaries containing filter parameters.name (
str
) – Name of the applicationurl (
str
) – Url of the applicationcsvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
To edit an application based on an id
1234
from platform>>> self.{risksenseobject}.applications.edit_application([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],name='test1',url='10.1.1.1/app')
Note
You can also dump the applications which are edited by
csvdump=True
argument>>> self.{risksenseobject}.applications.edit_application([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],name='test1',url='10.1.1.1/app',csvdump=True)
- add_tag(search_filters, tag_id, csvdump=False, client_id=None)[source]¶
Add a tag to application(s).
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.tag_id (
int
) – The tag ID to add to the application(s).csvdump (
bool
) – dumps the data in csvclient_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 is returned.
Example
To add a tag for an application id
1234
to tag123
>>> self.rs.applications.add_tag([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],123)
Note
You can also dump the applications to which tags are added post tag addition by
csvdump=True
argument>>> self.rs.applications.add_tag([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],123,csvdump=True)
- remove_tag(search_filters, tag_id, csvdump=False, client_id=None)[source]¶
Remove a tag from application(s).
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.tag_id (
int
) – The tag ID to remove from the application(s).csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
To remove a tag from an application id
1234
from tag123
>>> self.rs.applications.remove_tag([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],123)
Note
You can also dump the applications to which tags are removed before tag removal by
csvdump=True
argument>>> self.rs.applications.remove_tag([{"field":"id","exclusive":False,"operator":"IN","value":"1234"}],123,csvdump=True)
- getexporttemplate(client_id=None)[source]¶
Gets configurable export template for Applications.
- 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}.applications.getexporttemplate()
This gets all the export templates for applications
- export(search_filters, file_name, row_count='All', file_type='CSV', client_id=None)[source]¶
Initiates an export job on the platform for application(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_ALLfile_type (
str
) – File type to export. ExportFileType.CSV, ExportFileType.JSON, or ExportFileType.XLSXclient_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}.applications.export([],'testingexport')
You can change the filetype to any of the names above or even the other positional arguments as mentioned
>>> self.{risksenseobject}.applications.export([],'testingexport',filetype=ExportFileType.JSON)
- network_move(search_filters, network_id, force_merge=False, csvdump=False, client_id=None)[source]¶
Move an application to a different network.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.network_id (
int
) – The ID of the network the application should be moved to.force_merge (
bool
) – Boolean indicating whether or not a merge should be forced.csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
To move an application in id
123
to network1234
>>> self.{risksenseobject}.applications.network_move([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"123"}],1234)
Note
You can also dump the applications that are being moved by
csvdump=True
argument>>> self.{risksenseobject}.applications.network_move([{"field":"id","exclusive":False,"operator":"EXACT","orWithPrevious":False,"implicitFilters":[],"value":"123"}],1234,csvdump=True)
- run_urba(search_filters, csvdump=False, client_id=None)[source]¶
Initiates the update of remediation by assessment for application(s) specified in filter(s).
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 is returned.
Example
An example to use run_urba for an application 123 is
>>> self.{risksenseobject}.applications.run_urba([{"field":"id","exclusive":False,"operator":"IN","value":"123"}])
Note
You can also dump the applications to which urba is being run by
csvdump=True
argument>>> self.{risksenseobject}.applications.run_urba([{"field":"id","exclusive":False,"operator":"IN","value":"123"}],csvdump=True)
- add_note(search_filters, note, csvdump=False, client_id=None)[source]¶
Add a note to applications based on search filters.
- Parameters:
search_filters (
list
) – A list of dictionaries containing filter parameters.note (
str
) – A note to be added to the application(s).csvdump (
bool
) – dumps the data in csvclient_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 is returned.
Example
An example to use add_note is
>>> self.{risksenseobject}.applications.add_note([],'test')
Note
You can also dump the applications to which notes will be added post adding the note by
csvdump=True
argument>>> self.{risksenseobject}.applications.add_note([],'test',csvdump=True)
- get_model(client_id=None)[source]¶
Get available projections and models for Applications.
- Parameters:
client_id (
typing.Optional
[int
]) – Client ID- Return type:
dict
- Returns:
Application projections and models are returned.
Example
An example to use get_model is
>>> self.{risksenseobject}.applications.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 1search_filter_2 (
dict
) – Search Filter 2client_id (
typing.Optional
[int
]) – Client ID
- Return type:
list
- Returns:
Value suggestions
Example
An example to use suggest for assessment labels is
>>> self.{risksenseobject}.applications.suggest([],{"field":"assessment_labels","exclusive":False,"operator":"WILDCARD","value":"","implicitFilters":[]})
- add_group(search_filter, group_ids, csvdump=False, client_id=None)[source]¶
Add application(s) to one or more groups.
- Parameters:
search_filter (
list
) – Search filtergroup_ids (
list
) – List of Group IDs to add to application(s).csvdump (
bool
) – dumps the data in csvclient_id (
typing.Optional
[int
]) – Client ID
- Return type:
int
- Returns:
Job ID of group add job
Example
An example to use add_group is
>>> self.{risksenseobject}.applications.add_group([],[2,3,4])
Note
You can also dump the applications which will be addedd to the groups by
csvdump=True
argument>>> self.{risksenseobject}.applications.add_group([],[2,3,4],csvdump=True)
- remove_group(search_filter, group_ids, csvdump=False, client_id=None)[source]¶
Remove application(s) from one or more groups.
- Parameters:
search_filter (
list
) – Search filtergroup_ids (
list
) – List of Group IDs to add to application(s).csvdump (
bool
) – dumps the data in csvclient_id (
typing.Optional
[int
]) – Client ID
- Return type:
int
- Returns:
Job ID of group remove job
Example
An example to use remove_group is
>>> self.{risksenseobject}.applications.remove_group([],[2,3,4])
Note
You can also dump the applications which will be removed from the groups by
csvdump=True
argument>>> self.{risksenseobject}.applications.remove_group([],[2,3,4],csvdump=True)
- apply_system_filters(csvdump=False, client_id=None)[source]¶
Get data from system filters for applications.
- Parameters:
csvdump (
bool
) – csvdump is a boolean which you can make true if you want to dump the data from system filters in a csv. Keep it false if its not needed.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 data of the application findings based on the system filter chosen.
Example
An example to use apply_system_filters is
>>> self.{risksenseobject}.applications.apply_system_filters()
The system filters will be displayed in the terminal to which you must provide a key value and the data returned will reflect based on the system filter chosrn
Note
You can also dump the applications from the system filters search by
csvdump=True
argument>>> self.{risksenseobject}.applications.apply_system_filters(csvdump=True)