diff options
| author | xXx-caillou-xXx | 2018-07-13 10:36:50 +0200 |
|---|---|---|
| committer | jvoisin | 2018-07-13 08:36:50 +0000 |
| commit | 7963580d72a358975133f86f01de2d2eab08ba38 (patch) | |
| tree | 4bec345d70f687a2a6002b36e2f2fc79318959f6 /src/sp_config.h | |
| parent | 12b740bc7bb01ffe397cecc5b6fa25b136304911 (diff) | |
Massively optimize how rules are handled
This commit does a lot of things:
- Use hashtables instead of lists to store the rules
- Rules that can be applied at launch time won't be tried at runtime
- Improve feedback when writing nonsensical rules
- Make intensive use of `zend_string` instead of `char*`
Diffstat (limited to 'src/sp_config.h')
| -rw-r--r-- | src/sp_config.h | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/src/sp_config.h b/src/sp_config.h index 979feda..cfc3c8f 100644 --- a/src/sp_config.h +++ b/src/sp_config.h | |||
| @@ -38,15 +38,15 @@ typedef struct { | |||
| 38 | } sp_cidr; | 38 | } sp_cidr; |
| 39 | 39 | ||
| 40 | typedef struct { | 40 | typedef struct { |
| 41 | char *encryption_key; | 41 | zend_string *encryption_key; |
| 42 | char *cookies_env_var; | 42 | zend_string *cookies_env_var; |
| 43 | } sp_config_global; | 43 | } sp_config_global; |
| 44 | 44 | ||
| 45 | typedef struct { | 45 | typedef struct { |
| 46 | bool enable; | 46 | bool enable; |
| 47 | bool simulation; | 47 | bool simulation; |
| 48 | char *dump; | 48 | zend_string *dump; |
| 49 | char *textual_representation; | 49 | zend_string *textual_representation; |
| 50 | } sp_config_readonly_exec; | 50 | } sp_config_readonly_exec; |
| 51 | 51 | ||
| 52 | typedef struct { bool enable; } sp_config_global_strict; | 52 | typedef struct { bool enable; } sp_config_global_strict; |
| @@ -62,7 +62,7 @@ typedef struct { bool enable; } sp_config_disable_xxe; | |||
| 62 | typedef struct { | 62 | typedef struct { |
| 63 | enum samesite_type { strict = 1, lax = 2 } samesite; | 63 | enum samesite_type { strict = 1, lax = 2 } samesite; |
| 64 | bool encrypt; | 64 | bool encrypt; |
| 65 | char *name; | 65 | zend_string *name; |
| 66 | sp_pcre *name_r; | 66 | sp_pcre *name_r; |
| 67 | bool simulation; | 67 | bool simulation; |
| 68 | } sp_cookie; | 68 | } sp_cookie; |
| @@ -75,21 +75,21 @@ typedef struct { | |||
| 75 | typedef struct { | 75 | typedef struct { |
| 76 | bool enable; | 76 | bool enable; |
| 77 | bool simulation; | 77 | bool simulation; |
| 78 | char *dump; | 78 | zend_string *dump; |
| 79 | char *textual_representation; | 79 | zend_string *textual_representation; |
| 80 | } sp_config_unserialize; | 80 | } sp_config_unserialize; |
| 81 | 81 | ||
| 82 | typedef struct { | 82 | typedef struct { |
| 83 | char *textual_representation; | 83 | zend_string *textual_representation; |
| 84 | 84 | ||
| 85 | char *filename; | 85 | zend_string *filename; |
| 86 | sp_pcre *r_filename; | 86 | sp_pcre *r_filename; |
| 87 | 87 | ||
| 88 | char *function; | 88 | zend_string *function; |
| 89 | sp_pcre *r_function; | 89 | sp_pcre *r_function; |
| 90 | sp_list_node *functions_list; | 90 | sp_list_node *functions_list; |
| 91 | 91 | ||
| 92 | char *hash; | 92 | zend_string *hash; |
| 93 | int simulation; | 93 | int simulation; |
| 94 | 94 | ||
| 95 | sp_tree *param; | 95 | sp_tree *param; |
| @@ -98,18 +98,18 @@ typedef struct { | |||
| 98 | int pos; | 98 | int pos; |
| 99 | unsigned int line; | 99 | unsigned int line; |
| 100 | 100 | ||
| 101 | char *ret; | ||
| 102 | sp_pcre *r_ret; | 101 | sp_pcre *r_ret; |
| 102 | zend_string *ret; | ||
| 103 | sp_php_type ret_type; | 103 | sp_php_type ret_type; |
| 104 | 104 | ||
| 105 | sp_pcre *value_r; | 105 | sp_pcre *r_value; |
| 106 | char *value; | 106 | zend_string *value; |
| 107 | 107 | ||
| 108 | sp_pcre *r_key; | 108 | sp_pcre *r_key; |
| 109 | char *key; | 109 | zend_string *key; |
| 110 | 110 | ||
| 111 | char *dump; | 111 | zend_string *dump; |
| 112 | char *alias; | 112 | zend_string *alias; |
| 113 | bool param_is_array; | 113 | bool param_is_array; |
| 114 | bool var_is_array; | 114 | bool var_is_array; |
| 115 | sp_list_node *param_array_keys; | 115 | sp_list_node *param_array_keys; |
| @@ -126,8 +126,8 @@ typedef struct { | |||
| 126 | sp_list_node *blacklist; | 126 | sp_list_node *blacklist; |
| 127 | sp_list_node *whitelist; | 127 | sp_list_node *whitelist; |
| 128 | bool simulation; | 128 | bool simulation; |
| 129 | char *dump; | 129 | zend_string *dump; |
| 130 | char *textual_representation; | 130 | zend_string *textual_representation; |
| 131 | } sp_config_eval; | 131 | } sp_config_eval; |
| 132 | 132 | ||
| 133 | typedef struct { | 133 | typedef struct { |
| @@ -139,14 +139,7 @@ typedef struct { | |||
| 139 | } sp_config_cookie; | 139 | } sp_config_cookie; |
| 140 | 140 | ||
| 141 | typedef struct { | 141 | typedef struct { |
| 142 | sp_list_node | 142 | zend_string *script; |
| 143 | *construct_include; // list of rules for `(include|require)_(once)?` | ||
| 144 | sp_list_node *construct_eval; | ||
| 145 | sp_list_node *construct_echo; | ||
| 146 | } sp_config_disabled_constructs; | ||
| 147 | |||
| 148 | typedef struct { | ||
| 149 | char *script; | ||
| 150 | bool simulation; | 143 | bool simulation; |
| 151 | bool enable; | 144 | bool enable; |
| 152 | } sp_config_upload_validation; | 145 | } sp_config_upload_validation; |
| @@ -155,8 +148,6 @@ typedef struct { | |||
| 155 | sp_config_random *config_random; | 148 | sp_config_random *config_random; |
| 156 | sp_config_sloppy *config_sloppy; | 149 | sp_config_sloppy *config_sloppy; |
| 157 | sp_config_unserialize *config_unserialize; | 150 | sp_config_unserialize *config_unserialize; |
| 158 | sp_config_disabled_functions *config_disabled_functions; | ||
| 159 | sp_config_disabled_functions *config_disabled_functions_ret; | ||
| 160 | sp_config_readonly_exec *config_readonly_exec; | 151 | sp_config_readonly_exec *config_readonly_exec; |
| 161 | sp_config_upload_validation *config_upload_validation; | 152 | sp_config_upload_validation *config_upload_validation; |
| 162 | sp_config_cookie *config_cookie; | 153 | sp_config_cookie *config_cookie; |
| @@ -164,9 +155,16 @@ typedef struct { | |||
| 164 | sp_config_auto_cookie_secure *config_auto_cookie_secure; | 155 | sp_config_auto_cookie_secure *config_auto_cookie_secure; |
| 165 | sp_config_global_strict *config_global_strict; | 156 | sp_config_global_strict *config_global_strict; |
| 166 | sp_config_disable_xxe *config_disable_xxe; | 157 | sp_config_disable_xxe *config_disable_xxe; |
| 167 | sp_config_disabled_constructs *config_disabled_constructs; | ||
| 168 | sp_config_eval *config_eval; | 158 | sp_config_eval *config_eval; |
| 169 | sp_config_session *config_session; | 159 | sp_config_session *config_session; |
| 160 | bool hook_execute; | ||
| 161 | |||
| 162 | HashTable *config_disabled_functions; | ||
| 163 | HashTable *config_disabled_functions_hooked; | ||
| 164 | HashTable *config_disabled_functions_ret; | ||
| 165 | HashTable *config_disabled_functions_ret_hooked; | ||
| 166 | sp_config_disabled_functions *config_disabled_functions_reg; | ||
| 167 | sp_config_disabled_functions *config_disabled_functions_reg_ret; | ||
| 170 | } sp_config; | 168 | } sp_config; |
| 171 | 169 | ||
| 172 | typedef struct { | 170 | typedef struct { |
