From 17a09fafa2b569f0ce548220fd099cdf88e3a71e Mon Sep 17 00:00:00 2001 From: kkadosh Date: Fri, 2 Mar 2018 13:31:56 +0000 Subject: Add .dump() for eval whitelist/blacklist + simulation mode for whitelist --- src/sp_execute.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/sp_execute.c') 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, static void ZEND_HOT is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { + sp_config_eval *eval = SNUFFLEUPAGUS_G(config).config_eval; + if (EXPECTED(0 == SNUFFLEUPAGUS_G(in_eval))) { return; } @@ -71,11 +73,25 @@ is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { if (EXPECTED(NULL != current_function)) { if (UNEXPECTED(false == check_is_in_eval_whitelist(current_function))) { - sp_log_msg( - "Eval_whitelist", SP_LOG_DROP, - "The function '%s' isn't in the eval whitelist, dropping its call.", - current_function); - sp_terminate(); + if (eval->dump) { + sp_log_request( + SNUFFLEUPAGUS_G(config).config_eval->dump, + SNUFFLEUPAGUS_G(config).config_eval->textual_representation, + SP_TOKEN_EVAL_WHITELIST); + } + if (eval->simulation) { + sp_log_msg( + "Eval_whitelist", SP_LOG_SIMULATION, + "The function '%s' isn't in the eval whitelist, logging its call.", + current_function); + return; + } else { + sp_log_msg( + "Eval_whitelist", SP_LOG_DROP, + "The function '%s' isn't in the eval whitelist, dropping its call.", + current_function); + sp_terminate(); + } } } } -- cgit v1.3