Exemplo n.º 1
0
    def run(self, params={}):
        url = self.connection.url
        username = self.connection.username
        password = self.connection.password
        token = self.connection.token

        payload = {
            "element_type": params.get("element_type"),
            "name": params.get("name")
        }
        if params.get("time_to_live"):
            payload["time_to_live"] = params.get("time_to_live")
        if params.get("timeout_type"):
            payload["timeout_type"] = params.get("timeout_type")

        if token:
            r = helpers.add_data_to_reference_data_lists(self.logger, url, token=token, payload=payload)
        else:
            auth = helpers.encode_basic_auth(username, password)
            r = helpers.add_data_to_reference_data_lists(self.logger, url, basic_auth=auth, payload=payload)

        if not r:
            raise Exception("Run: Error adding data to reference list")
        else:
            return r
Exemplo n.º 2
0
    def run(self, params={}):
        url = self.connection.url
        username = self.connection.username
        password = self.connection.password
        token = self.connection.token
        fields = params.get('fields')
        filter = params.get('filter')
        range = params.get('range')

        if token:
            r = helpers.get_offenses(self.logger,
                                     url,
                                     token=token,
                                     fields=fields,
                                     filter=filter,
                                     range=range)
        else:
            auth = helpers.encode_basic_auth(username, password)
            r = helpers.get_offenses(self.logger,
                                     url,
                                     basic_auth=auth,
                                     fields=fields,
                                     filter=filter,
                                     range=range)

        return {'offenses': r}
Exemplo n.º 3
0
    def test(self):
        url = self.connection.url
        username = self.connection.username
        password = self.connection.password
        token = self.connection.token

        if token:
            success = helpers.test_auth(self.logger, url, token=token)
        else:
            auth = helpers.encode_basic_auth(username, password)
            success = helpers.test_auth(self.logger, url, basic_auth=auth)

        if not success:
            raise Exception('Test: Failed authentication')

        return {}
Exemplo n.º 4
0
    def run(self, params={}):
        url = self.connection.url
        username = self.connection.username
        password = self.connection.password
        token = self.connection.token
        query = params.get("query")

        if token:
            r = helpers.new_ariel_query(self.logger,
                                        url,
                                        token=token,
                                        query=query)
        else:
            auth = helpers.encode_basic_auth(username, password)
            r = helpers.new_ariel_query(self.logger,
                                        url,
                                        basic_auth=auth,
                                        query=query)

        if not r:
            raise Exception("Run: Error creating new ariel query")
        else:
            return {"search_id": r["search_id"]}
Exemplo n.º 5
0
    def run(self, params={}):
        url = self.connection.url
        username = self.connection.username
        password = self.connection.password
        token = self.connection.token

        search_id = params.get("search_id")

        if token:
            r = helpers.get_ariel_query_results(self.logger,
                                                url,
                                                token=token,
                                                search_id=search_id)
        else:
            auth = helpers.encode_basic_auth(username, password)
            r = helpers.get_ariel_query_results(self.logger,
                                                url,
                                                basic_auth=auth,
                                                search_id=search_id)

        if not r:
            raise Exception("Run: Error getting ariel query results")
        else:
            return r