diff options
| author | kkadosh | 2018-03-02 13:31:56 +0000 |
|---|---|---|
| committer | jvoisin | 2018-03-02 14:31:56 +0100 |
| commit | 17a09fafa2b569f0ce548220fd099cdf88e3a71e (patch) | |
| tree | 7d07f6ba92635959fbae9b1ec9fa6470d3bf6576 /src/sp_execute.c | |
| parent | bdd2cfc430d4b841c24a6c08e7934d667bdc6637 (diff) | |
Add .dump() for eval whitelist/blacklist + simulation mode for whitelist
Diffstat (limited to 'src/sp_execute.c')
| -rw-r--r-- | src/sp_execute.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/sp_execute.c b/src/sp_execute.c index 5cf139a..1517134 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -51,6 +51,8 @@ static void is_builtin_matching(const char *restrict const filename, | |||
| 51 | 51 | ||
| 52 | static void ZEND_HOT | 52 | static void ZEND_HOT |
| 53 | is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { | 53 | is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { |
| 54 | sp_config_eval *eval = SNUFFLEUPAGUS_G(config).config_eval; | ||
| 55 | |||
| 54 | if (EXPECTED(0 == SNUFFLEUPAGUS_G(in_eval))) { | 56 | if (EXPECTED(0 == SNUFFLEUPAGUS_G(in_eval))) { |
| 55 | return; | 57 | return; |
| 56 | } | 58 | } |
| @@ -71,11 +73,25 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { | |||
| 71 | 73 | ||
| 72 | if (EXPECTED(NULL != current_function)) { | 74 | if (EXPECTED(NULL != current_function)) { |
| 73 | if (UNEXPECTED(false == check_is_in_eval_whitelist(current_function))) { | 75 | if (UNEXPECTED(false == check_is_in_eval_whitelist(current_function))) { |
| 74 | sp_log_msg( | 76 | if (eval->dump) { |
| 75 | "Eval_whitelist", SP_LOG_DROP, | 77 | sp_log_request( |
| 76 | "The function '%s' isn't in the eval whitelist, dropping its call.", | 78 | SNUFFLEUPAGUS_G(config).config_eval->dump, |
| 77 | current_function); | 79 | SNUFFLEUPAGUS_G(config).config_eval->textual_representation, |
| 78 | sp_terminate(); | 80 | SP_TOKEN_EVAL_WHITELIST); |
| 81 | } | ||
| 82 | if (eval->simulation) { | ||
| 83 | sp_log_msg( | ||
| 84 | "Eval_whitelist", SP_LOG_SIMULATION, | ||
| 85 | "The function '%s' isn't in the eval whitelist, logging its call.", | ||
| 86 | current_function); | ||
| 87 | return; | ||
| 88 | } else { | ||
| 89 | sp_log_msg( | ||
| 90 | "Eval_whitelist", SP_LOG_DROP, | ||
| 91 | "The function '%s' isn't in the eval whitelist, dropping its call.", | ||
| 92 | current_function); | ||
| 93 | sp_terminate(); | ||
| 94 | } | ||
| 79 | } | 95 | } |
| 80 | } | 96 | } |
| 81 | } | 97 | } |
