Selaa lähdekoodia

【程序目录】优化过滤

吴昊天 1 vuosi sitten
vanhempi
commit
03272a2e6d

+ 3 - 3
crmeb/app/Request.php

@@ -34,7 +34,7 @@ class Request extends \think\Request
      * @var array
      */
     protected $except = ['menu_path', 'api_url', 'unique_auth',
-                         'description', 'custom_form', 'content', 'tableField', 'url', 'customCode'];
+        'description', 'custom_form', 'content', 'tableField', 'url', 'customCode', 'value', 'refund_reason_wap_img'];
 
     /**
      * 获取请求的数据
@@ -83,8 +83,8 @@ class Request extends \think\Request
         $result = [];
         foreach ($array as $key => $value) {
             if (is_array($value)) {
-                // 如果值是数组,递归调用 filterArrayValues
-                $result[$key] = $this->filterArrayValues($value);
+                // 如果值是数组,并且不在不过滤变量名里面,递归调用 filterArrayValues,否则直接赋值
+                $result[$key] = in_array($key, $this->except) ? $value : $this->filterArrayValues($value);
             } else {
                 if (in_array($key, $this->except) || is_int($value) || is_null($value)) {
                     $result[$key] = $value;

+ 3 - 0
crmeb/app/adminapi/controller/v1/setting/SystemConfig.php

@@ -376,6 +376,9 @@ class SystemConfig extends AuthController
         if (isset($post['refund_time_available'])) {
             if (!ctype_digit($post['refund_time_available'])) return app('json')->fail('售后期限必须为大于0的整数');
         }
+        if (isset($post['param_filter_data'])) {
+            $post['param_filter_data'] = base64_encode($post['param_filter_data']);
+        }
         if (isset($post['sms_save_type']) && sys_config('sms_account', '') != '') return app('json')->success(100001);
         foreach ($post as $k => $v) {
             $config_one = $this->services->getOne(['menu_name' => $k]);

+ 1 - 23
crmeb/app/common.php

@@ -623,29 +623,7 @@ if (!function_exists('filter_str')) {
      */
     function filter_str($str)
     {
-        $rules = [
-            '/\.\./', // 禁用包含 ../ 的参数
-            '/\<\?/', // 禁止 php 脚本出现
-            '/\bor\b.*=.*/i', // 匹配 'or 1=1',防止 SQL 注入(注意边界词 \b 和不区分大小写 i 修饰符)
-            '/(select[\s\S]*?)(from|limit)/i', // 防止 SQL 注入
-            '/(union[\s\S]*?select)/i', // 防止 SQL 注入
-            '/(having|updatexml|extractvalue)/i', // 防止 SQL 注入
-            '/sleep\((\s*)(\d*)(\s*)\)/i', // 防止 SQL 盲注
-            '/benchmark\((.*)\,(.*)\)/i', // 防止 SQL 盲注
-            '/base64_decode\(/i', // 防止 SQL 变种注入
-            '/(?:from\W+information_schema\W)/i', // 注意这里的 (?:...) 是不合法的,应该是 (?:...) 表示非捕获组,但通常我们不需要这个
-            '/(?:current_|user|database|schema|connection_id)\s*\(/i', // 防止 SQL 注入(注意去掉了不必要的 (?:...))
-            '/(?:etc\/\W*passwd)/i', // 防止窥探 Linux 用户信息
-            '/into(\s+)(?:dump|out)file\s*/i', // 禁用 MySQL 导出函数
-            '/group\s+by.+\(/i', // 防止 SQL 注入
-            '/(?:define|eval|file_get_contents|include|require|require_once|shell_exec|phpinfo|system|passthru|preg_\w+|execute|echo|print|print_r|var_dump|(fp)open|alert|showmodaldialog)\(/i', // 禁用 webshell 相关某些函数
-            '/(gopher|doc|php|glob|file|phar|zlib|ftp|ldap|dict|ogg|data)\:\/\//i', // 防止一些协议攻击(注意协议后的三个斜杠)
-            '/\$_(GET|POST|COOKIE|FILES|SESSION|ENV|GLOBALS|SERVER)\[/i', // 禁用一些内置变量,注意 PHP 变量名通常是大写的
-            '/<(iframe|script|body|img|layer|div|meta|style|base|object|input)/i', // 防止 XSS 标签植入
-            '/(onmouseover|onerror|onload|onclick)\=/i', // 防止 XSS 事件植入
-            '/\|\|.*?(?:ls|pwd|whoami|ll|ifconfig|ipconfig|&&|chmod|cd|mkdir|rmdir|cp|mv)/i', // 防止执行 shell(注意去掉了不合适的 ifconfog)
-            '/\sand\s+.*=.*/i' // 匹配 and 1=1
-        ];
+        $rules = preg_split('/\r\n|\r|\n/', base64_decode(sys_config('param_filter_data')));
         if (filter_var($str, FILTER_VALIDATE_URL)) {
             $url = parse_url($str);
             if (!isset($url['scheme'])) return $str;

+ 3 - 0
crmeb/app/services/system/config/SystemConfigServices.php

@@ -475,6 +475,9 @@ class SystemConfigServices extends BaseServices
     public function createTextareaForm(array $data)
     {
         $data['value'] = json_decode($data['value'], true) ?: '';
+        if ($data['menu_name'] == 'param_filter_data') {
+            $data['value'] = base64_decode($data['value']);
+        }
         $formbuider[] = $this->builder->textarea($data['menu_name'], $data['info'], $data['value'])->placeholder($data['desc'])->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 4 - 2
crmeb/public/install/crmeb.sql