Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Please refer to the [NEWS](NEWS.md) for a list of changes which have an affect o
### Tests

### Tools
- `intelmq.lib.bot_debugger`: Optionally read input messages from stdin instead of parameter value (PR#2678 by Sebastian Wager).

### Contrib

Expand Down
13 changes: 12 additions & 1 deletion docs/admin/management/intelmq.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,20 @@ file-output: * Message from cli will be used when processing.
...
```

You can also read the message from stdin (one line):

```bash
> intelmqctl run file-output process -m -
...
Reading message from stdin (one line):
{"source.ip":"10.2.3.4"}
file-output: * Message from cli will be used when processing.
...
```

If you wish to display the processed message as well, you the
**--show-sent|-s** flag. Then, if sent through (either with
`--dryrun` or without), the message gets displayed as well.
`--dryrun` or without), the resulting message gets displayed as well.

### disable

Expand Down
6 changes: 3 additions & 3 deletions intelmq/bin/intelmqctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
intelmqctl list [bots|queues|queues-and-status]
intelmqctl log bot-id [number-of-lines [log-level]]
intelmqctl run bot-id message [get|pop|send]
intelmqctl run bot-id process [--msg|--dryrun]
intelmqctl run bot-id process [--msg|--dryrun|--show-sent]
intelmqctl run bot-id console
intelmqctl clear queue-id
intelmqctl check
Expand Down Expand Up @@ -280,8 +280,8 @@ def __init__(self, interactive: bool = False, returntype: ReturnType = ReturnTyp
help='Never really pop the message from the input pipeline '
'nor send to output pipeline.')
parser_run_process.add_argument('--msg', '-m',
help='Trick the bot to process this JSON '
'instead of the Message in its pipeline.')
help='Trick the bot to process this JSON message from the parameter '
"instead of the Message in its pipeline. Read from stdin (one line) with '-'.")
parser_run_process.set_defaults(run_subcommand="process")
parser_run.set_defaults(func=self.bot_run)

Expand Down
4 changes: 4 additions & 0 deletions intelmq/lib/bot_debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ def outputappend(self, msg):

def arg2msg(self, msg):
default_type = "Report" if (self.runtime_configuration.get("group", None) == "Parser" or isinstance(self.instance, ParserBot)) else "Event"
if msg == '-':
print('Reading message from stdin (one line):')
msg = input()

try:
msg = MessageFactory.unserialize(msg, default_type=default_type)
except (Exception, KeyError, TypeError, ValueError) as exc:
Expand Down
Loading