From 50bb0ed72d5c221d40f16690d980db5e7ccee46a Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sun, 8 Oct 2017 23:23:02 +0200 Subject: Improve a bit the script to generate rules --- scripts/generate_rules.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/generate_rules.php b/scripts/generate_rules.php index e286ef1..a14198e 100644 --- a/scripts/generate_rules.php +++ b/scripts/generate_rules.php @@ -11,10 +11,12 @@ $functions_blacklist = ['shell_exec', 'exec', 'passthru', 'php_uname', 'popen', 'proc_terminate', 'proc_open', 'proc_get_status', 'dl', 'pnctl_exec', 'pnctl_fork', 'assert', 'system']; -$extensions = ['php', 'php7', 'php5']; +$extensions = ['php', 'php7', 'php5', 'inc']; $path = realpath($argv[1]); +$output = Array(); + $objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); foreach($objects as $name => $object){ if (FALSE === in_array (pathinfo($name, PATHINFO_EXTENSION), $extensions, true)) { @@ -33,11 +35,14 @@ foreach($objects as $name => $object){ if ('' === $hash) { $hash = hash('sha256', $file_content); } - echo 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '").hash("' . $hash . '").allow();' . "\n"; + $output[] = 'sp.disable_function.function("' . $token[1] . '").filename("' . $name . '").hash("' . $hash . '").allow();' . "\n"; } } } foreach($functions_blacklist as $fun) { - echo 'sp.disable_function.function("' . $fun . '").drop();' . "\n"; - + $output[] = 'sp.disable_function.function("' . $fun . '").drop();' . "\n"; } + +foreach (array_unique($output) as $line) { + echo $line; + } -- cgit v1.3