Skip to content

Commit

Permalink
[Security Solution] Improve regexes processing KQL (#194215)
Browse files Browse the repository at this point in the history
## Summary

See linked ticket

(cherry picked from commit 6d8f85e)
  • Loading branch information
marshallmain committed Oct 4, 2024
1 parent 09bfadb commit 47f17b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const operators = ['and', 'or', 'not'];

export const removeKqlVariablesUsingRegex = (expression: string) => {
const myRegexp =
/(\s+)*(and|or|not){0,1}(\s+)*([\w\.\-\[\]]+)\s*:\s*"(\$[\w\.\-\(\)\[\]]+\$)"(\s+)*(and|or|not){0,1}(\s+)*/g;
/(\s*)(and|or|not){0,1}(\s*)([\w\.\-\[\]]+)\s*:\s*"(\$[\w\.\-\(\)\[\]]+\$)"(\s*)(and|or|not){0,1}(\s*)/g;
return expression.replace(myRegexp, replacer);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const replacement = (match: string, p1: string, p2: string) => {
};

export const replaceKqlCommasWithOrUsingRegex = (expression: string) => {
const myRegexp = /([\w\.\-\[\]]+)\s*:\s*"(([\w\.\-\(\)\[\]]+,[\w\.\-\(\)\[\]]+){1,})"/g;
const myRegexp = /([\w\.\-\[\]]+)\s*:\s*"(([\w\.\-\(\)\[\]]+)(,[\w\.\-\(\)\[\]]+){1,})"/g;
return expression.replace(myRegexp, replacement);
};

Expand Down

0 comments on commit 47f17b2

Please sign in to comment.