refactor(rules): improve termination detection and block parsing logic

Refactors the termination detection in the rules DSL to properly handle if-block and if-else-block commands.

Adds new functions `commandsTerminateInPre`, `commandTerminatesInPre`, and `ifElseBlockTerminatesInPre`
to recursively check if command sequences terminate in the pre-phase.

Also improves the Parse function to try block syntax first with proper error handling and fallback to YAML.

Includes test cases for dead code detection with terminating handlers in conditional blocks.
This commit is contained in:
yusing
2026-02-24 01:05:54 +08:00
parent 08de9086c3
commit 54be056530
5 changed files with 126 additions and 19 deletions

View File

@@ -420,7 +420,7 @@ func TestHTTPFlow_HeaderManipulation(t *testing.T) {
var rules Rules
err := parseRules(`
default {
{
remove resp_header X-Secret
add resp_header X-Custom-Header custom-value
}