Skip to content

Commit

Permalink
Add *-remove rule limits
Browse files Browse the repository at this point in the history
add operation limits to the remove rules as they were generating invalid rules
  • Loading branch information
JakeWnuk committed Nov 8, 2024
1 parent fb3e68f commit 938ff72
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ func AppendRules(items map[string]int, operation string, bypass bool, debug bool
// remove will remove characters then append
case "rule-append-remove", "append-remove":
for key, value := range items {
if len(key) > 15 {
if debug {
fmt.Fprintf(os.Stderr, "[!] Error: Key is too long for append-remove operation\n")
}
continue
}
rule := CharToRule(key, "$")
remove := LenToRule(key, "]")
appendRemoveRule := FormatCharToRuleOutput(remove, rule)
Expand Down Expand Up @@ -241,6 +247,12 @@ func PrependRules(items map[string]int, operation string, bypass bool, debug boo
// remove will remove characters then prepend
case "rule-prepend-remove", "prepend-remove":
for key, value := range items {
if len(key) > 15 {
if debug {
fmt.Fprintf(os.Stderr, "[!] Error: Key is too long for prepend-remove operation\n")
}
continue
}
rule := CharToRule(utils.ReverseString(key), "^")
remove := LenToRule(key, "[")
prependRemoveRule := FormatCharToRuleOutput(remove, rule)
Expand Down

0 comments on commit 938ff72

Please sign in to comment.