(cls, get_cfg: Callable[[tuple[str, str]], Any])
| 104 | |
| 105 | @classmethod |
| 106 | def load(cls, get_cfg: Callable[[tuple[str, str]], Any]) -> "EngineConfig": |
| 107 | def _as_int_list(value: Any) -> list[int]: |
| 108 | if value is None: |
| 109 | return [] |
| 110 | if isinstance(value, list): |
| 111 | out: list[int] = [] |
| 112 | for v in value: |
| 113 | try: |
| 114 | out.append(int(v)) |
| 115 | except (TypeError, ValueError): |
| 116 | continue |
| 117 | return out |
| 118 | return [] |
| 119 | |
| 120 | heuristics = bool(get_cfg(("analysis", "heuristics"))) |
| 121 | iocs = bool(get_cfg(("analysis", "iocs"))) |
| 122 | whitelist = bool(get_cfg(("analysis", "whitelist"))) |
| 123 | active = bool(get_cfg(("analysis", "active"))) |
| 124 | userlang = str(get_cfg(("frontend", "user_lang")) or "en") |
| 125 | max_ports_raw = get_cfg(("analysis", "max_ports")) |
| 126 | try: |
| 127 | max_ports = int(max_ports_raw) |
| 128 | except (TypeError, ValueError): |
| 129 | max_ports = 1024 |
| 130 | |
| 131 | http_default_ports = _as_int_list(get_cfg(("analysis", "http_default_ports"))) |
| 132 | tls_default_ports = _as_int_list(get_cfg(("analysis", "tls_default_ports"))) |
| 133 | indicators_types_raw = get_cfg(("analysis", "indicators_types")) or [] |
| 134 | indicators_types = [str(x) for x in indicators_types_raw] if isinstance(indicators_types_raw, list) else [] |
| 135 | |
| 136 | return cls( |
| 137 | heuristics_analysis=heuristics, |
| 138 | iocs_analysis=iocs, |
| 139 | whitelist_analysis=whitelist, |
| 140 | active_analysis=active, |
| 141 | userlang=userlang, |
| 142 | max_ports=max_ports, |
| 143 | http_default_ports=http_default_ports, |
| 144 | tls_default_ports=tls_default_ports, |
| 145 | indicators_types=indicators_types, |
| 146 | ) |
| 147 | |
| 148 | |
| 149 | class WhitelistIndex: |
no outgoing calls
no test coverage detected