def list_all(self, **kwargs):
        """Returns a list of all servers.

        This query is limited to 50 pages of 10 items,
        totaling 500 servers.

        Default filter returns only servers in the 'active' state.

        Keyword Args:
            state (list or str): A list or comma-separated string containing \
            any of these: active, missing, deactivated
            platform (list or str): A list or comma-separated string \
            containing any of these: \
            windows, debian, ubuntu, centos, oracle, rhel, etc...
            cve (str): CVE ID.  Example: CVE-2015-1234
            kb (str): Search for presence of KB.  Example: kb="KB2485376"
            missing_kb (str): Search for absence of KB.  \
            Example: mising_kb="KB2485376"

        Returns:
            list: List of dictionary objects describing servers

        """

        endpoint = "/v1/servers"
        key = "servers"
        max_pages = 50
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint, key,
                                         max_pages, params=params)
        return response
Esempio n. 2
0
    def list_all(self, **kwargs):
        """Returns a list of all servers.

        This query is limited to 50 pages of 100 items,
        totaling 500 servers.

        Default filter returns only servers in the 'active' state.

        Keyword Args:
            state (list or str): A list or comma-separated string containing \
            any of these: active, missing, deactivated
            platform (list or str): A list or comma-separated string \
            containing any of these: \
            windows, debian, ubuntu, centos, oracle, rhel, etc...
            cve (str): CVE ID.  Example: CVE-2015-1234
            kb (str): Search for presence of KB.  Example: kb="KB2485376"
            missing_kb (str): Search for absence of KB.  \
            Example: mising_kb="KB2485376"

        Returns:
            list: List of dictionary objects describing servers

        """

        endpoint = "/v1/servers?per_page=100"
        key = "servers"
        max_pages = 300
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint,
                                         key,
                                         max_pages,
                                         params=params)
        return response
Esempio n. 3
0
    def list_all(self, **kwargs):
        """This method retrieves all local user accounts

        Keyword Args:
            os_type (list or str): A list of local user accounts \
            with the according os type.
            username (list or str): A list of local user accounts \
            with the according username.
            admin (boolean): A list of local user accounts \
            with the according admin.
            active (boolean): A list of local user accounts \
            with the according active settings.
            last_login_at (str): A list of local user accounts \
            last login at date in iso8601 format such as: 2017-01-01.
            never_logged_in (boolean): A list of local user accounts \
            with never logged in.
            password_required (boolean): A list of local user accounts \
            with the according password_required settings
            password_expired (boolean): A list of local user accounts \
            with the according password_expired settings
            comment:  A list of local user accounrs with the according comment
            group_id (list or str): A list of local user accounts \
            with the according group id
            server_id (list or str): A list of local user accounts \
            with the according server id
            server_name (list or str): A list of local user accounts \
            with the according server name
            server_label (list or str): A list of local user accounts \
            with the according server label
            group_name (list or str): A list of local user accounts \
            with the according group name
            locked (boolean): A list of local user accounts \
            with the according locked settings
            gid (list or str): A list of local user accounts \
            with the according gid
            sid (list or str): A list of local user accounts \
            with the according sid

        Returns:
            list: List of dictionary objects describing local user accounts

        """
        endpoint = "/v1/local_accounts"
        key = "accounts"
        max_pages = 50
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint,
                                         key,
                                         max_pages,
                                         params=params)
        return response
    def list_all(self):
        """Lists all policies of this type.

        Returns:
            list: List of policies (represented as dictionary-type objects)

        Note:
            This query is limited to 30 pages.

        """

        request = HttpHelper(self.session)
        return request.get_paginated(self.endpoint(), self.pagination_key(),
                                     self.max_pages)
Esempio n. 5
0
    def list_all(self, fim_policy_id):
        """Returns a list of all baselines for the indicated FIM policy

        Args:
            fim_policy_id (str): ID of fim policy

        Returns:
            list: List of all baselines for the given policy

        """

        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines" % fim_policy_id
        key = "baselines"
        max_pages = 30
        response = request.get_paginated(endpoint, key, max_pages)
        return response
    def list_all(self, fim_policy_id):
        """Returns a list of all baselines for the indicated FIM policy

        Args:
            fim_policy_id (str): ID of fim policy

        Returns:
            list: List of all baselines for the given policy

        """

        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines" % fim_policy_id
        key = "baselines"
        max_pages = 30
        response = request.get_paginated(endpoint, key, max_pages)
        return response
    def list_all(self):
        """Returns a list of all groups for an account

        This is represented as a list of dictionaries

        This will only return a maximum of 20 pages, which amounts to
        200 groups.  If you have more than that, you should consider
        using the SDK within a multi-threaded application so you don't
        spend the rest of your life waiting on a list of groups.
        """

        session = self.session
        max_pages = 20
        key = "groups"
        endpoint = "/v1/groups"
        request = HttpHelper(session)
        groups = request.get_paginated(endpoint, key, max_pages)
        return groups
    def list_all(self):
        """Returns a list of all groups for an account

        This is represented as a list of dictionaries

        This will only return a maximum of 20 pages, which amounts to
        200 groups.  If you have more than that, you should consider
        using the SDK within a multi-threaded application so you don't
        spend the rest of your life waiting on a list of groups.
        """

        session = self.session
        max_pages = 20
        key = "groups"
        endpoint = "/v1/groups"
        request = HttpHelper(session)
        groups = request.get_paginated(endpoint, key, max_pages)
        return groups
Esempio n. 9
0
    def get_firewall_logs(self, server_id, pages):
        """This method retrieves the detail of a server firewall log.

        Args:
            server_id (str): ID of server

        Returns:
            list: firewall log of the server
        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s/firewall_logs" % server_id
        key = "agent_firewall_logs"
        max_pages = pages

        request = HttpHelper(self.session)
        response = request.get_paginated(endpoint, key, max_pages)
        return response
    def get_firewall_logs(self, server_id, pages):
        """This method retrieves the detail of a server firewall log.

        Args:
            server_id (str): ID of server

        Returns:
            list: firewall log of the server
        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s/firewall_logs" % server_id
        key = "agent_firewall_logs"
        max_pages = pages

        request = HttpHelper(self.session)
        response = request.get_paginated(endpoint, key, max_pages)
        firewall_log_details = response[key]
        return firewall_log_details
Esempio n. 11
0
    def list_all(self, firewall_policy_id):
        """List all rules associated with a firewall policy.

        Args:
            firewall_policy_id (str): ID of firewall policy

        Returns:
            list: Returns a list of rules associated with the firewall \
            policy, each of which are represented by an object of type dict.

        """

        request = HttpHelper(self.session)
        endpoint = ("/v1/firewall_policies/%s/firewall_rules/" %
                    firewall_policy_id)
        key = "firewall_rules"
        max_pages = 30
        response = request.get_paginated(endpoint, key, max_pages)
        return response
    def list_all(self, pages, **kwargs):
        """Returns a list of all events.


        Default filter returns ALL events.  This is a very verbose \
        and time-consuming operation.

        Args:
            pages (int): Max number of pages (of ten items each) to retrieve

        Keyword Args:
            group_id (list or str): A list or comma-separated string \
            containing the group IDs to retrieve events for.
            server_id (list or str): A list or comma-separated string \
            containing the server IDs to retrieve events for.
            server_platform (str): (linux | windows)
            critical (bool): Returns only critical or \
            noncritical events.
            type (list or str): A list or comma-separated string containing \
            the event types to query for.  A complete list of event types is \
            available \
            `here: <https://support.cloudpassage.com/entries/23125117-Events\
            #event-types>`_
            since (str): ISO 8601 formatted string representing the starting \
            date and time for query
            until (str): ISO 8601 formatted string representing the ending \
            date and time for query

        Returns:
            list: List of dictionary objects describing servers

        """

        endpoint = "/v1/events"
        key = "events"
        max_pages = pages
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint,
                                         key,
                                         max_pages,
                                         params=params)
        return response
    def list_all(self, **kwargs):
        """Return a list of all local user groups.

        This will only return a maximum of 50 pages, which amounts
        to 500 local user groups.

        Keyword Args:
            group_id (list or str): A list of local user groups \
            in the according server group
            server_id (list or str): A list of local user groups \
            in the according server
            os_type (list or str): A list of local user groups \
            in the according os type
            name (list or str): A list of local user groups \
            with the according name
            memebers (list or str): A list of local user groups \
            with the according members
            comment (str):  A list of local user groups \
            with the according comment
            member_name (list or str): A list of local user groups \
            with the according member names
            server_name (list or str): A list of local user groups \
            with the according server name
            server_label (list or str): A list of local user groups \
            with the according server label
            gid (list or str): A list of local user groups \
            with the according gid
            sid (list or str): A list of local user groups \
            with the according sid

        Returns:
            list: List of dictionary objects describing local user groups

        """
        endpoint = "/v1/local_groups"
        key = "local_groups"
        max_pages = 50
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint, key,
                                         max_pages, params=params)
        return response
Esempio n. 14
0
    def list_all(self, **kwargs):
        """Returns a list of all issues.

        This query is limited to 20 pages of 100 items,
        totalling 2000 issues.

        Default filter returns only issues in the 'active' state.

        Keyword Args:
            agent_id (list or str): A list or comma-separated string \
            containing agent ids
            status (list or str): A list or comma-separated string \
            containing any of these: active, resolved
            since (str): Returns issues created since date in iso8601 format \
            such as: 2017-01-01
            until (str): Returns issues created until date in iso8601 format \
            such as 2017-01-01
            issue_type: (list or str): A list or comma-separated string \
            containing any of these: sva, csm, fim, lids, sam, fw, or agent
            group_id: (list or str): A list or comma-separated string \
            containing group ids
            critical: (list or str): A list or comma-separated string \
            containing any of these: true, false
            policy_id (list or str): A list or comma-separated string \
            containing policy ids
            os_type (list or str): A list or comma-separated string \
            containing any of these: Linux, Windows

         Returns:
            list: List of dictionary objects describing issues

        """

        session = self.session
        max_pages = 20
        key = "issues"
        endpoint = "/v1/issues"
        request = HttpHelper(session)
        params = utility.sanitize_url_params(kwargs)
        issues = request.get_paginated(endpoint, key,
                                       max_pages, params=params)
        return issues
    def list_all(self, pages, **kwargs):
        """Returns a list of all events.


        Default filter returns ALL events.  This is a very verbose \
        and time-consuming operation.

        Args:
            pages (int): Max number of pages (of ten items each) to retrieve

        Keyword Args:
            group_id (list or str): A list or comma-separated string \
            containing the group IDs to retrieve events for.
            server_id (list or str): A list or comma-separated string \
            containing the server IDs to retrieve events for.
            server_platform (str): (linux | windows)
            critical (bool): Returns only critical or \
            noncritical events.
            type (list or str): A list or comma-separated string containing \
            the event types to query for.  A complete list of event types is \
            available \
            `here: <https://support.cloudpassage.com/entries/23125117-Events\
            #event-types>`_
            since (str): ISO 8601 formatted string representing the starting \
            date and time for query
            until (str): ISO 8601 formatted string representing the ending \
            date and time for query

        Returns:
            list: List of dictionary objects describing servers

        """

        endpoint = "/v1/events"
        key = "events"
        max_pages = pages
        request = HttpHelper(self.session)
        params = utility.sanitize_url_params(kwargs)
        response = request.get_paginated(endpoint, key, max_pages,
                                         params=params)
        return response
    def scan_history(self, **kwargs):
        """Get a list of historical scans.

        Keyword args:
            server_id (str): Id of server
            module (str or list): sca, fim, svm, sam
            status (str or list): queued, pending, running, completed_clean,
            completed_with_errors, failed
            since (str): ISO 8601 formatted string representing the starting \
            date and time for query
            until (str): ISO 8601 formatted string representing the ending \
            date and time for query
            max_pages (int): maximum number of pages to fetch.  Default: 20.

        Returns:
            list: List of scan objects
        """

        max_pages = 20
        url_params = kwargs
        if "server_id" in kwargs:
            url_params["server_id"] = kwargs["server_id"]
        if "module" in kwargs:
            url_params["module"] = self.verify_and_build_module_params(
                kwargs["module"])
        if "status" in kwargs:
            url_params["status"] = self.verify_and_build_status_params(
                kwargs["status"])
        if "max_pages" in kwargs:
            max_pages = kwargs["max_pages"]
        endpoint = "/v1/scans"
        key = "scans"
        request = HttpHelper(self.session)
        params = utility.assemble_search_criteria(self.supported_search_fields,
                                                  url_params)
        response = request.get_paginated(endpoint,
                                         key,
                                         max_pages,
                                         params=params)
        return response
    def scan_history(self, **kwargs):
        """Get a list of historical scans.

        Keyword args:
            server_id (str): Id of server
            module (str or list): sca, fim, svm, sam
            status (str or list): queued, pending, running, completed_clean,
            completed_with_errors, failed
            since (str): ISO 8601 formatted string representing the starting \
            date and time for query
            until (str): ISO 8601 formatted string representing the ending \
            date and time for query
            max_pages (int): maximum number of pages to fetch.  Default: 20.

        Returns:
            list: List of scan objects
        """

        max_pages = 20
        url_params = {}
        if "server_id" in kwargs:
            url_params["server_id"] = kwargs["server_id"]
        if "module" in kwargs:
            url_params["module"] = self.verify_and_build_module_params(
                kwargs["module"])
        if "status" in kwargs:
            url_params["status"] = self.verify_and_build_status_params(
                kwargs["status"])
        if "max_pages" in kwargs:
            max_pages = kwargs["max_pages"]
        endpoint = "/v1/scans"
        key = "scans"
        request = HttpHelper(self.session)
        params = utility.assemble_search_criteria(self.supported_search_fields,
                                                  url_params)
        response = request.get_paginated(endpoint, key, max_pages,
                                         params=params)
        return response