Add filter discovery endpoints with active/inactive status (Task 2.1)
- Add list_filters() and get_filter() to config_file_service.py:
scans filter.d/, parses [Definition] + [Init] sections, merges .local
overrides, and cross-references running jails to set active/used_by_jails
- Add FilterConfig.active, used_by_jails, source_file, has_local_override
fields to the Pydantic model; add FilterListResponse and FilterNotFoundError
- Add GET /api/config/filters and GET /api/config/filters/{name} to config.py
- Remove the shadowed GET /api/config/filters list route from file_config.py;
rename GET /api/config/filters/{name} raw variant to /filters/{name}/raw
- Update frontend: fetchFilterFiles() adapts FilterListResponse -> ConfFilesResponse;
add fetchFilters() and fetchFilter() to api/config.ts; remove unused
fetchFilterFiles/fetchActionFiles calls from useConfigActiveStatus
- Fix ConfigPageLogPath test mock to include fetchInactiveJails and related
exports introduced by Stage 1
- Backend: 169 tests pass, mypy --strict clean, ruff clean
- Frontend: 63 tests pass, tsc --noEmit clean, eslint clean
This commit is contained in:
@@ -99,12 +99,23 @@ vi.mock("../../api/config", () => ({
|
||||
fetchFilterFile: vi.fn(),
|
||||
updateFilterFile: vi.fn(),
|
||||
createFilterFile: vi.fn(),
|
||||
fetchFilters: vi.fn().mockResolvedValue({ filters: [], total: 0 }),
|
||||
fetchFilter: vi.fn(),
|
||||
fetchActionFiles: mockFetchActionFiles,
|
||||
fetchActionFile: vi.fn(),
|
||||
updateActionFile: vi.fn(),
|
||||
createActionFile: vi.fn(),
|
||||
previewLog: vi.fn(),
|
||||
testRegex: vi.fn(),
|
||||
fetchInactiveJails: vi.fn().mockResolvedValue({ jails: [], total: 0 }),
|
||||
activateJail: vi.fn(),
|
||||
deactivateJail: vi.fn(),
|
||||
fetchParsedFilter: vi.fn(),
|
||||
updateParsedFilter: vi.fn(),
|
||||
fetchParsedAction: vi.fn(),
|
||||
updateParsedAction: vi.fn(),
|
||||
fetchParsedJailFile: vi.fn(),
|
||||
updateParsedJailFile: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../../api/jails", () => ({
|
||||
|
||||
@@ -23,6 +23,10 @@ const mockConfig: FilterConfig = {
|
||||
maxlines: null,
|
||||
datepattern: null,
|
||||
journalmatch: null,
|
||||
active: false,
|
||||
used_by_jails: [],
|
||||
source_file: "/etc/fail2ban/filter.d/sshd.conf",
|
||||
has_local_override: false,
|
||||
};
|
||||
|
||||
function renderForm(name: string) {
|
||||
|
||||
Reference in New Issue
Block a user