"""Autogenerated API"""
import requests
from argus_cli.plugin import register_command
[docs]@register_command(extending=('assets','v1','host'))
def search_host_assets_simplified(keywords: list = None, keywordField: list = None, name: list = None, hostID: list = None, serviceID: list = None, businessProcessID: list = None, customerID: list = None, ip: list = None, port: list = None, protocol: list = None, cpe: list = None, vulnID: list = None, vulnRef: list = None, includeFlag: list = None, excludeFlag: list = None, sortBy: list = None, offset: int = 0, limit: int = 25, keywordMatch: str = 'all',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Returns as set of HostAssets defined by query parameters. (PUBLIC)
:param list keywords: Search by keywords
:param list keywordField: Set field strategy for keyword search
:param list name: Search by name
:param list hostID: Search by HostAsset ID
:param list serviceID: Search by ServiceAsset ID
:param list businessProcessID: Search by BusinessProcess ID
:param list customerID: Search by customer ID
:param list ip: Search by IP range
:param list port: Search by application port
:param list protocol: Search by application protocol
:param list cpe: Search by CPE
:param list vulnID: Search by vulnerability ID
:param list vulnRef: Search by vulnerability reference
:param list includeFlag: Include certain HostAssets in the search result based on set flags
:param list excludeFlag: Exclude certain HostAssets from the search result based on set flags
:param list sortBy: Sort search result
:param int offset: Skip a number of results
:param int limit: Maximum number of returned results
:param str keywordMatch: Set match strategy for keyword search
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 841, "limit": 647, "responseCode": 200, "count": 805, "data": [{"id": "Star affect plan throughout company property they.", "ownedByUser": {"id": 217, "customerID": 28, "userName": "ncooper", "name": "Mrs. Mary Simpson MD"}, "name": "Mark Costa", "description": "Everybody sort week first thought offer argue.", "totalCvss": 56, "vulnerabilitiesCount": 931, "createdTimestamp": 290430372, "createdByUser": {"id": 123, "customerID": 256, "userName": "mary60", "name": "Sandra Cardenas"}, "lastUpdatedTimestamp": 229308672, "lastUpdatedByUser": {"id": 422, "customerID": 330, "userName": "lynnsnyder", "name": "Mark Clarke"}, "deletedTimestamp": 829094186, "deletedByUser": {"id": 32, "customerID": 694, "userName": "pbarnett", "name": "Levi Robinson"}, "flags": ["MISSING_FROM_CVM"], "properties": {"additionalProperties": "She enter nor officer rule sure leader listen."}, "firstSeenTimestamp": 423075681, "lastSeenTimestamp": 1143425246, "lastScanTimestamp": 194972342, "ipAddresses": [{"host": true, "maskBits": 478, "ipv6": false, "multicast": false, "public": true, "address": "Soldier laugh control green."}], "aliases": [{"fqdn": "Case reflect himself inside guy believe event."}], "services": [{"id": "Dinner certain teacher building camera off action.", "name": "Joshua Kirk"}], "applications": [{"id": "Sell success today surface all specific.", "name": "Elizabeth Higgins", "description": "Body music short his case television nation.", "createdTimestamp": 1447508668, "lastUpdatedTimestamp": 768433844, "deletedTimestamp": 446898952, "firstSeenTimestamp": 315556943, "lastSeenTimestamp": 1309029447, "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Main hospital anyone family here require ago."}, "cpe": "Go same three age.", "sockets": ["Themselves family over parent."]}], "vulnerabilities": [{"id": "Could prepare among parent western job.", "vulnerabilityID": "Identify surface bad as identify.", "references": ["Fly within very successful great traditional study."], "name": "David Rangel", "description": "Medical matter challenge care determine talk.", "conclusion": "Record up up take owner conference enter.", "solution": "More reflect skill lose room fire international.", "rawOutput": "East word after soon commercial ever.", "cvss": 272, "createdTimestamp": 735056444, "lastUpdatedTimestamp": 1430359039, "deletedTimestamp": 30896796, "firstSeenTimestamp": 1444676242, "lastSeenTimestamp": 1347887822, "resolutionTimestamp": 1045222323, "resolutionComment": "Service five ten anything.", "resolution": "ACCEPTED", "flags": ["DELETED_FROM_CVM"], "properties": {"additionalProperties": "Through which process sport successful."}, "severity": "critical", "socket": "Young state those."}], "operatingSystemCPE": "Whose daughter note increase."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Top notice speak form seem.", "messageTemplate": "Official southern through always budget family themselves.", "field": "Federal policy maybe remember charge court.", "parameter": {}, "timestamp": 1262639108}], "currentPage": 141, "size": 575}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if offset:
body.update({"offset": offset})
if limit:
body.update({"limit": limit})
if keywordMatch:
body.update({"keywordMatch": keywordMatch})
if keywords:
body.update({"keywords": keywords})
if keywordField:
body.update({"keywordField": keywordField})
if name:
body.update({"name": name})
if hostID:
body.update({"hostID": hostID})
if serviceID:
body.update({"serviceID": serviceID})
if businessProcessID:
body.update({"businessProcessID": businessProcessID})
if customerID:
body.update({"customerID": customerID})
if ip:
body.update({"ip": ip})
if port:
body.update({"port": port})
if protocol:
body.update({"protocol": protocol})
if cpe:
body.update({"cpe": cpe})
if vulnID:
body.update({"vulnID": vulnID})
if vulnRef:
body.update({"vulnRef": vulnRef})
if includeFlag:
body.update({"includeFlag": includeFlag})
if excludeFlag:
body.update({"excludeFlag": excludeFlag})
if sortBy:
body.update({"sortBy": sortBy})
response = get(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def add_host_asset(ownerID: int = None, customerID: int = None, name: str = None, description: str = None, properties: dict = None, operatingSystemCPE: str = None, ipAddresses: list = None, aliases: list = None, type: str = 'SERVER', source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Creates a new HostAsset. (PUBLIC)
:param int ownerID: User who owns the asset.
:param int customerID: Customer the asset belongs to.
:param str name: Name of the asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param str description: Description of the asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param dict properties: Custom user-defined properties. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param str operatingSystemCPE: CPE of the host operating system.
:param list ipAddresses: IP address(es) of the host.
:param list aliases: Aliases (domain names) of the host.
:param str type: Defines if host is a client or a server. (default SERVER)
:param str source: Source of the request. (default USER)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 265, "limit": 616, "responseCode": 200, "count": 910, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Fine those themselves pull.", "messageTemplate": "Approach upon senior stop.", "field": "Still above open address simple few could.", "parameter": {}, "timestamp": 1201734875}], "currentPage": 463, "size": 571}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if type:
body.update({"type": type})
if source:
body.update({"source": source})
if ownerID:
body.update({"ownerID": ownerID})
if customerID:
body.update({"customerID": customerID})
if name:
body.update({"name": name})
if description:
body.update({"description": description})
if properties:
body.update({"properties": properties})
if operatingSystemCPE:
body.update({"operatingSystemCPE": operatingSystemCPE})
if ipAddresses:
body.update({"ipAddresses": ipAddresses})
if aliases:
body.update({"aliases": aliases})
response = post(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def bulk_update_host_asset(assetVulnerabilityAddRequests: list = None, assetVulnerabilityUpdateRequests: list = None, assetVulnerabilityResolveRequests: list = None, assetVulnerabilityDeleteRequests: list = None, hostApplicationAddRequests: list = None, hostApplicationUpdateRequests: list = None, hostApplicationDeleteRequests: list = None, hostAssetAddRequests: list = None, hostAssetUpdateRequests: list = None, hostAssetDeleteRequests: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Performs multiple updates to HostAssets in a single transaction. (PUBLIC)
:param list assetVulnerabilityAddRequests: List of AssetVulnerabilityAddRequests.
:param list assetVulnerabilityUpdateRequests: List of AssetVulnerabilityUpdateRequests.
:param list assetVulnerabilityResolveRequests: List of AssetVulnerabilityResolveRequests.
:param list assetVulnerabilityDeleteRequests: List of AssetVulnerabilityDeleteRequests.
:param list hostApplicationAddRequests: List of HostApplicationAddRequests.
:param list hostApplicationUpdateRequests: List of HostApplicationUpdateRequests.
:param list hostApplicationDeleteRequests: List of HostApplicationDeleteRequests.
:param list hostAssetAddRequests: List of HostAssetAddRequests. Adding vulnerabilities/applications to added hosts must be done in separate transaction.
:param list hostAssetUpdateRequests: List of HostAssetUpdateRequests.
:param list hostAssetDeleteRequests: List of HostAssetDeleteRequests.
:param str source: Source of the request. (default USER)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 167, "limit": 687, "responseCode": 200, "count": 180, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Already character response present shake easy daughter break.", "messageTemplate": "Notice notice parent first seat determine.", "field": "Phone example each lot son anything product.", "parameter": {}, "timestamp": 1169025703}], "currentPage": 158, "size": 968}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if source:
body.update({"source": source})
if assetVulnerabilityAddRequests:
body.update({"assetVulnerabilityAddRequests": assetVulnerabilityAddRequests})
if assetVulnerabilityUpdateRequests:
body.update({"assetVulnerabilityUpdateRequests": assetVulnerabilityUpdateRequests})
if assetVulnerabilityResolveRequests:
body.update({"assetVulnerabilityResolveRequests": assetVulnerabilityResolveRequests})
if assetVulnerabilityDeleteRequests:
body.update({"assetVulnerabilityDeleteRequests": assetVulnerabilityDeleteRequests})
if hostApplicationAddRequests:
body.update({"hostApplicationAddRequests": hostApplicationAddRequests})
if hostApplicationUpdateRequests:
body.update({"hostApplicationUpdateRequests": hostApplicationUpdateRequests})
if hostApplicationDeleteRequests:
body.update({"hostApplicationDeleteRequests": hostApplicationDeleteRequests})
if hostAssetAddRequests:
body.update({"hostAssetAddRequests": hostAssetAddRequests})
if hostAssetUpdateRequests:
body.update({"hostAssetUpdateRequests": hostAssetUpdateRequests})
if hostAssetDeleteRequests:
body.update({"hostAssetDeleteRequests": hostAssetDeleteRequests})
response = put(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def search_host_assets(limit: int = None, offset: int = None, subCriteria: list = None, customerID: list = None, name: list = None, startTimestamp: int = None, endTimestamp: int = None, keywords: list = None, keywordMatchStrategy: str = None, timeMatchStrategy: str = None, hostID: list = None, serviceID: list = None, businessProcessID: list = None, ipRange: list = None, applicationPort: list = None, applicationProtocol: list = None, cpe: list = None, hostCPE: list = None, applicationCPE: list = None, ownerID: list = None, criticality: list = None, minimumTotalCvss: int = None, maximumTotalCvss: int = None, vulnerabilityReference: list = None, vulnerabilityID: list = None, applicationRole: list = None, type: str = None, timeFieldStrategy: list = None, keywordFieldStrategy: list = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False', includeVulnerabilityRawOutput: bool = 'False', includeVulnerabilityConclusion: bool = 'False', includeVulnerabilitySolution: bool = 'False', includeVulnerabilities: bool = 'False', includeApplications: bool = 'False', includeServices: bool = 'False', connectedToService: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Returns a set of HostAssets defined by a HostAssetSearchCriteria. (PUBLIC)
:param int limit: Set this value to set max number of results. By default, no restriction on result set size.
:param int offset: Set this value to skip the first (offset) objects. By default, return result from first object.
:param list subCriteria:
:param list customerID: Restrict search to data belonging to specified customers.
:param list name: Restrict search to specific asset name
:param int startTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (start timestamp).
:param int endTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (end timestamp).
:param list keywords: Search for keywords.
:param str keywordMatchStrategy: Defines the MatchStrategy for keywords (default match all keywords).
:param str timeMatchStrategy: Defines how strict to match against different timestamps (all/any) using start and end timestamp (default any)
:param list hostID: Restrict search to specific host UUIDs.
:param list serviceID: Restrict search to specific service UUIDs.
:param list businessProcessID: Restrict search to specific business process UUIDs.
:param list ipRange: Restrict search to entities related to these IP-addresses (may specify single IPs, IP networks or IP ranges.
:param list applicationPort: Restrict to applications listening on specific ports.
:param list applicationProtocol: Restrict to applications by transport protocol name.
:param list cpe: Restrict to applications or hosts by CPE.
:param list hostCPE: Restrict to hosts by CPE.
:param list applicationCPE: Restrict to applications by CPE.
:param list ownerID: Restrict search to specific ownerIDs
:param list criticality: Restrict search to a range of criticality levels (add multiple CriticalitySearch objects to specify OR criteria).
:param int minimumTotalCvss: Restrict search to a minimum total CVSS score.
:param int maximumTotalCvss: Restrict search to a maximum total CVSS score.
:param list vulnerabilityReference: Restrict to vulnerabilities identified by vulnerability reference.
:param list vulnerabilityID: Restrict to vulnerabilities identified by vulnerability ID.
:param list applicationRole: Restrict to applications with specific roles (list of role IDs).
:param str type: Restrict search to a specific type of host (client or server).
:param list timeFieldStrategy: Defines which timestamps will be included in the search (default lastUpdatedTimestamp on host).
:param list keywordFieldStrategy: Defines which fields will be searched by keywords (default all supported fields).
:param list sortBy: List of properties to sort by (prefix with "-" to sort descending).
:param list includeFlags: Only include objects which have includeFlags set.
:param list excludeFlags: Exclude objects which have excludeFlags set.
:param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects.
:param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded.
:param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria).
:param bool includeVulnerabilityRawOutput: Include vulnerability rawOutput in result (default false).
:param bool includeVulnerabilityConclusion: Include vulnerability conclusion in result (default false).
:param bool includeVulnerabilitySolution: Include vulnerability solution in result (default false).
:param bool includeVulnerabilities: Include host vulnerabilities in result (default false).
:param bool includeApplications: Include host applications in result (default false).
:param bool includeServices: Include related services in result (default false).
:param bool connectedToService: If true, only return hosts connected to service(s). If false, return hosts not connected to any service. If not set, do not filter.
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 198, "limit": 940, "responseCode": 200, "count": 211, "data": [{"id": "Tend money able second nor rule forward.", "ownedByUser": {"id": 139, "customerID": 622, "userName": "kylemorgan", "name": "Matthew Taylor"}, "name": "Jeffrey Bennett", "description": "Their know knowledge indeed road rise.", "totalCvss": 708, "vulnerabilitiesCount": 457, "createdTimestamp": 61015847, "createdByUser": {"id": 271, "customerID": 32, "userName": "jason95", "name": "Mary Beltran"}, "lastUpdatedTimestamp": 1092044753, "lastUpdatedByUser": {"id": 151, "customerID": 148, "userName": "andrew04", "name": "Andrew Meadows Jr."}, "deletedTimestamp": 162626303, "deletedByUser": {"id": 550, "customerID": 282, "userName": "xperez", "name": "Eric Campbell"}, "flags": ["HAS_CRITICAL_VULN"], "properties": {"additionalProperties": "International sport team member analysis tell."}, "firstSeenTimestamp": 568100759, "lastSeenTimestamp": 1276880961, "lastScanTimestamp": 1385297650, "ipAddresses": [{"host": false, "maskBits": 863, "ipv6": false, "multicast": true, "public": false, "address": "Environmental involve save sound but."}], "aliases": [{"fqdn": "Follow hour long usually task."}], "services": [{"id": "Throw imagine cause two exactly movement.", "name": "William Schmidt MD"}], "applications": [{"id": "Ok left election consumer trade baby add.", "name": "Melissa Moore", "description": "Or different tend.", "createdTimestamp": 1431935484, "lastUpdatedTimestamp": 8046609, "deletedTimestamp": 1269105144, "firstSeenTimestamp": 547820373, "lastSeenTimestamp": 39114406, "flags": ["DETECTED_BY_CVM"], "properties": {"additionalProperties": "Wife before push material dog education stock."}, "cpe": "Simply method black information rest teach.", "sockets": ["Much office whom hospital present."]}], "vulnerabilities": [{"id": "Matter tree under.", "vulnerabilityID": "Of decision public including radio red.", "references": ["Sound entire memory morning property where."], "name": "Gail Boone", "description": "Why term as marriage industry guess.", "conclusion": "Head property only west discover them explain.", "solution": "Forward crime your mind piece.", "rawOutput": "Every example check if.", "cvss": 341, "createdTimestamp": 1479129802, "lastUpdatedTimestamp": 1349061627, "deletedTimestamp": 1177382495, "firstSeenTimestamp": 433408019, "lastSeenTimestamp": 300980805, "resolutionTimestamp": 547649331, "resolutionComment": "Black respond think prove.", "resolution": "UNRESOLVED", "flags": ["UPDATED_BY_CVM"], "properties": {"additionalProperties": "Floor myself section charge rather he."}, "severity": "critical", "socket": "Minute method lawyer happy data use read."}], "operatingSystemCPE": "Paper night by term skill available attorney."}], "metaData": {"additionalProperties": {}}, "messages": [{"message": "Week stand receive detail total data talk.", "messageTemplate": "Like note must base maintain put rock.", "field": "Truth loss billion hotel best.", "parameter": {}, "timestamp": 955336348}], "currentPage": 950, "size": 210}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/search".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if limit:
body.update({"limit": limit})
if offset:
body.update({"offset": offset})
if includeDeleted:
body.update({"includeDeleted": includeDeleted})
if subCriteria:
body.update({"subCriteria": subCriteria})
if exclude:
body.update({"exclude": exclude})
if required:
body.update({"required": required})
if customerID:
body.update({"customerID": customerID})
if name:
body.update({"name": name})
if startTimestamp:
body.update({"startTimestamp": startTimestamp})
if endTimestamp:
body.update({"endTimestamp": endTimestamp})
if keywords:
body.update({"keywords": keywords})
if keywordMatchStrategy:
body.update({"keywordMatchStrategy": keywordMatchStrategy})
if timeMatchStrategy:
body.update({"timeMatchStrategy": timeMatchStrategy})
if hostID:
body.update({"hostID": hostID})
if serviceID:
body.update({"serviceID": serviceID})
if businessProcessID:
body.update({"businessProcessID": businessProcessID})
if ipRange:
body.update({"ipRange": ipRange})
if applicationPort:
body.update({"applicationPort": applicationPort})
if applicationProtocol:
body.update({"applicationProtocol": applicationProtocol})
if cpe:
body.update({"cpe": cpe})
if hostCPE:
body.update({"hostCPE": hostCPE})
if applicationCPE:
body.update({"applicationCPE": applicationCPE})
if ownerID:
body.update({"ownerID": ownerID})
if criticality:
body.update({"criticality": criticality})
if minimumTotalCvss:
body.update({"minimumTotalCvss": minimumTotalCvss})
if maximumTotalCvss:
body.update({"maximumTotalCvss": maximumTotalCvss})
if vulnerabilityReference:
body.update({"vulnerabilityReference": vulnerabilityReference})
if vulnerabilityID:
body.update({"vulnerabilityID": vulnerabilityID})
if applicationRole:
body.update({"applicationRole": applicationRole})
if type:
body.update({"type": type})
if timeFieldStrategy:
body.update({"timeFieldStrategy": timeFieldStrategy})
if keywordFieldStrategy:
body.update({"keywordFieldStrategy": keywordFieldStrategy})
if includeVulnerabilityRawOutput:
body.update({"includeVulnerabilityRawOutput": includeVulnerabilityRawOutput})
if includeVulnerabilityConclusion:
body.update({"includeVulnerabilityConclusion": includeVulnerabilityConclusion})
if includeVulnerabilitySolution:
body.update({"includeVulnerabilitySolution": includeVulnerabilitySolution})
if includeVulnerabilities:
body.update({"includeVulnerabilities": includeVulnerabilities})
if includeApplications:
body.update({"includeApplications": includeApplications})
if includeServices:
body.update({"includeServices": includeServices})
if connectedToService:
body.update({"connectedToService": connectedToService})
if sortBy:
body.update({"sortBy": sortBy})
if includeFlags:
body.update({"includeFlags": includeFlags})
if excludeFlags:
body.update({"excludeFlags": excludeFlags})
response = post(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def search_host_asset_statistics(limit: int = None, offset: int = None, subCriteria: list = None, customerID: list = None, name: list = None, startTimestamp: int = None, endTimestamp: int = None, keywords: list = None, keywordMatchStrategy: str = None, timeMatchStrategy: str = None, hostID: list = None, serviceID: list = None, businessProcessID: list = None, ipRange: list = None, applicationPort: list = None, applicationProtocol: list = None, cpe: list = None, hostCPE: list = None, applicationCPE: list = None, ownerID: list = None, criticality: list = None, minimumTotalCvss: int = None, maximumTotalCvss: int = None, vulnerabilityReference: list = None, vulnerabilityID: list = None, applicationRole: list = None, type: str = None, timeFieldStrategy: list = None, keywordFieldStrategy: list = None, groupBy: list = None, values: list = None, resolution: int = None, cutoff: int = None, cutoffValue: str = None, sortBy: list = None, includeFlags: list = None, excludeFlags: list = None, includeDeleted: bool = 'False', exclude: bool = 'False', required: bool = 'False', includeVulnerabilityRawOutput: bool = 'False', includeVulnerabilityConclusion: bool = 'False', includeVulnerabilitySolution: bool = 'False', includeVulnerabilities: bool = 'False', includeApplications: bool = 'False', includeServices: bool = 'False', connectedToService: bool = 'False', includeOthers: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Fetch host asset statistics base on criteria (DEV)
:param int limit: Set this value to set max number of results. By default, no restriction on result set size.
:param int offset: Set this value to skip the first (offset) objects. By default, return result from first object.
:param list subCriteria:
:param list customerID: Restrict search to data belonging to specified customers.
:param list name: Restrict search to specific asset name
:param int startTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (start timestamp).
:param int endTimestamp: Restrict search to a time frame based on the set TimeFieldStrategy (end timestamp).
:param list keywords: Search for keywords.
:param str keywordMatchStrategy: Defines the MatchStrategy for keywords (default match all keywords).
:param str timeMatchStrategy: Defines how strict to match against different timestamps (all/any) using start and end timestamp (default any)
:param list hostID: Restrict search to specific host UUIDs.
:param list serviceID: Restrict search to specific service UUIDs.
:param list businessProcessID: Restrict search to specific business process UUIDs.
:param list ipRange: Restrict search to entities related to these IP-addresses (may specify single IPs, IP networks or IP ranges.
:param list applicationPort: Restrict to applications listening on specific ports.
:param list applicationProtocol: Restrict to applications by transport protocol name.
:param list cpe: Restrict to applications or hosts by CPE.
:param list hostCPE: Restrict to hosts by CPE.
:param list applicationCPE: Restrict to applications by CPE.
:param list ownerID: Restrict search to specific ownerIDs
:param list criticality: Restrict search to a range of criticality levels (add multiple CriticalitySearch objects to specify OR criteria).
:param int minimumTotalCvss: Restrict search to a minimum total CVSS score.
:param int maximumTotalCvss: Restrict search to a maximum total CVSS score.
:param list vulnerabilityReference: Restrict to vulnerabilities identified by vulnerability reference.
:param list vulnerabilityID: Restrict to vulnerabilities identified by vulnerability ID.
:param list applicationRole: Restrict to applications with specific roles (list of role IDs).
:param str type: Restrict search to a specific type of host (client or server).
:param list timeFieldStrategy: Defines which timestamps will be included in the search (default lastUpdatedTimestamp on host).
:param list keywordFieldStrategy: Defines which fields will be searched by keywords (default all supported fields).
:param list groupBy: Specify which fields will be grouped by in stats
:param list values: Specify which values will be included in stats (default hosts)
:param int resolution: Stats resolution period in milliseconds, if is 0 means to generate non-timeline statistics
:param int cutoff: Reduce stats keys to the cutoff amount of keys that has largest hit count, default 0 means no reduce
:param str cutoffValue: Specify which value to be cutoff on (default hosts)
:param list sortBy: List of properties to sort by (prefix with "-" to sort descending).
:param list includeFlags: Only include objects which have includeFlags set.
:param list excludeFlags: Exclude objects which have excludeFlags set.
:param bool includeDeleted: Set to true to include deleted objects. By default, exclude deleted objects.
:param bool exclude: Only relevant for subcriteria. If set to true, objects matching this subcriteria object will be excluded.
:param bool required: Only relevant for subcriteria. If set to true, objects matching this subcriteria are required (AND-ed together with parent criteria).
:param bool includeVulnerabilityRawOutput: Include vulnerability rawOutput in result (default false).
:param bool includeVulnerabilityConclusion: Include vulnerability conclusion in result (default false).
:param bool includeVulnerabilitySolution: Include vulnerability solution in result (default false).
:param bool includeVulnerabilities: Include host vulnerabilities in result (default false).
:param bool includeApplications: Include host applications in result (default false).
:param bool includeServices: Include related services in result (default false).
:param bool connectedToService: If true, only return hosts connected to service(s). If false, return hosts not connected to any service. If not set, do not filter.
:param bool includeOthers: If reduce (cutoff>0), true means remaining keys (other than cutoff keys) are collected into an "other" key, default false
:raises AuthenticationFailedException: on 401
:raises ValidationFailedException: on 412
:raises AccessDeniedException: on 403
:returns: {"offset": 435, "limit": 27, "responseCode": 200, "count": 348, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Always office voice necessary continue mind owner.", "messageTemplate": "Purpose property first spring day head popular leg.", "field": "South sort real with own choice.", "parameter": {}, "timestamp": 1350778850}], "currentPage": 663, "size": 667}
"""
from requests import post
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/statistics".format()
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if limit:
body.update({"limit": limit})
if offset:
body.update({"offset": offset})
if includeDeleted:
body.update({"includeDeleted": includeDeleted})
if subCriteria:
body.update({"subCriteria": subCriteria})
if exclude:
body.update({"exclude": exclude})
if required:
body.update({"required": required})
if customerID:
body.update({"customerID": customerID})
if name:
body.update({"name": name})
if startTimestamp:
body.update({"startTimestamp": startTimestamp})
if endTimestamp:
body.update({"endTimestamp": endTimestamp})
if keywords:
body.update({"keywords": keywords})
if keywordMatchStrategy:
body.update({"keywordMatchStrategy": keywordMatchStrategy})
if timeMatchStrategy:
body.update({"timeMatchStrategy": timeMatchStrategy})
if hostID:
body.update({"hostID": hostID})
if serviceID:
body.update({"serviceID": serviceID})
if businessProcessID:
body.update({"businessProcessID": businessProcessID})
if ipRange:
body.update({"ipRange": ipRange})
if applicationPort:
body.update({"applicationPort": applicationPort})
if applicationProtocol:
body.update({"applicationProtocol": applicationProtocol})
if cpe:
body.update({"cpe": cpe})
if hostCPE:
body.update({"hostCPE": hostCPE})
if applicationCPE:
body.update({"applicationCPE": applicationCPE})
if ownerID:
body.update({"ownerID": ownerID})
if criticality:
body.update({"criticality": criticality})
if minimumTotalCvss:
body.update({"minimumTotalCvss": minimumTotalCvss})
if maximumTotalCvss:
body.update({"maximumTotalCvss": maximumTotalCvss})
if vulnerabilityReference:
body.update({"vulnerabilityReference": vulnerabilityReference})
if vulnerabilityID:
body.update({"vulnerabilityID": vulnerabilityID})
if applicationRole:
body.update({"applicationRole": applicationRole})
if type:
body.update({"type": type})
if timeFieldStrategy:
body.update({"timeFieldStrategy": timeFieldStrategy})
if keywordFieldStrategy:
body.update({"keywordFieldStrategy": keywordFieldStrategy})
if includeVulnerabilityRawOutput:
body.update({"includeVulnerabilityRawOutput": includeVulnerabilityRawOutput})
if includeVulnerabilityConclusion:
body.update({"includeVulnerabilityConclusion": includeVulnerabilityConclusion})
if includeVulnerabilitySolution:
body.update({"includeVulnerabilitySolution": includeVulnerabilitySolution})
if includeVulnerabilities:
body.update({"includeVulnerabilities": includeVulnerabilities})
if includeApplications:
body.update({"includeApplications": includeApplications})
if includeServices:
body.update({"includeServices": includeServices})
if connectedToService:
body.update({"connectedToService": connectedToService})
if groupBy:
body.update({"groupBy": groupBy})
if values:
body.update({"values": values})
if resolution:
body.update({"resolution": resolution})
if cutoff:
body.update({"cutoff": cutoff})
if cutoffValue:
body.update({"cutoffValue": cutoffValue})
if includeOthers:
body.update({"includeOthers": includeOthers})
if sortBy:
body.update({"sortBy": sortBy})
if includeFlags:
body.update({"includeFlags": includeFlags})
if excludeFlags:
body.update({"excludeFlags": excludeFlags})
response = post(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def get_host_asset(id: str,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Returns a HostAsset identified by its ID. (PUBLIC)
:param str id: HostAsset ID
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 962, "limit": 214, "responseCode": 200, "count": 767, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Open health question.", "messageTemplate": "Dream red citizen certain.", "field": "Perform than movie loss score floor everything behind.", "parameter": {}, "timestamp": 1448827563}], "currentPage": 41, "size": 178}
"""
from requests import get
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/{id}".format(id=id)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
response = get(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def update_host_asset(id: str, ownerID: int = None, name: str = None, description: str = None, addProperties: dict = None, deleteProperties: list = None, type: str = None, operatingSystemCPE: str = None, addIpAddresses: list = None, deleteIpAddresses: list = None, addAliases: list = None, deleteAliases: list = None, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Updates an existing HostAsset. (PUBLIC)
:param str id: HostAsset ID
:param int ownerID: Change user who owns the asset.
:param str name: Change name of asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param str description: Change description of asset. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param dict addProperties: Add custom properties (updates a property if key already exists). => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param list deleteProperties: Delete custom properties by key.
:param str type: Change type of host (client or server).
:param str operatingSystemCPE: Change CPE of host.
:param list addIpAddresses: Add IP address(es) to host.
:param list deleteIpAddresses: Delete IP address(es) from host.
:param list addAliases: Add alias(es) (domain names) to host.
:param list deleteAliases: Delete alias(es) from host.
:param str source: Source of the request. (default USER)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 749, "limit": 766, "responseCode": 200, "count": 905, "metaData": {"additionalProperties": {}}, "messages": [{"message": "In still summer.", "messageTemplate": "Else couple unit parent listen family.", "field": "Sea tonight girl line.", "parameter": {}, "timestamp": 586769306}], "currentPage": 168, "size": 552}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/{id}".format(id=id)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if source:
body.update({"source": source})
if ownerID:
body.update({"ownerID": ownerID})
if name:
body.update({"name": name})
if description:
body.update({"description": description})
if addProperties:
body.update({"addProperties": addProperties})
if deleteProperties:
body.update({"deleteProperties": deleteProperties})
if type:
body.update({"type": type})
if operatingSystemCPE:
body.update({"operatingSystemCPE": operatingSystemCPE})
if addIpAddresses:
body.update({"addIpAddresses": addIpAddresses})
if deleteIpAddresses:
body.update({"deleteIpAddresses": deleteIpAddresses})
if addAliases:
body.update({"addAliases": addAliases})
if deleteAliases:
body.update({"deleteAliases": deleteAliases})
response = put(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def delete_host_asset(id: str, source: str = 'USER',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Marks a HostAsset as deleted. (PUBLIC)
:param str id: HostAsset ID
:param str source: Request source (default USER)
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 257, "limit": 416, "responseCode": 200, "count": 317, "metaData": {"additionalProperties": {}}, "messages": [{"message": "West rate away production.", "messageTemplate": "Player network catch fire start lot.", "field": "Case group white drug.", "parameter": {}, "timestamp": 1292084013}], "currentPage": 986, "size": 342}
"""
from requests import delete
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/{id}".format(id=id)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if source:
body.update({"source": source})
response = delete(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response
[docs]@register_command(extending=('assets','v1','host'))
def merge_host_asset(mergeIntoID: str, mergeFromID: list = None, ownerID: int = None, name: str = None, description: str = None, type: str = None, operatingSystemCPE: str = None, mergeApplications: bool = 'False', mergeVulnerabilities: bool = 'False',json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
"""Merges multiple HostAssets into one. (DEV)
This operation takes multiple HostAssets (merge from) and merges them into another existing HostAsset (merge into). Thereby collection fields from all HostAssets are combined by calculating their union. Conflicts between single value fields can be resolved manually by explicitly specifying the values to use in the request. By default the values from the merge into HostAsset will be retained. When 'mergeApplications' or 'mergeVulnerabilities' are set in the request applications and vulnerabilities are merged as well, i.e. all applications and vulnerabilities from all HostAssets will be present in the merge result. But duplicated applications and vulnerabilities will be omitted.
:param str mergeIntoID: ID of HostAsset to merge into. This HostAsset is kept and contains the merge result.
:param list mergeFromID: Merge from hosts identified by their IDs.
:param int ownerID: Set owner of merged host. Keeps owner of merge into host if not provided.
:param str name: Set name of merged host. Keeps name of merge into host if not provided. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param str description: Set description of merged host. Keeps description of merge into host if not provided. => [\s\w\{\}\$\-\(\)\.\[\]"\'_/\\,\*\+\#:@!?;]*
:param str type: Set type of merged host. Keeps type of merge into host if not provided.
:param str operatingSystemCPE: Set operating system CPE of merged host. Keeps CPE of merge into host if not provided.
:param bool mergeApplications: If set to true also merge applications (defaults to false).
:param bool mergeVulnerabilities: If set to true also merge vulnerabilities (defaults to false).
:raises AuthenticationFailedException: on 401
:raises ValidationErrorException: on 412
:raises AccessDeniedException: on 403
:raises ObjectNotFoundException: on 404
:returns: {"offset": 542, "limit": 11, "responseCode": 200, "count": 77, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Car sure culture time.", "messageTemplate": "Ready federal you.", "field": "President great after all number leave foot which.", "parameter": {}, "timestamp": 22606456}], "currentPage": 172, "size": 300}
"""
from requests import put
from argus_api.exceptions import http
url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/host/{mergeIntoID}/merge".format(mergeIntoID=mergeIntoID)
headers = {
'Content-Type': 'application/json',
'User-Agent': 'ArgusToolbelt/1.0'
}
if apiKey:
headers["Argus-API-Key"] = apiKey
elif authentication and isinstance(authentication, dict):
headers.update(authentication)
elif callable(authentication):
headers.update(authentication(url))
body = {}
if mergeFromID:
body.update({"mergeFromID": mergeFromID})
if ownerID:
body.update({"ownerID": ownerID})
if name:
body.update({"name": name})
if description:
body.update({"description": description})
if type:
body.update({"type": type})
if mergeApplications:
body.update({"mergeApplications": mergeApplications})
if mergeVulnerabilities:
body.update({"mergeVulnerabilities": mergeVulnerabilities})
if operatingSystemCPE:
body.update({"operatingSystemCPE": operatingSystemCPE})
response = put(url, json=body if body else None, verify=verify, headers=headers)
errors = []
if response.status_code == 401:
raise http.AuthenticationFailedException(response)
elif response.status_code == 403:
raise http.AccessDeniedException(response)
elif response.status_code == 412:
raise http.ValidationErrorException(response)
elif response.status_code == 404:
raise http.ObjectNotFoundException(response)
return response.json() if json else response