Пример #1
0
    def handler_wrapped(self, channel, request):
        log_error('DISCARDING message on %s' % (channel))

        message = plugin_pb2.SubmitRequestMessage()
        message.ParseFromString(request)
        command = message.payload[0].command
        log('Got message %s on %s' % (command, channel))

        msg = self.get_response(command)
        msg.got_response = True
        self.set_response(msg)
        return None
Пример #2
0
    def inbox_handler_wrapped(self, channel, request):
        message = plugin_pb2.SubmitRequestMessage()
        message.ParseFromString(request)
        if len(message.payload) != 1:
            log_error("Got invalid message on channel: %s" % channel)
            return None
        command = message.payload[0].command
        log('Got message %s on %s' % (command, channel))

        msg = NSCAMessage(command)
        msg.got_response = True
        self.set_response(msg)
        return None
Пример #3
0
    def submit_payload(self, encryption, target, length, source, status, msg,
                       perf, tag):
        message = plugin_pb2.SubmitRequestMessage()

        message.header.recipient_id = target
        message.channel = 'nsca_test_outbox'
        host = message.header.hosts.add()
        host.id = target
        if (target == 'valid'):
            pass
        else:
            host.address = "127.0.0.1:15667"
            enc = host.metadata.add()
            enc.key = "encryption"
            enc.value = encryption
            enc = host.metadata.add()
            enc.key = "password"
            enc.value = 'pwd-%s' % encryption
            enc = host.metadata.add()
            enc.key = "payload length"
            enc.value = '%d' % length

        uid = str(uuid.uuid4())
        payload = message.payload.add()
        payload.result = status
        payload.command = uid
        line = payload.lines.add()
        line.message = '%s - %s' % (uid, msg)
        payload.source = source
        (result_code, err) = self.core.submit('nsca_test_outbox',
                                              message.SerializeToString())

        result = TestResult('Testing payload submission (via API): %s' % tag)
        result.assert_equals(result_code, True,
                             'Submission (%s) return ok status' % tag)
        result.assert_equals(err, 'Submission successful',
                             'Submission (%s) returned correct status' % tag)
        self.wait_and_validate(uid, result, msg, perf, '%s/spb' % tag)
        return result
Пример #4
0
    def submit_payload(self, encryption, target, length, source, status, msg,
                       perf, tag):
        message = plugin_pb2.SubmitRequestMessage()

        message.header.version = plugin_pb2.Common.VERSION_1
        message.header.recipient_id = target
        message.channel = 'nsca_test_outbox'
        host = message.header.hosts.add()
        host.id = target
        if (target == 'valid'):
            pass
        else:
            host.address = "127.0.0.1:15667"
            enc = host.metadata.add()
            enc.key = "encryption"
            enc.value = encryption
            enc = host.metadata.add()
            enc.key = "password"
            enc.value = 'pwd-%s' % encryption
            enc = host.metadata.add()
            enc.key = "payload length"
            enc.value = '%d' % length

        uid = str(uuid.uuid4())
        payload = message.payload.add()
        payload.result = status
        payload.command = uid
        payload.message = '%s - %s' % (uid, msg)
        payload.source = source
        (result_code, err) = self.core.submit('nsca_test_outbox',
                                              message.SerializeToString())

        result = TestResult('Testing payload submission (via API): %s' % tag)
        result.add_message(
            len(err) == 0, 'Testing to send message using %s/sbp' % tag, err)
        self.wait_and_validate(uid, result, msg, perf, '%s/spb' % tag)
        return result