feat(api): unify policy handling with default action updates
- Updated `evofw-firewall.sh` and related scripts to replace `policy_mode` with `default_action`, enhancing clarity and consistency in policy management. - Adjusted agent routes and evaluation logic to accommodate the new default action structure, ensuring backward compatibility with legacy modes. - Enhanced tests to validate the new default action behavior and its integration within the agent policy framework. - Refactored related components in the web interface to align with the updated policy handling, improving user experience and reducing confusion around policy modes.
This commit is contained in:
+5
-5
@@ -63,14 +63,14 @@ Install RSC:
|
||||
|
||||
1. Enroll (с `install_link_id` → агент Invited → Pending).
|
||||
2. Создаёт filter-правила `evofw-*` и address-list `EVOFW_DENY` / `EVOFW_ALLOW`.
|
||||
3. Scheduler `evofw-sync` каждую минуту: `GET /v1/agent/policy.rsc` → `/import` (списки + режим).
|
||||
3. Scheduler `evofw-sync` каждую минуту: `GET /v1/agent/policy.rsc` → `/import` (списки + default).
|
||||
|
||||
**Режим фильтра** задаётся на **наборе правил** (`/rules`), не на агенте:
|
||||
**Default action** задаётся на **агенте** (`default_action: accept | drop`):
|
||||
|
||||
- **blacklist** — по умолчанию ACCEPT; deny-CIDR блокируются
|
||||
- **whitelist** — по умолчанию DROP (forward); только allow-CIDR
|
||||
- **accept** — пакет вне deny/allow пропускается
|
||||
- **drop** — пакет вне deny/allow отбрасывается (forward)
|
||||
|
||||
Все наборы, назначенные агенту, должны иметь один режим.
|
||||
Цепочка всегда: deny-drop → allow-accept → default. Наборы несут только правила deny/allow, без exclusive mode.
|
||||
|
||||
## Force sync
|
||||
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
|
||||
1. **Enroll** — `POST /v1/agent/enroll` + `X-EvoFW-Seed` → pending agent
|
||||
2. **Approve** — UI/API → status approved
|
||||
3. **Policy** — `GET /v1/agent/policy` → deny/allow CIDRs + mode + hash
|
||||
3. **Policy** — `GET /v1/agent/policy` → deny/allow CIDRs + `default_action` + hash (`apply_version: 2`)
|
||||
4. **Apply** — agent пишет kernel rules, `POST /v1/agent/apply-report` + stats sample
|
||||
5. **Lists refresh** — cron каждые 5 мин (json_url / domains / evobgp_community)
|
||||
|
||||
## Политика
|
||||
|
||||
- Именованные **наборы правил** (`policy_sets`); агенту назначается **M:N** через `agent_policy_sets`
|
||||
- Правило в наборе: ровно один источник — IP-список (`list_id`), CIDR или DNS-имя (`hostname` → A/AAAA, кэш в `policy_rule_resolved`)
|
||||
- Правило в наборе: `action: deny | allow` + ровно один источник — IP-список (`list_id`), CIDR или DNS-имя (`hostname` → A/AAAA, кэш в `policy_rule_resolved`)
|
||||
- Evaluate: правила всех назначенных enabled-наборов (sort + priority) + `ip_overrides`
|
||||
- `blacklist` — default accept, apply deny set
|
||||
- `whitelist` — default drop, apply allow set (+ lo/established на Linux)
|
||||
- Overrides, смена наборов и refresh DNS/lists бампят `policy_generation`
|
||||
- Цепочка ядра **всегда**: deny → allow → `default_action` (`accept` | `drop` на агенте)
|
||||
- Exact overlap: `allow \ deny` (`conflicts_dropped`); deny wins
|
||||
- Overrides, смена наборов, `default_action` и refresh DNS/lists бампят `policy_generation`
|
||||
|
||||
## Auth
|
||||
|
||||
|
||||
@@ -7,15 +7,22 @@ EvoFirewall использует EvoBGP как **источник префикс
|
||||
В UI Settings или `settings` table:
|
||||
|
||||
- `evobgp_api_url` — base URL EvoBGP API
|
||||
- `evobgp_api_token` — API key (viewer+)
|
||||
- `evobgp_api_token` — API key (viewer+ / `bgp:directories:read`)
|
||||
|
||||
При refresh списка:
|
||||
## Refresh списка
|
||||
|
||||
1. `GET {api}/v1/directories/communities/{id}/prefixes` (если доступен)
|
||||
2. fallback `GET {api}/v1/lookup?q={community_id}`
|
||||
При refresh списка `evobgp_community`:
|
||||
|
||||
1. `GET {api}/v1/communities/{id}/prefixes?limit=5000`
|
||||
2. Ответ: `{ items: [{ prefix }], prefixes: string[], has_more, next_cursor }`
|
||||
3. Entries заменяются; generation агентов с правилами на этот list бампится
|
||||
|
||||
## Autocomplete в UI
|
||||
|
||||
`GET /api/v1/integrations/evobgp/communities` — proxy к EvoBGP `GET /v1/communities?limit=200` (нужны settings выше).
|
||||
|
||||
## Список
|
||||
|
||||
Создайте IP list type `evobgp_community` с `config.community_id`. Cron / кнопка Refresh обновляет entries и бампит generation агентов.
|
||||
Создайте IP list type `evobgp_community` с `config.community_id`. Cron / кнопка Refresh обновляет entries.
|
||||
|
||||
Firewall-подсистема в EvoBGP **удалена** (hard cutover) — клиенты переустанавливаются на EvoFirewall agents.
|
||||
|
||||
Reference in New Issue
Block a user