diff options
| author | bohwaz | 2024-03-23 21:41:27 +0100 |
|---|---|---|
| committer | Julien Voisin | 2024-03-24 17:37:59 +0100 |
| commit | 859d69a3e0b4b0afedd0f45df0f4bc4ff2a72d0e (patch) | |
| tree | 02c238b56239c198d8f59c18258551ae30bb5eca /scripts | |
| parent | 9b0cf1b7dee2b6830def207cd3de993346fac404 (diff) | |
Don't whitelist files if the function name is actually a method of a class
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/generate_rules.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/scripts/generate_rules.php b/scripts/generate_rules.php index f923e5d..3152342 100644 --- a/scripts/generate_rules.php +++ b/scripts/generate_rules.php | |||
| @@ -40,6 +40,8 @@ foreach($objects as $name => $object){ | |||
| 40 | $hash = '.hash("' . hash('sha256', $file_content) . '")'; | 40 | $hash = '.hash("' . hash('sha256', $file_content) . '")'; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | $prev_token = null; | ||
| 44 | |||
| 43 | foreach(token_get_all($file_content) as $token) { | 45 | foreach(token_get_all($file_content) as $token) { |
| 44 | if (!is_array($token)) { | 46 | if (!is_array($token)) { |
| 45 | continue; | 47 | continue; |
| @@ -49,9 +51,13 @@ foreach($objects as $name => $object){ | |||
| 49 | $token[1] = substr($token[1], 1); | 51 | $token[1] = substr($token[1], 1); |
| 50 | } | 52 | } |
| 51 | 53 | ||
| 52 | if (in_array($token[1], $functions_blacklist, true)) { | 54 | $prev_token_str = $prev_token[1] ?? null; |
| 55 | |||
| 56 | if (in_array($token[1], $functions_blacklist, true) && $prev_token_str !== '->' && $prev_token_str !== '::') { | ||
| 53 | $output[] = 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '")' . $hash . '.allow();' . "\n"; | 57 | $output[] = 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '")' . $hash . '.allow();' . "\n"; |
| 54 | } | 58 | } |
| 59 | |||
| 60 | $prev_token = $token; | ||
| 55 | } | 61 | } |
| 56 | } | 62 | } |
| 57 | foreach($functions_blacklist as $fun) { | 63 | foreach($functions_blacklist as $fun) { |
