Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Correctly validate 'apps.misp.api.*' config settings #161

Merged
merged 3 commits into from
Aug 24, 2021
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Every entry has a category for which we use the following visual abbreviations:
address some limitations in the configuration framework.
[#157](https://github.com/tenzir/threatbus/pull/157)

- 🐞 Fixed config validation for the 'apps.misp.api' setting.
[#161](https://github.com/tenzir/threatbus/pull/161)

## [2021.07.29]

- 🐞 Threatbus now only attempts to load plugins that are explicitly
Expand Down
2 changes: 1 addition & 1 deletion config.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ plugins:
module_namespace: Tenzir
# Requires the 'threatbus-misp' package to be installed
misp:
api: # Optional
api: # Optional. If present, all of 'host', 'ssl', 'key' are required.
host: https://localhost
ssl: false
key: MISP_API_KEY
Expand Down
12 changes: 9 additions & 3 deletions plugins/apps/threatbus_misp/threatbus_misp/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,16 @@ def config_validators() -> List[Validator]:
is_type_of=list,
default=[],
),
# TODO: Allow default values for 'host' and 'ssl'.
Validator(
f"plugins.apps.{plugin_name}.api",
is_type_of=dict,
default={},
f"plugins.apps.{plugin_name}.api.host",
f"plugins.apps.{plugin_name}.api.ssl",
f"plugins.apps.{plugin_name}.api.key",
when=Validator(f"plugins.apps.{plugin_name}.api", must_exist=True),
required=True,
messages={
"must_exist_true": "All of 'api.host', 'api.ssl', and 'api.key' must be defined when the 'api' key exists"
},
),
zmq_kafka_mut_exclusive_validator,
zmq_validator,
Expand Down