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

ENH: lib/bot: fix behavior for unconfigured bots #2054

Merged
1 commit merged into from
Aug 30, 2021
Merged

Conversation

ghost
Copy link

@ghost ghost commented Aug 19, 2021

Add enabled and run_mode as members of the Bot class with default values.
Log the system parameters in the same way as default and runtime parameters.
Warn if disallowed system parameters are encountered.
Warn if no configuration could be found in the runtime configuration file for the bot's ID.
Re-initialize logging if logging parameters have been changed by environment variables.

@ghost ghost added feature Indicates new feature requests or new features component: core labels Aug 19, 2021
@ghost ghost added this to the 3.1.0 milestone Aug 19, 2021
@ghost ghost self-requested a review August 19, 2021 19:00
@codecov-commenter
Copy link

codecov-commenter commented Aug 19, 2021

Codecov Report

Merging #2054 (0c92949) into develop (c9f3ec2) will decrease coverage by 0.01%.
The diff coverage is 61.53%.

@@             Coverage Diff             @@
##           develop    #2054      +/-   ##
===========================================
- Coverage    76.06%   76.04%   -0.02%     
===========================================
  Files          434      434              
  Lines        23210    23218       +8     
  Branches      3100     3104       +4     
===========================================
+ Hits         17654    17657       +3     
- Misses        4849     4852       +3     
- Partials       707      709       +2     
Impacted Files Coverage Δ
intelmq/lib/bot.py 63.45% <61.53%> (-0.29%) ⬇️

setattr(self, option, value)
elif option not in IGNORED_SYSTEM_PARAMETERS:
self.logger.warning('Ignoring disallowed system parameter %r.',
option)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the difference between an option that is not in ALLOWED_SYSTEM_PARAMETERS and an option that is in IGNORED_SYSTEM_PARAMETERS (besides the latter is logged)? Why not simply drop IGNORED_SYSTEM_PARAMETERS and log all parameters that are not in ALLOWED_SYSTEM_PARAMETERS?
Nitpicking: I prefer iterating through dicts using key, value instead of option, value. If you don't want to use key I'd prefer the term parameter instead of option to make it more consistent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ad naming: I just used the same naming as in the iteration below

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IGNORED_SYSTEM_PARAMETERS are silently ignored, as they are legit, but irrelevant here.
Everything which is not in ALLOWED_SYSTEM_PARAMETERS or IGNORED_SYSTEM_PARAMETERS is not allowed and likely a user configuration error (e.g. things that should have gone into parameters)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the naming

intelmq/lib/bot.py Show resolved Hide resolved
@ghost ghost force-pushed the wagner/enh-unconfigured branch 2 times, most recently from 894df82 to 488d885 Compare August 23, 2021 12:58
@ghost ghost self-requested a review August 30, 2021 07:25
@ghost ghost force-pushed the wagner/enh-unconfigured branch 2 times, most recently from e278acf to 68d034e Compare August 30, 2021 07:47
@ghost ghost self-assigned this Aug 30, 2021
Add `enabled` and `run_mode` as members of the `Bot` class with default values.
Log the system parameters in the same way as default and runtime parameters.
Warn if disallowed system parameters are encountered.
Warn if no configuration could be found in the runtime configuration file for the bot's ID.
Re-initialize logging if logging parameters have been changed by environment variables.
@ghost ghost force-pushed the wagner/enh-unconfigured branch from 68d034e to 0c92949 Compare August 30, 2021 08:11
@ghost ghost merged commit 0c92949 into develop Aug 30, 2021
@ghost ghost deleted the wagner/enh-unconfigured branch August 30, 2021 08:52
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: core feature Indicates new feature requests or new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant