From d538eef4fb62174ea32d94e28f1f5a20c5094426 Mon Sep 17 00:00:00 2001 From: xXx-caillou-xXx Date: Fri, 17 Aug 2018 15:44:21 +0200 Subject: Add ignore hash feature in `generate_rules.php` (#208) https://github.com/nbs-system/snuffleupagus/issues/206--- scripts/generate_rules.php | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'scripts/generate_rules.php') diff --git a/scripts/generate_rules.php b/scripts/generate_rules.php index 1fa40d1..68936ad 100644 --- a/scripts/generate_rules.php +++ b/scripts/generate_rules.php @@ -1,19 +1,29 @@ $object){ $hash = ''; $file_content = file_get_contents($name); + if ($useHash) { + $hash = '.hash("' . hash('sha256', $file_content) . '")'; + } + foreach(token_get_all($file_content) as $token) { if ($token[0] != 319) { continue; } if (in_array($token[1], $functions_blacklist, true)) { - if ('' === $hash) { - $hash = hash('sha256', $file_content); - } - $output[] = 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '").hash("' . $hash . '").allow();' . "\n"; + $output[] = 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '")' . $hash . '.allow();' . "\n"; } } } @@ -45,4 +56,4 @@ foreach($functions_blacklist as $fun) { foreach (array_unique($output) as $line) { echo $line; - } +} -- cgit v1.3