Skip to content
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
1 change: 1 addition & 0 deletions Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
'custom_css' => {{ MISP_CUSTOM_CSS | str }},
'tmpdir' => '/tmp',
'log_client_ip_header' => 'HTTP_X_FORWARDED_FOR',
'trusted_proxies' => {{ MISP_TRUSTED_PROXIES | str }},
'thumbnail_in_redis' => true,
'self_update' => false,
'python_bin' => '/usr/bin/python3.12',
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ For production usage, please:
* change passwords for MariaDB and Redis,
* modify environment variables to requested values,
* deploy reverse proxy (for example `nginx`) before MISP to handle HTTPS connections.
* do not forget to send the proper `[X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For)` header
* do not forget to send the proper [`X-Forwarded-For`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For) header
* you also have to set `MISP_TRUSTED_PROXIES` so MISP will accept `X-Forwarded-For` from that server

### Usage in air-gapped environment

Expand Down Expand Up @@ -116,6 +117,7 @@ By default, MISP requires Redis. MISP will connect to Redis defined in `REDIS_HO
* `MISP_MODULE_URL` (optional, string) - full URL to MISP modules
* `MISP_DEBUG` (optional, boolean, default `false`) - enable debug mode (do not enable on production environment)
* `MISP_OUTPUT_COMPRESSION` (optional, boolean, default `true`) - enable or disable gzip or brotli output compression
* `MISP_TRUSTED_PROXIES` (optional, string) - a comma-separated list of trusted IPv4 or IPv6 addresses or network ranges from which the `X-Forwarded-For` header is accepted.

[Check more variables that allow MISP customization.](docs/CUSTOMIZATION.md)

Expand Down
15 changes: 15 additions & 0 deletions bin/misp_create_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import hashlib
import argparse
import ipaddress
from urllib.parse import urlparse, quote_plus
from typing import Optional, Type, Callable, Any, NoReturn, List, Union, Tuple
from jinja2 import Environment
Expand Down Expand Up @@ -101,6 +102,19 @@ def check_oidc_code_challenge(variable_name: str, value: str):
raise ValueError(f"Environment variable '{variable_name}' value is not valid, must be one of {valid_methods}")


def check_is_list_ips(variable_name: str, value: str):
for item in value.split(","):
item = item.strip()
if not item:
continue
try:
ipaddress.ip_network(item)
except ValueError as e:
raise ValueError(
f"Environment variable '{variable_name}' contains "
f"an invalid IP address or network '{item}': {e}")


def dict_parser(variable_name: str, value: str, seperator: str = ',', key_value_delimiter: str = '=', variable_description: str = "") -> dict:
value = value.strip()
if len(value) == 0:
Expand Down Expand Up @@ -244,6 +258,7 @@ def parse_mysql_settings(variable_name: str, value: str) -> dict:
"MISP_HOME_LOGO": Option(),
"MISP_FOOTER_LOGO": Option(),
"MISP_CUSTOM_CSS": Option(),
"MISP_TRUSTED_PROXIES": Option(validation=check_is_list_ips),
# Security
"GNUPG_SIGN": Option(typ=bool, default=False),
"GNUPG_PRIVATE_KEY_PASSWORD": Option(sensitive=True),
Expand Down
Loading