def last_scan_results(self, server_id, scan_type):
        """Get the results of scan_type performed on server_id.

        Args:
            server_id (str): ID of server
            scan_type (str): Type of scan to filter results for

        Valid scan types:
          sca  - Configuration scan
          csm  - Configuration scan (same as sca)
          svm  - Software vulnerability scan
          sva  - Software vulnerability scan (same as svm)
          fim  - File integrity monitoring scan

        Returns:
            dict: Dictionary object describing last scan results

        """

        if self.scan_history_supported(scan_type) is False:
            exception_message = "Unsupported scan type: %s" % scan_type
            raise CloudPassageValidation(exception_message)
        else:
            scan_type_normalized = self.supported_scans[scan_type]
            endpoint = "/v1/servers/%s/%s" % (server_id, scan_type_normalized)
            request = HttpHelper(self.session)
            response = request.get(endpoint)
            return response
    def last_scan_results(self, server_id, scan_type):
        """Get the results of scan_type performed on server_id.

        Args:
            server_id (str): ID of server
            scan_type (str): Type of scan to filter results for

        Valid scan types:
          sca  - Configuration scan
          csm  - Configuration scan (same as sca)
          svm  - Software vulnerability scan
          sva  - Software vulnerability scan (same as svm)
          fim  - File integrity monitoring scan

        Returns:
            dict: Dictionary object describing last scan results

        """

        if self.scan_history_supported(scan_type) is False:
            exception_message = "Unsupported scan type: %s" % scan_type
            raise CloudPassageValidation(exception_message)
        else:
            scan_type_normalized = self.supported_scans[scan_type]
            endpoint = "/v1/servers/%s/%s" % (server_id, scan_type_normalized)
            request = HttpHelper(self.session)
            response = request.get(endpoint)
            return response
Esempio n. 3
0
    def list_all(self):
        """Returns a list of all system announcements
        """

        session = self.session
        endpoint = self.build_endpoint()
        request = HttpHelper(session)
        response = request.get(endpoint)
        announcement_list = response["announcements"]
        return announcement_list
    def list_all(self):
        """Returns a list of all system announcements
        """

        session = self.session
        endpoint = self.build_endpoint()
        request = HttpHelper(session)
        response = request.get(endpoint)
        announcement_list = response["announcements"]
        return announcement_list
    def describe(self, issue_id):
        """Get issue details by issue ID

        Args:
            issue_id (str): Issue ID

        Returns:
            dict: Dictionary object describing issue
        """

        endpoint = "/v1/issues/%s" % issue_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        return response
    def describe(self, policy_id):
        """Get the detailed configuration of a policy

        Args:
            policy_id (str): ID of the policy to retrieve \
            detailed configuration information for

        Returns:
            dict: dictionary object representing the entire, detailed, policy

        """

        request = HttpHelper(self.session)
        describe_endpoint = "%s/%s" % (self.endpoint(), policy_id)
        return request.get(describe_endpoint)[self.policy_key()]
Esempio n. 7
0
    def issues(self, server_id):
        """This method retrieves the detail of a server issues.

        Args:
            server_id (str): ID of server

        Returns:
            list: issues of the server
        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s/issues" % server_id

        request = HttpHelper(self.session)
        response = request.get(endpoint)
        return response
    def issues(self, server_id):
        """This method retrieves the detail of a server issues.

        Args:
            server_id (str): ID of server

        Returns:
            list: issues of the server
        """

        sanity.validate_object_id(server_id)
        endpoint = "/v1/servers/%s/issues" % server_id

        request = HttpHelper(self.session)
        response = request.get(endpoint)
        return response
    def describe(self, server_id):
        """Get server details by server ID

        Args:
            server_id (str): Server ID

        Returns:
            dict: Dictionary object describing server

        """

        endpoint = "/v1/servers/%s" % server_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        server_details = response["server"]
        return server_details
    def scan_details(self, scan_id):
        """Get detailed scan information

        Args:
            scan_id (str): ID of scan

        Returns:
            dict: Dictionary object describing scan details

        """

        endpoint = "/v1/scans/%s" % scan_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        report = response["scan"]
        return report
    def findings(self, scan_id, findings_id):
        """Get FIM, CSM, and SVA findings details by scan and findings ID

        Args:
            scan_id (str): ID of scan_id
            findings_id (str): ID of findings to retrieve

        Returns:
            dict: Dictionary object descrbing findings

        """

        endpoint = "/v1/scans/%s/findings/%s" % (scan_id, findings_id)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        return response
    def scan_details(self, scan_id):
        """Get detailed scan information

        Args:
            scan_id (str): ID of scan

        Returns:
            dict: Dictionary object describing scan details

        """

        endpoint = "/v1/scans/%s" % scan_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        report = response["scan"]
        return report
    def findings(self, scan_id, findings_id):
        """Get FIM, CSM, and SVA findings details by scan and findings ID

        Args:
            scan_id (str): ID of scan_id
            findings_id (str): ID of findings to retrieve

        Returns:
            dict: Dictionary object descrbing findings

        """

        endpoint = "/v1/scans/%s/findings/%s" % (scan_id, findings_id)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        return response
Esempio n. 14
0
    def describe_local_account(self, server_id, username):
        """Get deatils on local user account

        Args:
            server_id (str): Server ID
            username (str): username of the local user account

        Returns:
            dict: Dictionary object describing local user account

        """
        endpoint = "/v1/servers/%s/accounts/%s" % (server_id, username)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        account_detail = response["account"]
        return account_detail
Esempio n. 15
0
    def list_local_accounts(self, server_id):
        """This method retrieves all local user accounts on the server\
            specified by server ID

        Args:
            server_id (str): Server ID

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

        """
        endpoint = "/v1/servers/%s/accounts" % (server_id)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        local_accounts = response["accounts"]
        return local_accounts
Esempio n. 16
0
    def describe(self, server_id):
        """Get server details by server ID

        Args:
            server_id (str): Server ID

        Returns:
            dict: Dictionary object describing server

        """

        endpoint = "/v1/servers/%s" % server_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        server_details = response["server"]
        return server_details
    def list_members(self, group_id):
        """Returns a list of all member servers of a group_id

        Args:
            group_id (str): ID of group_id

        Returns:
            list: List of dictionary objects describing member servers

        """

        endpoint = "/v1/groups/%s/servers" % group_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        servers = response["servers"]
        return servers
    def describe(self, group_id):
        """Describe a ServerGroup.  In detail.

        Args:
            group_id (str): ID of group

        Returns:
            dict: Dictionary object describing group.  In detail.

        """

        endpoint = "/v1/groups/%s" % group_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        group = response["group"]
        return group
    def describe(self, group_id):
        """Describe a ServerGroup.  In detail.

        Args:
            group_id (str): ID of group

        Returns:
            dict: Dictionary object describing group.  In detail.

        """

        endpoint = "/v1/groups/%s" % group_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        group = response["group"]
        return group
    def list_members(self, group_id):
        """Returns a list of all member servers of a group_id

        Args:
            group_id (str): ID of group_id

        Returns:
            list: List of dictionary objects describing member servers

        """

        endpoint = "/v1/groups/%s/servers" % group_id
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        servers = response["servers"]
        return servers
    def command_details(self, server_id, command_id):
        """This method retrieves the details and status of a server command.

        Args:
            server_id (str): ID of server runnung command
            command_id (str): ID of command running on server

        Returns:
            dict: Command status as a dictionary object.

        Example:

        ::

            {
              "name": "",
              "status: "",
              "created_at": "",
              "updated_at": "",
              "result": ""
             }


        For server account creation and server account password resets, \
        the password will be contained in the result field, as a dictionary:


        ::

            {
              "name": "",
              "status: "",
              "created_at": "",
              "updated_at": "",
              "result": {
                         "password": ""
                         }
            }


        """

        endpoint = "/v1/servers/%s/commands/%s" % (server_id, command_id)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        command_status = response["command"]
        return command_status
Esempio n. 22
0
    def command_details(self, server_id, command_id):
        """This method retrieves the details and status of a server command.

        Args:
            server_id (str): ID of server runnung command
            command_id (str): ID of command running on server

        Returns:
            dict: Command status as a dictionary object.

        Example:

        ::

            {
              "name": "",
              "status: "",
              "created_at": "",
              "updated_at": "",
              "result": ""
             }


        For server account creation and server account password resets, \
        the password will be contained in the result field, as a dictionary:


        ::

            {
              "name": "",
              "status: "",
              "created_at": "",
              "updated_at": "",
              "result": {
                         "password": ""
                         }
            }


        """

        endpoint = "/v1/servers/%s/commands/%s" % (server_id, command_id)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        command_status = response["command"]
        return command_status
    def describe(self, server_id, gid):
        """Get local user group deatils by server id and gid

        Args:
            server_id = Server ID
            gid = gid

        Returns:
            list: List of dictionary object describing local user group detail

        """
        endpoint = "/v1/local_groups?server_id=%s&gid=%s" % (server_id,
                                                             gid)
        request = HttpHelper(self.session)
        response = request.get(endpoint)
        group_detail = response["local_groups"]
        return group_detail
    def list_connections(self, group_id, **kwargs):
        """This method retrieves all recently detected connections in the server\
           group specified by Group ID

        Args:
            server_id (str): Group ID

        Returns:
            list: List of all recently detected connections in the srever group

        """
        endpoint = "/v1/groups/%s/connections" % (group_id)
        params = utility.sanitize_url_params(kwargs)
        request = HttpHelper(self.session)
        response = request.get(endpoint, params=params)
        connections = response["connections"]
        return connections
    def describe(self, fim_policy_id, fim_baseline_id):
        """Returns the body of the baseline indicated by fim_baseline_id.

        Args
            fim_policy_id (str): ID of FIM policy
            fim_baseline_id (str): ID of baseline

        Returns:
            dict: Dictionary describing FIM baseline

        """

        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines/%s" % (fim_policy_id,
                                                         fim_baseline_id)
        response = request.get(endpoint)
        result = response["baseline"]
        return result
Esempio n. 26
0
    def describe(self, fim_policy_id, baseline_id):
        """Returns the body of the baseline indicated by fim_baseline_id.

        Args
            fim_policy_id (str): ID of FIM policy
            fim_baseline_id (str): ID of baseline

        Returns:
            dict: Dictionary describing FIM baseline

        """

        request = HttpHelper(self.session)
        endpoint = "/v1/fim_policies/%s/baselines/%s/details" % (fim_policy_id,
                                                                 baseline_id)
        response = request.get(endpoint)
        result = response["baseline"]
        return result
Esempio n. 27
0
    def describe(self, firewall_policy_id, firewall_rule_id):
        """Get the detailed configuration of a firewall rule

        Args:
            firewall_policy_id (str): ID of the policy to retrieve \
            detailed configuration information for
            firewall_rule_id (str): ID of the specific rule to \
            retrieve details for

        Returns:
            dict: dictionary object representing the entire \
            firewall rule

        """

        request = HttpHelper(self.session)
        endpoint = ("/v1/firewall_policies/%s/firewall_rules/%s" %
                    (firewall_policy_id, firewall_rule_id))
        response = request.get(endpoint)
        result = response["firewall_rule"]
        return result