diff --git a/.gitignore b/.gitignore index b5bca2a..bbfa9ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ config.py +instance_config_override.py run.py migrations/ diff --git a/README.md b/README.md index 526a2e1..e5039db 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ The REST API is documented using Swagger (OpenAPI). After installing and running ## Change Log +- 1.1.5 - introduced instance config override. Copy the sample to instance_config_override.py and customize you dashboard menu items easily. For normal installations no override is needed. - 1.1.4 - minor bug fixes and code cleanup - 1.1.3 - introduced configurable footer menu for links in bottom of the default template - 1.1.2 - minor security updates (removed unused JS files), setup.py now reads dependencies from requirements.txt diff --git a/flowapp/__about__.py b/flowapp/__about__.py index d65e0a5..c599dc3 100755 --- a/flowapp/__about__.py +++ b/flowapp/__about__.py @@ -1 +1 @@ -__version__ = "1.1.4" +__version__ = "1.1.5" diff --git a/flowapp/__init__.py b/flowapp/__init__.py index 61543e7..9b9616a 100644 --- a/flowapp/__init__.py +++ b/flowapp/__init__.py @@ -30,6 +30,12 @@ def create_app(config_object=None): if config_object: app.config.from_object(config_object) + # Allow override of instance config from external file + try: + app.config.from_pyfile("../instance_config_override.py", silent=False) + except FileNotFoundError: + pass # No override file, use defaults + app.config.setdefault("VERSION", __version__) # SSO configuration diff --git a/flowapp/constants.py b/flowapp/constants.py index 975f99b..819f685 100644 --- a/flowapp/constants.py +++ b/flowapp/constants.py @@ -9,7 +9,7 @@ DEFAULT_ORDER = "desc" # Maximum allowed comma separated values for port string or packet lenght -MAX_COMMA_VALUES = 6 +MAX_COMMA_VALUES = 5 SORT_ARG = "sort" ORDER_ARG = "order" diff --git a/instance_config_override.example.py b/instance_config_override.example.py new file mode 100644 index 0000000..5b93bec --- /dev/null +++ b/instance_config_override.example.py @@ -0,0 +1,98 @@ +# This file can be simply ignored if you do not need to override anything + +# Example instance config override +# If you need to override some settings, you can do it here. +# Copy this to instance_config_override.py and customize + + +# column names for tables +RTBH_COLUMNS = ( + ("ipv4", "IP address (v4 or v6)"), + ("community_id", "Community"), + ("expires", "Expires"), + ("user_id", "User"), +) + +WHITELIST_COLUMNS = ( + ("address", "IP address / network (v4 or v6)"), + ("expires", "Expires"), + ("user_id", "User"), +) + + +RULES_COLUMNS_V4 = ( + ("source", "Source addr."), + ("source_port", "S port"), + ("dest", "Dest. addr."), + ("dest_port", "D port"), + ("protocol", "Proto"), + ("packet_len", "Packet len"), + ("expires", "Expires"), + ("action_id", "Action"), + ("flags", "Flags"), + ("user_id", "User"), +) + +RULES_COLUMNS_V6 = ( + ("source", "Source addr."), + ("source_port", "S port"), + ("dest", "Dest. addr."), + ("dest_port", "D port"), + ("next_header", "Next header"), + ("packet_len", "Packet len"), + ("expires", "Expires"), + ("action_id", "Action"), + ("flags", "Flags"), + ("user_id", "User"), +) + + +# Customize main menu +MAIN_MENU = { + "edit": [ + {"name": "Add RTBH", "url": "rules.rtbh_rule"}, + {"name": "Add Whitelist", "url": "whitelist.add"}, + {"name": "API Key", "url": "api_keys.all"}, + ], + "admin": [ + {"name": "Commands Log", "url": "admin.log"}, + {"name": "Machine keys", "url": "admin.machine_keys"}, + { + "name": "Users", + "url": "admin.users", + "divide_before": True, + }, + {"name": "Add User", "url": "admin.user"}, + {"name": "Add Multiple Users", "url": "admin.bulk_import_users"}, + {"name": "Organizations", "url": "admin.organizations"}, + {"name": "Add Org.", "url": "admin.organization"}, + { + "name": "Action", + "url": "admin.actions", + "divide_before": True, + }, + {"name": "Add action", "url": "admin.action"}, + {"name": "RTBH Communities", "url": "admin.communities"}, + {"name": "Add RTBH Comm.", "url": "admin.community"}, + ], +} + +# Customize dashboard - only include what you need +DASHBOARD = { + "rtbh": { + "name": "RTBH", + "macro_file": "macros.html", + "macro_tbody": "build_rtbh_tbody", + "macro_thead": "build_rules_thead", + "table_colspan": 5, + "table_columns": RTBH_COLUMNS, + }, + "whitelist": { + "name": "Whitelist", + "macro_file": "macros.html", + "macro_tbody": "build_whitelist_tbody", + "macro_thead": "build_rules_thead", + "table_colspan": 4, + "table_columns": WHITELIST_COLUMNS, + }, +}