intelmq-manager icon indicating copy to clipboard operation
intelmq-manager copied to clipboard

BUG: configs.js: prevent frontend from converting numeric strings to numbers

Open monoidic opened this issue 1 year ago • 1 comments

intelmq-manager allows the user to fill in a configuration value with a numeric string by enclosing it in quotes, such as "200", and it is submitted correctly. When editing the configuration of the same bot later, the values, including the numeric string, are filled in with the current configuration values. However, this filled in value will not contain the quotes and will subsequently be considered a number. This can cause type errors if a string is expected for this value.

This patch detects numeric strings and adds quotation marks for them ahead of time when editing the configuration in intelmq-manager, preventing "200" from being silently converted to 200 on subsequent edits.

monoidic avatar Jul 01 '24 08:07 monoidic

This is actually quite tricky, because if the bot may expect a number to be a number in the configuration, right? If I understand correctly, the problem is that configuration:

my-bot:
   parameters:
      expected_string: "200"

will silently be converted by the manager to:

my-bot:
   parameters:
      expected_string: 200

However, isn't it so, that this change will introduce the opposite behaviour, and all data defined intentionally as numbers, will be then converted to strings?

kamil-certat avatar Mar 03 '25 15:03 kamil-certat