refactor(api): enhance host firewall collection and JSON output
Build and Push EvoFirewall Docker Image / build-and-push (push) Successful in 1m40s
Build and Push EvoFirewall Docker Image / create-release (push) Skipped

- Improved the `collect_host_firewall` function in `evofw-firewall.sh` to utilize temporary files for better handling of large rule sets, avoiding ARG_MAX limitations.
- Updated the JSON output structure to omit null/empty optional fields, ensuring compatibility with historical data formats.
- Enhanced error handling and logging for the firewall collection process, providing clearer diagnostics in case of failures.
- Adjusted related tests to accommodate changes in the expected output format, ensuring robust validation of the host firewall snapshot functionality.

These changes enhance the reliability and clarity of the host firewall data collection process, improving overall monitoring capabilities.
This commit is contained in:
Denozordec
2026-08-11 15:33:10 +07:00
parent 43f5ac2525
commit bfaed511bd
3 changed files with 149 additions and 79 deletions
+10 -10
View File
@@ -245,15 +245,15 @@ export const hostFwBackendSchema = z.enum([
export const hostFwRuleSchema = z.object({
ownership: hostFwOwnershipSchema,
backend: hostFwBackendSchema,
table: z.string().max(128).optional(),
chain: z.string().max(128).optional(),
action: z.string().max(64).optional(),
protocol: z.string().max(16).optional(),
dport: z.string().max(64).optional(),
sport: z.string().max(64).optional(),
saddr: z.string().max(128).optional(),
daddr: z.string().max(128).optional(),
comment: z.string().max(256).optional(),
table: z.string().max(128).nullish(),
chain: z.string().max(128).nullish(),
action: z.string().max(64).nullish(),
protocol: z.string().max(16).nullish(),
dport: z.string().max(64).nullish(),
sport: z.string().max(64).nullish(),
saddr: z.string().max(128).nullish(),
daddr: z.string().max(128).nullish(),
comment: z.string().max(256).nullish(),
raw: z.string().max(512),
})
@@ -261,7 +261,7 @@ export const hostListenerSchema = z.object({
protocol: z.string().max(16),
port: z.number().int().min(0).max(65535),
address: z.string().max(128),
process: z.string().max(128).optional(),
process: z.string().max(128).nullish(),
})
export const hostFirewallPayloadSchema = z.object({