How to use the broker.TOPICS.SQL_COMMAND function in broker

To help you get started, we’ve selected a few broker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / WAFBench / ftw_compatible_tool / traffic.py View on Github external
def _publish(self):
        elapse_time = None
        if self._request_time and self._response_time:
            elapse_time = self._response_time - self._request_time
        self._ctx.broker.publish(
            broker.TOPICS.SQL_COMMAND,
            sql.SQL_INSERT_RAW_TRAFFIC,
            self._request_buffer,
            self._response_buffer,
            elapse_time,
            self._current_key,
        )
        self._ctx.broker.publish(
            broker.TOPICS.RAW_TRAFFIC,
            self._current_key,
            self._request_buffer,
            self._response_buffer,
        )
github microsoft / WAFBench / ftw_compatible_tool / base.py View on Github external
row = dict(zip(result.title(), row))
                    if self._ctx.delimiter:
                        delimiter_packet = self._ctx.delimiter.get_delimiter_packet(
                            row["traffic_id"])
                        delimiter_packet = pywb.ftwhelper.get(
                            delimiter_packet, pywb.ftwhelper.FTW_TYPE.PACKETS)
                        dumper.dump(delimiter_packet)
                    dumper.dump(row["request"])
                    if self._ctx.delimiter:
                        delimiter_packet = self._ctx.delimiter.get_delimiter_packet(
                            row["traffic_id"])
                        delimiter_packet = pywb.ftwhelper.get(
                            delimiter_packet, pywb.ftwhelper.FTW_TYPE.PACKETS)
                        dumper.dump(delimiter_packet)
        self._ctx.broker.publish(
            broker.TOPICS.SQL_COMMAND,
            request_sql_script
            if request_sql_script else sql.SQL_QUERY_REQUEST,
            *args,
            callback=gen_requests)
github microsoft / WAFBench / ftw_compatible_tool / database.py View on Github external
def __init__(self, context):
        """ Create a Database,
            subscribe itself to SQL_COMMAND,
            query for initializing database.
        """
        self.context = context
        self.context.broker.subscribe(broker.TOPICS.SQL_COMMAND, self._query)
        try:
            self.query(sql.SQL_INITIALIZE_DATABASE)
        except sqlite3.OperationalError:
            # ignore repeatedly initialize error
            pass
github microsoft / WAFBench / ftw_compatible_tool / database.py View on Github external
def __del__(self):
        self.context.broker.unsubscribe(broker.TOPICS.SQL_COMMAND, self._query)
github microsoft / WAFBench / ftw_compatible_tool / log.py View on Github external
log_buffer = []
        # Remove logs generated by dummy request
        start_unique_id = '[unique_id "{unique_id}"]'.format(
            unique_id = self._get_unique_id(collected_buffer[0])
        )
        end_unique_id = '[unique_id "{unique_id}"]'.format(
            unique_id = self._get_unique_id(collected_buffer[-1])
        )
        for line in collected_buffer:
            if start_unique_id not in line and end_unique_id not in line:
                log_buffer.append(line)

        if log_buffer:
            self._ctx.broker.publish(
                broker.TOPICS.SQL_COMMAND,
                sql.SQL_INSERT_LOG,
                "\n".join(log_buffer),
                key,
            )