Skip to content

Conversation

@e3rd
Copy link
Member

@e3rd e3rd commented Sep 12, 2025

My proposal is to implement miniterface. This gives us various advantages.

Automatic GUI and colourful helps

If left empty, there is an automatic wizzard. Note the file-picker button.

$ intelmqsetup
image
$ intelmqsetup --help
usage: intelmqsetup [-h] [OPTIONS]

Set's up directories and example configurations for IntelMQ.

╭─ options ──────────────────────────────────────────────────────────────────╮
│ -h, --help                                                                 │
│     show this help message and exit                                        │
│ -v, --verbose                                                              │
│     verbosity level, can be used multiple times to increase                │
│ --skip-ownership, --no-skip-ownership                                      │
│     Skip setting file ownership. (default: False)                          │
│ --state-file PATH                                                          │
│     The state file location to use. (default:                              │
│     /opt/intelmq/var/lib/state.json)                                       │
│ --webserver-user {None}|STR                                                │
│     The webserver to use instead of auto-detection. (default: None)        │
│ --webserver-configuration-directory {None}|STR                             │
│     The webserver configuration directory to use instead of                │
│     auto-detection. (default: None)                                        │
│ --skip-api, --no-skip-api                                                  │
│     Skip set-up of intelmq-api. (default: False)                           │
│ --skip-webserver, --no-skip-webserver                                      │
│     Skip all operations on the webserver configuration, affects the API    │
│     and Manager. (default: False)                                          │
│ --skip-manager, --no-skip-manager                                          │
│     Skip set-up of intelmq-manager. (default: False)                       │
╰────────────────────────────────────────────────────────────────────────────╯

The automatic wizzard for intelmqctl has multiple steps, according to the subcommands:

$ intelmqctl
image image
$ intelmqctl --help

Automatic TUI

On machines without display (ex. through SSH), there is an automatic fallback for a mouse-clickable text interface.

$ intelmqctl
image

Transparent parser

Instead of the argparse, I've refactored the configuration to dataclasses.

So instead of this structure we have something more readable.

parser_run_message = parser_run_subparsers.add_parser('message',
                        help='Debug bot\'s pipelines. Get the message in the'
                            ' input pipeline, pop it (cut it) and display it, or'
                            ' send the message directly to bot\'s output pipeline(s).')
parser_run_message.add_argument('message_action_kind',
choices=["get", "pop", "send"],
help='get: show the next message in the source pipeline. '
        'pop: show and delete the next message in the source pipeline '
        'send: Send the given message to the destination pipeline(s).')
parser_run_message.add_argument('msg', nargs='?', help='If send was chosen, put here the message in JSON.')

The dataclass mentioned:

@dataclass
class Message:
    """Debug bot's pipelines. Get the message in the
        input pipeline, pop it (cut it) and display it, or
        send the message directly to bot's output pipeline(s)."""

    message_action_kind: Literal["get", "pop", "send"]
    """get: show the next message in the source pipeline.
    pop: show and delete the next message in the source pipeline
    send: Send the given message to the destination pipeline(s)."""

    msg: Optional[str] = None
    "If send was chosen, put here the message in JSON."

IDE benefits

The miniterface would have worked with our argparse too but refactoring into dataclasses will give us benefits. Automatic type control, IDE suggestions and IDE is now able to show hints (which is impossible with the old argparse).

image

Also, it allows us a direct usage of complex types instead of the basic ones the arpgarse supports. It works well with Enums, Paths, dates, etc.

Conclusion

The functionality is equal. Are you interested in this PR, what do you think? Are there any changes I should catch up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants