BeanShell support

This commit is contained in:
Mihai Pitu
2013-09-18 17:41:18 +01:00
committed by Felipe Zimmerle
parent 29f4bd15ea
commit 90856f42b6

View File

@@ -1,4 +1,4 @@
/*
/*
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
@@ -2198,19 +2198,23 @@ static apr_status_t msre_action_exec_execute(modsec_rec *msr, apr_pool_t *mptmp,
msre_rule *rule, msre_action *action)
{
//#ifdef WITH_BEANSHELL
if (action->param != NULL) {
int lenparam = strlen(action->param);
int bsh = 0;
int lenparam = action->param != NULL ? strlen(action->param) : -1;
if (lenparam > 0)
if ((action->param[lenparam - 4] == '.' &&
action->param[lenparam - 3] == 'b' &&
action->param[lenparam - 2] == 's' &&
action->param[lenparam - 1] == 'h')) {
action->param[lenparam - 1] == 'h'))
bsh = 1;
if (bsh) {
//beanshell_execute(action->param, msr, mptmp, rule);
char *script_output = NULL;
int rc;
const char *start = "java -classpath bsh*.jar bsh.Interpreter ";
char *command = (char*) apr_palloc(mptmp, strlen(start) + lenparam + 1);
msr_log(msr, 1, "Executing: %s", action->param);
msr_log(msr, 1, "beanshell ftw");
strcpy(command, start);
strcat(command, action->param);
command[strlen(start) + lenparam] = '\0';
@@ -2219,8 +2223,7 @@ static apr_status_t msre_action_exec_execute(modsec_rec *msr, apr_pool_t *mptmp,
msr_log(msr, 1, "Failed to execute: %s", action->param);
return 0;
}
}
}
} else
//#endif
#if defined(WITH_LUA)
if (action->param_data != NULL) { /* Lua */