Skip to content

Commit 9a85c47

Browse files
committed
perf(rss): skip unused transaction expansion
1 parent 622eab5 commit 9a85c47

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

rules/engine_bundle.rss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ pub fn ctx_update(state: map<string>, id: int, raw_base: string, selector: strin
106106
}
107107

108108
// bundled from engine_operators.rss
109-
pub fn op_expand(state: map<string>, value: string) -> string { let mut out = value; let keys = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } out }
109+
pub fn op_expand(state: map<string>, value: string) -> string {
110+
let mut out: string = value;
111+
if contains(&out, "%{") { let keys: [string] = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } }
112+
out
113+
}
110114
pub fn sqli(value: string) -> bool { let text: string = lower(value); (contains(&text, " union ") && contains(&text, "select")) || contains(&text, "' or '") || contains(&text, "'or 1=1") || contains(&text, " or 1=1") || contains(&text, "sleep(") || contains(&text, "benchmark(") || contains(&text, "information_schema") }
111115
pub fn xss(value: string) -> bool { let text: string = lower(value); contains(&text, "<script") || contains(&text, "javascript:") || contains(&text, "onerror=") || contains(&text, "onload=") || (contains(&text, "<svg") && contains(&text, "on")) }
112116
pub fn phrase(pattern: string, value: string) -> bool { let phrases: [string] = if contains(&pattern, "\n") => { string_split_literal(pattern, "\n") } else => { string_split_literal(pattern, " ") }; let haystack: string = lower(value); let mut found = false; for i in 0..phrases.length { let item: string = lower((&phrases)[i]); if item != "" && contains(&haystack, item) { found = true; break; } } found }

rules/engine_operators.rss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
use re;
22
use engine_text;
3-
pub fn op_expand(state: map<string>, value: string) -> string { let mut out = value; let keys = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if engine_text::starts(&key, "tx.") { out = engine_text::replace(out, "%{" + key + "}", (&state)[key]); } } out }
3+
pub fn op_expand(state: map<string>, value: string) -> string {
4+
let mut out: string = value;
5+
if engine_text::contains(&out, "%{") { let keys: [string] = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if engine_text::starts(&key, "tx.") { out = engine_text::replace(out, "%{" + key + "}", (&state)[key]); } } }
6+
out
7+
}
48
pub fn sqli(value: string) -> bool { let text: string = engine_text::lower(value); (engine_text::contains(&text, " union ") && engine_text::contains(&text, "select")) || engine_text::contains(&text, "' or '") || engine_text::contains(&text, "'or 1=1") || engine_text::contains(&text, " or 1=1") || engine_text::contains(&text, "sleep(") || engine_text::contains(&text, "benchmark(") || engine_text::contains(&text, "information_schema") }
59
pub fn xss(value: string) -> bool { let text: string = engine_text::lower(value); engine_text::contains(&text, "<script") || engine_text::contains(&text, "javascript:") || engine_text::contains(&text, "onerror=") || engine_text::contains(&text, "onload=") || (engine_text::contains(&text, "<svg") && engine_text::contains(&text, "on")) }
610
pub fn phrase(pattern: string, value: string) -> bool { let phrases: [string] = if engine_text::contains(&pattern, "\n") => { string_split_literal(pattern, "\n") } else => { string_split_literal(pattern, " ") }; let haystack: string = engine_text::lower(value); let mut found = false; for i in 0..phrases.length { let item: string = engine_text::lower((&phrases)[i]); if item != "" && engine_text::contains(&haystack, item) { found = true; break; } } found }

rules/pd_edge_waf.rss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ pub fn ctx_update(state: map<string>, id: int, raw_base: string, selector: strin
108108
}
109109

110110
// bundled from engine_operators.rss
111-
pub fn op_expand(state: map<string>, value: string) -> string { let mut out = value; let keys = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } out }
111+
pub fn op_expand(state: map<string>, value: string) -> string {
112+
let mut out: string = value;
113+
if contains(&out, "%{") { let keys: [string] = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } }
114+
out
115+
}
112116
pub fn sqli(value: string) -> bool { let text: string = lower(value); (contains(&text, " union ") && contains(&text, "select")) || contains(&text, "' or '") || contains(&text, "'or 1=1") || contains(&text, " or 1=1") || contains(&text, "sleep(") || contains(&text, "benchmark(") || contains(&text, "information_schema") }
113117
pub fn xss(value: string) -> bool { let text: string = lower(value); contains(&text, "<script") || contains(&text, "javascript:") || contains(&text, "onerror=") || contains(&text, "onload=") || (contains(&text, "<svg") && contains(&text, "on")) }
114118
pub fn phrase(pattern: string, value: string) -> bool { let phrases: [string] = if contains(&pattern, "\n") => { string_split_literal(pattern, "\n") } else => { string_split_literal(pattern, " ") }; let haystack: string = lower(value); let mut found = false; for i in 0..phrases.length { let item: string = lower((&phrases)[i]); if item != "" && contains(&haystack, item) { found = true; break; } } found }

rules/ruleset_bundle.rss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ pub fn ctx_update(state: map<string>, id: int, raw_base: string, selector: strin
106106
}
107107

108108
// bundled from engine_operators.rss
109-
pub fn op_expand(state: map<string>, value: string) -> string { let mut out = value; let keys = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } out }
109+
pub fn op_expand(state: map<string>, value: string) -> string {
110+
let mut out: string = value;
111+
if contains(&out, "%{") { let keys: [string] = (&state).keys; for i in 0..keys.length { let key: string = (&keys)[i]; if starts(&key, "tx.") { out = replace(out, "%{" + key + "}", (&state)[key]); } } }
112+
out
113+
}
110114
pub fn sqli(value: string) -> bool { let text: string = lower(value); (contains(&text, " union ") && contains(&text, "select")) || contains(&text, "' or '") || contains(&text, "'or 1=1") || contains(&text, " or 1=1") || contains(&text, "sleep(") || contains(&text, "benchmark(") || contains(&text, "information_schema") }
111115
pub fn xss(value: string) -> bool { let text: string = lower(value); contains(&text, "<script") || contains(&text, "javascript:") || contains(&text, "onerror=") || contains(&text, "onload=") || (contains(&text, "<svg") && contains(&text, "on")) }
112116
pub fn phrase(pattern: string, value: string) -> bool { let phrases: [string] = if contains(&pattern, "\n") => { string_split_literal(pattern, "\n") } else => { string_split_literal(pattern, " ") }; let haystack: string = lower(value); let mut found = false; for i in 0..phrases.length { let item: string = lower((&phrases)[i]); if item != "" && contains(&haystack, item) { found = true; break; } } found }

0 commit comments

Comments
 (0)