diff options
| author | Ben Fuhrmannek | 2021-08-16 15:47:01 +0200 |
|---|---|---|
| committer | Ben Fuhrmannek | 2021-08-16 15:47:01 +0200 |
| commit | 5148ded7268b569fd5e720f90b44645c83ac3e9e (patch) | |
| tree | 9d5c3035a7a85ffc27de7c32b441994a21a6347a /src/sp_disabled_functions.c | |
| parent | 9dc6b23a2219e809e665bac7d82567533751d39d (diff) | |
fincy new scanner/parser for config rules + fixed a few bugs along the way + fixed related unittests
Diffstat (limited to 'src/sp_disabled_functions.c')
| -rw-r--r-- | src/sp_disabled_functions.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index 84d8acf..ebb7d3f 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -69,28 +69,22 @@ static bool is_functions_list_matching(zend_execute_data* execute_data, | |||
| 69 | return false; | 69 | return false; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | static bool is_local_var_matching( | 72 | static bool is_local_var_matching(zend_execute_data* execute_data, const sp_disabled_function* const config_node) { |
| 73 | zend_execute_data* execute_data, | ||
| 74 | const sp_disabled_function* const config_node) { | ||
| 75 | zval* var_value = {0}; | 73 | zval* var_value = {0}; |
| 76 | 74 | ||
| 77 | var_value = sp_get_var_value(execute_data, config_node->var, false); | 75 | var_value = sp_get_var_value(execute_data, config_node->var, false); |
| 78 | if (var_value) { | 76 | if (var_value) { |
| 79 | if (Z_TYPE_P(var_value) == IS_ARRAY) { | 77 | if (Z_TYPE_P(var_value) == IS_ARRAY) { |
| 80 | if (config_node->key || config_node->r_key) { | 78 | if (config_node->key || config_node->r_key) { |
| 81 | if (sp_match_array_key(var_value, config_node->key, | 79 | if (sp_match_array_key(var_value, config_node->key, config_node->r_key)) { |
| 82 | config_node->r_key)) { | ||
| 83 | return true; | 80 | return true; |
| 84 | } | 81 | } |
| 85 | } else if (sp_match_array_value(var_value, config_node->value, | 82 | } else if (sp_match_array_value(var_value, config_node->value, config_node->r_value)) { |
| 86 | config_node->r_value)) { | ||
| 87 | return true; | 83 | return true; |
| 88 | } | 84 | } |
| 89 | } else { | 85 | } else { |
| 90 | zend_string const* const var_value_str = | 86 | zend_string const* const var_value_str = sp_zval_to_zend_string(var_value); |
| 91 | sp_zval_to_zend_string(var_value); | 87 | bool match = sp_match_value(var_value_str, config_node->value, config_node->r_value); |
| 92 | bool match = sp_match_value(var_value_str, config_node->value, | ||
| 93 | config_node->r_value); | ||
| 94 | 88 | ||
| 95 | if (true == match) { | 89 | if (true == match) { |
| 96 | return true; | 90 | return true; |
| @@ -555,24 +549,19 @@ ZEND_FUNCTION(eval_blacklist_callback) { | |||
| 555 | zend_string_release(tmp); | 549 | zend_string_release(tmp); |
| 556 | 550 | ||
| 557 | if (SNUFFLEUPAGUS_G(in_eval) > 0) { | 551 | if (SNUFFLEUPAGUS_G(in_eval) > 0) { |
| 558 | zend_string* filename = get_eval_filename(zend_get_executed_filename()); | 552 | // zend_string* filename = get_eval_filename(zend_get_executed_filename()); |
| 559 | const int line_number = zend_get_executed_lineno(TSRMLS_C); | 553 | // const int line_number = zend_get_executed_lineno(TSRMLS_C); |
| 560 | const sp_config_eval* config_eval = SNUFFLEUPAGUS_G(config).config_eval; | 554 | const sp_config_eval* config_eval = SNUFFLEUPAGUS_G(config).config_eval; |
| 561 | 555 | ||
| 562 | if (config_eval->dump) { | 556 | if (config_eval->dump) { |
| 563 | sp_log_request(config_eval->dump, config_eval->textual_representation, | 557 | sp_log_request(config_eval->dump, config_eval->textual_representation); |
| 564 | SP_TOKEN_EVAL_BLACKLIST); | ||
| 565 | } | 558 | } |
| 566 | if (config_eval->simulation) { | 559 | if (config_eval->simulation) { |
| 567 | sp_log_simulation("eval", | 560 | sp_log_simulation("eval", "A call to '%s' was tried in eval. logging it.", current_function_name); |
| 568 | "A call to %s was tried in eval, in %s:%d, logging it.", | ||
| 569 | current_function_name, ZSTR_VAL(filename), line_number); | ||
| 570 | } else { | 561 | } else { |
| 571 | sp_log_drop("eval", | 562 | sp_log_drop("eval", "A call to '%s' was tried in eval. dropping it.", current_function_name); |
| 572 | "A call to %s was tried in eval, in %s:%d, dropping it.", | ||
| 573 | current_function_name, ZSTR_VAL(filename), line_number); | ||
| 574 | } | 563 | } |
| 575 | efree(filename); | 564 | // efree(filename); |
| 576 | } | 565 | } |
| 577 | 566 | ||
| 578 | whitelisted: | 567 | whitelisted: |
