Beispiel #1
0
char *test_read_input()
{
        FILE *f;

        /* open, read and parse some invalid xml */
        f = fopen("test.invalid.xml", "r");
        mu_assert("read invalid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("parse invalid xml", xml_parse(buf) == XML_STATUS_INVALID);

        /* open, read and parse some valid xml */
        f = fopen("test.xml", "r");
        mu_assert("read valid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("buffer contains request", strncmp(buf,"<request>", 9) == 0);
        mu_assert("parse some valid xml", xml_parse(buf) == XML_STATUS_OK);

        /* fetch value of an element */
        char *value = xml_element("//username");
        mu_assert("perform xpath search for element", value != NULL);
        mu_assert("get value of xml element", strcmp(value, "iamauser") == 0);
        xml_free(value);

        xml_cleanup();

        return 0;
}
Beispiel #2
0
static apr_status_t modsecurity_tx_cleanup(void *data) {
    modsec_rec *msr = (modsec_rec *)data;
    char *my_error_msg = NULL;
    
    if (msr == NULL) return APR_SUCCESS;    

    /* Multipart processor cleanup. */
    if (msr->mpd != NULL) multipart_cleanup(msr);

    /* XML processor cleanup. */
    if (msr->xml != NULL) xml_cleanup(msr);

    // TODO: Why do we ignore return code here?
    modsecurity_request_body_clear(msr, &my_error_msg);
    if (my_error_msg != NULL) {
        msr_log(msr, 1, "%s", my_error_msg);
    }

#if defined(WITH_LUA)
    #ifdef CACHE_LUA
    if(msr->L != NULL)  lua_close(msr->L);
    #endif
#endif

    return APR_SUCCESS;
}
Beispiel #3
0
int clean_psia_request(request *req, node_t *root)
{
  /* cleanup the request */
  delete_tree(root);
  xml_cleanup(req);
  xadd_cleanup(req);
  iface_cleanup(req);

  return 0;
}
Beispiel #4
0
static apr_status_t modsecurity_tx_cleanup(void *data) 
{
    modsec_rec *msr = (modsec_rec *)data;
    char *my_error_msg = NULL;
    
    if (msr == NULL) {
        return APR_SUCCESS;    
    }

    /* Multipart processor cleanup. */
    if (msr->mpd != NULL) {
        multipart_cleanup(msr);
    }

    /* XML processor cleanup. */
    if (msr->xml != NULL) {
        xml_cleanup(msr);
    }

    // TODO: Why do we ignore return code here?
    modsecurity_request_body_clear(msr, &my_error_msg);
    if (my_error_msg != NULL) {
        msr_log(msr, 1, "%s", my_error_msg);
    }
    
    if (msr->stream_input_data) {
        free(msr->stream_input_data);
        msr->stream_input_data = NULL;
    }
    
    if (msr->stream_output_data) {
        free(msr->stream_output_data);
        msr->stream_output_data = NULL;
    }

    if (msr->msc_reqbody_chunk_current && msr->msc_reqbody_chunk_current->data) {
        free(msr->msc_reqbody_chunk_current->data);
        msr->msc_reqbody_chunk_current->data = NULL;
    }

    return APR_SUCCESS;
}