Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check missing requirements in check command #2411

Open
kamil-certat opened this issue Sep 20, 2023 · 0 comments
Open

Check missing requirements in check command #2411

kamil-certat opened this issue Sep 20, 2023 · 0 comments
Labels
component: core component: intelmqctl feature Indicates new feature requests or new features

Comments

@kamil-certat
Copy link
Contributor

kamil-certat commented Sep 20, 2023

Currently, bots check their requirements only during startup. It would be helpful, if the check() method of bots does it as well, so we'll get the clear information when verifying IntelMQ installation. Probably it would be also useful to have a helper that gets the modules and versions, and can be then reused.

Pseudo-code idea:

# importing with fallback to None as usual
try:
   import requests
except ImportError:
  requests = None

from intelmq.lib.utils import DependencyValidator

deps = DependencyValidator()
deps.register(module=requests, version=(1, 1, 1), validator=lambda module, version: module.__version__ >= version)
# ^ validator only optional when the package has some non-standard version check or so

# ...  in init()
    deps.validate(raise=True)

# ... in check()
    errors.extend(deps.validate(raise=False))

Maybe it would be even possible to do a method for dependency auto-discovery from corresponding REQUIREMENTS.txt file - but this could be tricky.

@sebix sebix added the feature Indicates new feature requests or new features label Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core component: intelmqctl feature Indicates new feature requests or new features
Projects
None yet
Development

No branches or pull requests

2 participants