api.assets.v1.scan — Argus-Toolbelt 1.0 documentation

# Source code for api.assets.v1.scan

    """Autogenerated API"""
    import requests
    from argus_cli.plugin import register_command

    @register_command(extending=('assets','v1','scan'))
    def host_asset_bulk_scanned(customerID: int = None, scannedRequests: list = None, scannedIpRanges: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Marks multiple HostAsset as scanned. (PUBLIC)

        :param int customerID: Define customer which was scanned.
        :param list scannedRequests: Set of host scan requests.
        :param list scannedIpRanges: Set of scanned IP address ranges as list of single IPs (1.1.1.1), CIDR networks (1.1.1.0/24) or ranges (1.1.1.1-1.1.1.2)
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 530, "limit": 84, "responseCode": 200, "count": 367, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Protect rule leave sell itself out.", "messageTemplate": "Ball laugh mother task spring.", "field": "Population soon author consumer.", "parameter": {}, "timestamp": 883500667}], "currentPage": 640, "size": 307}
        """
        from requests import post
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/scan".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 customerID:
            body.update({"customerID": customerID})

        if scannedRequests:
            body.update({"scannedRequests": scannedRequests})

        if scannedIpRanges:
            body.update({"scannedIpRanges": scannedIpRanges})

        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

    @register_command(extending=('assets','v1','scan'))
    def host_asset_scanned(customerID: int, ip: str, detectedVulnerabilities: list = None, detectedApplications: list = None,json: bool = True, verify: bool = True, apiKey: str = "", authentication: dict = {}) -> dict:
        """Marks a single HostAsset as scanned. (PUBLIC)

        :param int customerID: Customer ID
        :param str ip: IP address of scanned HostAsset
        :param list detectedVulnerabilities: Specify (vulnerabilityID, socket string) objects of detected vulnerabilities.
        :param list detectedApplications: Specify sockets of detected applications (e.g. tcp/80).
        :raises AuthenticationFailedException: on 401
        :raises ValidationErrorException: on 412
        :raises AccessDeniedException: on 403
        :raises ObjectNotFoundException: on 404
        :returns: {"offset": 167, "limit": 42, "responseCode": 200, "count": 453, "metaData": {"additionalProperties": {}}, "messages": [{"message": "Available once machine just.", "messageTemplate": "Form top camera fish usually.", "field": "Require husband ever ok everyone American.", "parameter": {}, "timestamp": 1248221392}], "currentPage": 748, "size": 159}
        """
        from requests import put
        from argus_api.exceptions import http

        url = "https://osl-argus-trunk-web1.mnemonic.no/web/api/assets/v1/scan/{customerID}/{ip}".format(customerID=customerID, ip=ip)
        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 detectedVulnerabilities:
            body.update({"detectedVulnerabilities": detectedVulnerabilities})

        if detectedApplications:
            body.update({"detectedApplications": detectedApplications})

        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