Blame apache2/modsecurity.h

Packit Service 384592
/*
Packit Service 384592
* ModSecurity for Apache 2.x, http://www.modsecurity.org/
Packit Service 384592
* Copyright (c) 2004-2013 Trustwave Holdings, Inc. (http://www.trustwave.com/)
Packit Service 384592
*
Packit Service 384592
* You may not use this file except in compliance with
Packit Service 384592
* the License.  You may obtain a copy of the License at
Packit Service 384592
*
Packit Service 384592
*     http://www.apache.org/licenses/LICENSE-2.0
Packit Service 384592
*
Packit Service 384592
* If any of the files related to licensing are missing or if you have any
Packit Service 384592
* other questions related to licensing please contact Trustwave Holdings, Inc.
Packit Service 384592
* directly using the email address security@modsecurity.org.
Packit Service 384592
*/
Packit Service 384592
Packit Service 384592
#ifndef _MODSECURITY_H_
Packit Service 384592
#define _MODSECURITY_H_
Packit Service 384592
Packit Service 384592
#include <stdio.h>
Packit Service 384592
#include <stdlib.h>
Packit Service 384592
Packit Service 384592
#include <limits.h>
Packit Service 384592
#include <libxml/tree.h>
Packit Service 384592
#include <libxml/HTMLparser.h>
Packit Service 384592
Packit Service 384592
typedef struct rule_exception rule_exception;
Packit Service 384592
typedef struct rule_exception hash_method;
Packit Service 384592
typedef struct modsec_rec modsec_rec;
Packit Service 384592
typedef struct directory_config directory_config;
Packit Service 384592
typedef struct error_message_t error_message_t;
Packit Service 384592
typedef struct msc_engine msc_engine;
Packit Service 384592
typedef struct msc_data_chunk msc_data_chunk;
Packit Service 384592
typedef struct msc_arg msc_arg;
Packit Service 384592
typedef struct msc_string msc_string;
Packit Service 384592
typedef struct msc_parm msc_parm;
Packit Service 384592
Packit Service 384592
#include "msc_release.h"
Packit Service 384592
#include "msc_logging.h"
Packit Service 384592
#include "msc_multipart.h"
Packit Service 384592
#include "msc_pcre.h"
Packit Service 384592
#include "msc_util.h"
Packit Service 384592
#include "msc_json.h"
Packit Service 384592
#include "msc_xml.h"
Packit Service 384592
#include "msc_tree.h"
Packit Service 384592
#include "msc_geo.h"
Packit Service 384592
#include "msc_gsb.h"
Packit Service 384592
#include "msc_unicode.h"
Packit Service 384592
#include "re.h"
Packit Service 384592
#include "msc_crypt.h"
Packit Service 384592
#include "msc_remote_rules.h"
Packit Service 384592
Packit Service 384592
#include "ap_config.h"
Packit Service 384592
#include "apr_md5.h"
Packit Service 384592
#include "apr_strings.h"
Packit Service 384592
#include "apr_hash.h"
Packit Service 384592
#include "httpd.h"
Packit Service 384592
#include "http_config.h"
Packit Service 384592
#include "http_log.h"
Packit Service 384592
#include "http_protocol.h"
Packit Service 384592
Packit Service 384592
#if defined(WITH_LUA)
Packit Service 384592
#include "msc_lua.h"
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#define PHASE_REQUEST_HEADERS       1
Packit Service 384592
#define PHASE_REQUEST_BODY          2
Packit Service 384592
#define PHASE_RESPONSE_HEADERS      3
Packit Service 384592
#define PHASE_RESPONSE_BODY         4
Packit Service 384592
#define PHASE_LOGGING               5
Packit Service 384592
#define PHASE_FIRST                 PHASE_REQUEST_HEADERS
Packit Service 384592
#define PHASE_LAST                  PHASE_LOGGING
Packit Service 384592
Packit Service 384592
#define NOT_SET                    -1l
Packit Service 384592
#define NOT_SET_P         ((void *)-1l)
Packit Service 384592
Packit Service 384592
#define CREATEMODE ( APR_UREAD | APR_UWRITE | APR_GREAD )
Packit Service 384592
#define CREATEMODE_DIR ( APR_UREAD | APR_UWRITE | APR_UEXECUTE | APR_GREAD | APR_GEXECUTE )
Packit Service 384592
Packit Service 384592
#if defined(NETWARE)
Packit Service 384592
#define CREATEMODE_UNISTD ( S_IREAD | S_IWRITE )
Packit Service 384592
#elif defined(WIN32)
Packit Service 384592
#define CREATEMODE_UNISTD ( _S_IREAD | _S_IWRITE )
Packit Service 384592
#else
Packit Service 384592
#define CREATEMODE_UNISTD ( S_IRUSR | S_IWUSR | S_IRGRP )
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#if !defined(O_BINARY)
Packit Service 384592
#define O_BINARY (0)
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#ifndef PIPE_BUF
Packit Service 384592
#define PIPE_BUF (512)
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#define REQUEST_BODY_HARD_LIMIT                 1073741824L
Packit Service 384592
#define REQUEST_BODY_DEFAULT_INMEMORY_LIMIT     131072
Packit Service 384592
#define REQUEST_BODY_DEFAULT_LIMIT              134217728
Packit Service 384592
#define REQUEST_BODY_NO_FILES_DEFAULT_LIMIT     1048576
Packit Service 384592
#define RESPONSE_BODY_DEFAULT_LIMIT             524288
Packit Service 384592
#define RESPONSE_BODY_HARD_LIMIT                1073741824L
Packit Service 384592
Packit Service 384592
#define RESPONSE_BODY_LIMIT_ACTION_REJECT       0
Packit Service 384592
#define RESPONSE_BODY_LIMIT_ACTION_PARTIAL      1
Packit Service 384592
Packit Service 384592
#define REQUEST_BODY_FORCEBUF_OFF               0
Packit Service 384592
#define REQUEST_BODY_FORCEBUF_ON                1
Packit Service 384592
Packit Service 384592
#define REQUEST_BODY_LIMIT_ACTION_REJECT       0
Packit Service 384592
#define REQUEST_BODY_LIMIT_ACTION_PARTIAL      1
Packit Service 384592
Packit Service 384592
#define SECACTION_TARGETS                       "REMOTE_ADDR"
Packit Service 384592
#define SECACTION_ARGS                          "@unconditionalMatch"
Packit Service 384592
Packit Service 384592
#define SECMARKER_TARGETS                       "REMOTE_ADDR"
Packit Service 384592
#define SECMARKER_ARGS                          "@noMatch"
Packit Service 384592
#define SECMARKER_BASE_ACTIONS                  "t:none,pass,marker:"
Packit Service 384592
Packit Service 384592
#if !defined(OS2) && !defined(WIN32) && !defined(BEOS) && !defined(NETWARE)
Packit Service 384592
#include "unixd.h"
Packit Service 384592
#define __SET_MUTEX_PERMS
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#define COOKIES_V0                      0
Packit Service 384592
#define COOKIES_V1                      1
Packit Service 384592
Packit Service 384592
#ifdef WIN32
Packit Service 384592
#include <direct.h>
Packit Service 384592
#else
Packit Service 384592
#include <sys/types.h>
Packit Service 384592
#include <unistd.h>
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
#define NOTE_MSR "modsecurity-tx-context"
Packit Service 384592
Packit Service 384592
#define FATAL_ERROR "ModSecurity: Fatal error (memory allocation or unexpected internal error)!"
Packit Service 384592
Packit Service 384592
extern DSOLOCAL char *new_server_signature;
Packit Service 384592
extern DSOLOCAL char *real_server_signature;
Packit Service 384592
extern DSOLOCAL char *chroot_dir;
Packit Service 384592
Packit Service 384592
extern module AP_MODULE_DECLARE_DATA security2_module;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL const command_rec module_directives[];
Packit Service 384592
Packit Service 384592
extern DSOLOCAL unsigned long int msc_pcre_match_limit;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL unsigned long int msc_pcre_match_limit_recursion;
Packit Service 384592
Packit Service 384592
#ifdef WITH_REMOTE_RULES
Packit Service 384592
extern DSOLOCAL msc_remote_rules_server *remote_rules_server;
Packit Service 384592
#endif
Packit Service 384592
extern DSOLOCAL int remote_rules_fail_action;
Packit Service 384592
extern DSOLOCAL char *remote_rules_fail_message;
Packit Service 34f31f
extern DSOLOCAL unsigned long int remote_rules_timeout;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL int status_engine_state;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL int conn_limits_filter_state;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL unsigned long int conn_read_state_limit;
Packit Service 384592
extern DSOLOCAL TreeRoot *conn_read_state_whitelist;
Packit Service 384592
extern DSOLOCAL TreeRoot *conn_read_state_suspicious_list;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL unsigned long int conn_write_state_limit;
Packit Service 384592
extern DSOLOCAL TreeRoot *conn_write_state_whitelist;
Packit Service 384592
extern DSOLOCAL TreeRoot *conn_write_state_suspicious_list;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL unsigned long int unicode_codepage;
Packit Service 384592
Packit Service 384592
extern DSOLOCAL int *unicode_map_table;
Packit Service 384592
Packit Service 384592
#define RESBODY_STATUS_NOT_READ         0   /* we were not configured to read the body */
Packit Service 384592
#define RESBODY_STATUS_ERROR            1   /* error occured while we were reading the body */
Packit Service 384592
#define RESBODY_STATUS_PARTIAL          2   /* partial body content available in the brigade */
Packit Service 384592
#define RESBODY_STATUS_READ_BRIGADE     3   /* body was read but not flattened */
Packit Service 384592
#define RESBODY_STATUS_READ             4   /* body was read and flattened */
Packit Service 384592
Packit Service 384592
#define IF_STATUS_NONE                  0
Packit Service 384592
#define IF_STATUS_WANTS_TO_RUN          1
Packit Service 384592
#define IF_STATUS_COMPLETE              2
Packit Service 384592
Packit Service 384592
#define OF_STATUS_NOT_STARTED           0
Packit Service 384592
#define OF_STATUS_IN_PROGRESS           1
Packit Service 384592
#define OF_STATUS_COMPLETE              2
Packit Service 384592
Packit Service 384592
#define MSC_REQBODY_NONE                0
Packit Service 384592
#define MSC_REQBODY_MEMORY              1
Packit Service 384592
#define MSC_REQBODY_DISK                2
Packit Service 384592
Packit Service 384592
#define ACTION_NONE                     0
Packit Service 384592
#define ACTION_DENY                     1
Packit Service 384592
#define ACTION_REDIRECT                 2
Packit Service 384592
#define ACTION_PROXY                    3
Packit Service 384592
#define ACTION_DROP                     4
Packit Service 384592
#define ACTION_ALLOW                    5
Packit Service 384592
#define ACTION_ALLOW_REQUEST            6
Packit Service 384592
#define ACTION_ALLOW_PHASE              7
Packit Service 384592
#define ACTION_PAUSE                    8
Packit Service 384592
Packit Service 384592
#define MODSEC_DISABLED                 0
Packit Service 384592
#define MODSEC_DETECTION_ONLY           1
Packit Service 384592
#define MODSEC_ENABLED                  2
Packit Service 384592
Packit Service 384592
#define STATUS_ENGINE_ENABLED           1
Packit Service 384592
#define STATUS_ENGINE_DISABLED          0
Packit Service 384592
Packit Service 384592
#define REMOTE_RULES_ABORT_ON_FAIL	0
Packit Service 384592
#define REMOTE_RULES_WARN_ON_FAIL	1
Packit Service 384592
Packit Service 384592
#define HASH_DISABLED             0
Packit Service 384592
#define HASH_ENABLED              1
Packit Service 384592
Packit Service 384592
#define HASH_URL_HREF_HASH_RX     0
Packit Service 384592
#define HASH_URL_HREF_HASH_PM     1
Packit Service 384592
#define HASH_URL_FACTION_HASH_RX  2
Packit Service 384592
#define HASH_URL_FACTION_HASH_PM  3
Packit Service 384592
#define HASH_URL_LOCATION_HASH_RX 4
Packit Service 384592
#define HASH_URL_LOCATION_HASH_PM 5
Packit Service 384592
#define HASH_URL_IFRAMESRC_HASH_RX 6
Packit Service 384592
#define HASH_URL_IFRAMESRC_HASH_PM 7
Packit Service 384592
#define HASH_URL_FRAMESRC_HASH_RX 8
Packit Service 384592
#define HASH_URL_FRAMESRC_HASH_PM 9
Packit Service 384592
Packit Service 384592
#define HASH_KEYONLY              0
Packit Service 384592
#define HASH_SESSIONID            1
Packit Service 384592
#define HASH_REMOTEIP             2
Packit Service 384592
Packit Service 384592
#define MODSEC_CACHE_DISABLED           0
Packit Service 384592
#define MODSEC_CACHE_ENABLED            1
Packit Service 384592
Packit Service 384592
#define MODSEC_OFFLINE                  0
Packit Service 384592
#define MODSEC_ONLINE                   1
Packit Service 384592
Packit Service 384592
#define REGEX_CAPTURE_BUFLEN            1024
Packit Service 384592
Packit Service 384592
#define KEEP_FILES_OFF                  0
Packit Service 384592
#define KEEP_FILES_ON                   1
Packit Service 384592
#define KEEP_FILES_RELEVANT_ONLY        2
Packit Service 384592
Packit Service 384592
#define RULE_EXCEPTION_IMPORT_ID        1
Packit Service 384592
#define RULE_EXCEPTION_IMPORT_MSG       2
Packit Service 384592
#define RULE_EXCEPTION_REMOVE_ID        3
Packit Service 384592
#define RULE_EXCEPTION_REMOVE_MSG       4
Packit Service 384592
#define RULE_EXCEPTION_REMOVE_TAG       5
Packit Service 384592
Packit Service 384592
#define NBSP                            160
Packit Service 384592
Packit Service 384592
struct rule_exception {
Packit Service 384592
    int                  type;
Packit Service 384592
    const char          *param;
Packit Service 384592
    void                *param_data;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct modsec_rec {
Packit Service 384592
    apr_pool_t          *mp;
Packit Service 384592
    msc_engine          *modsecurity;
Packit Service 384592
Packit Service 384592
    request_rec         *r_early;
Packit Service 384592
    request_rec         *r;
Packit Service 384592
    directory_config    *dcfg1;
Packit Service 384592
    directory_config    *dcfg2;
Packit Service 384592
    directory_config    *usercfg;
Packit Service 384592
    directory_config    *txcfg;
Packit Service 384592
Packit Service 384592
    unsigned int         reqbody_should_exist;
Packit Service 384592
    unsigned int         reqbody_chunked;
Packit Service 384592
Packit Service 384592
    unsigned int         phase;
Packit Service 384592
    unsigned int         phase_request_headers_complete;
Packit Service 384592
    unsigned int         phase_request_body_complete;
Packit Service 384592
Packit Service 384592
    apr_bucket_brigade  *if_brigade;
Packit Service 384592
    unsigned int         if_seen_eos;
Packit Service 384592
    unsigned int         if_status;
Packit Service 384592
    unsigned int         if_started_forwarding;
Packit Service 384592
Packit Service 384592
    apr_size_t           reqbody_length;
Packit Service 384592
Packit Service 384592
    apr_bucket_brigade  *of_brigade;
Packit Service 384592
    unsigned int         of_status;
Packit Service 384592
    unsigned int         of_done_reading;
Packit Service 384592
    unsigned int         of_skipping;
Packit Service 384592
    unsigned int         of_partial;
Packit Service 384592
    unsigned int         of_is_error;
Packit Service 384592
Packit Service 384592
    unsigned int         resbody_status;
Packit Service 384592
    apr_size_t           resbody_length;
Packit Service 384592
    char                *resbody_data;
Packit Service 384592
    unsigned int         resbody_contains_html;
Packit Service 384592
Packit Service 384592
    apr_size_t           stream_input_length;
Packit Service 384592
    char                *stream_input_data;
Packit Service 384592
    apr_size_t           stream_output_length;
Packit Service 384592
    char                *stream_output_data;
Packit Service 384592
    unsigned int        of_stream_changed;
Packit Service 384592
    unsigned int        if_stream_changed;
Packit Service 384592
Packit Service 384592
    apr_array_header_t  *error_messages;
Packit Service 384592
    apr_array_header_t  *alerts;
Packit Service 384592
Packit Service 384592
    const char          *txid;
Packit Service 384592
    const char          *sessionid;
Packit Service 384592
    const char          *userid;
Packit Service 384592
Packit Service 384592
    const char          *server_software;
Packit Service 384592
    const char          *local_addr;
Packit Service 384592
    unsigned int         local_port;
Packit Service 384592
    const char          *local_user;
Packit Service 384592
Packit Service 384592
    /* client */
Packit Service 384592
Packit Service 384592
    const char          *remote_addr;
Packit Service 384592
    unsigned int         remote_port;
Packit Service 384592
    const char          *remote_user;
Packit Service 384592
Packit Service 384592
    /* useragent */
Packit Service 384592
    const char          *useragent_ip;
Packit Service 384592
Packit Service 384592
    /* request */
Packit Service 384592
Packit Service 384592
    const char          *request_line;
Packit Service 384592
    const char          *request_method;
Packit Service 384592
    const char          *request_uri;
Packit Service 384592
    const char          *query_string;
Packit Service 384592
    const char          *request_protocol;
Packit Service 384592
Packit Service 384592
    const char          *hostname;
Packit Service 384592
Packit Service 384592
    apr_table_t         *request_headers;
Packit Service 384592
Packit Service 384592
    apr_off_t            request_content_length;
Packit Service 384592
    const char          *request_content_type;
Packit Service 384592
Packit Service 384592
    apr_table_t         *arguments;
Packit Service 384592
    apr_table_t         *arguments_to_sanitize;
Packit Service 384592
    apr_table_t         *request_headers_to_sanitize;
Packit Service 384592
    apr_table_t         *response_headers_to_sanitize;
Packit Service 384592
    apr_table_t         *request_cookies;
Packit Service 384592
    apr_table_t         *pattern_to_sanitize;
Packit Service 384592
Packit Service 384592
    unsigned int        urlencoded_error;
Packit Service 384592
    unsigned int        inbound_error;
Packit Service 384592
    unsigned int        outbound_error;
Packit Service 384592
Packit Service 384592
    unsigned int         is_relevant;
Packit Service 384592
Packit Service 384592
    apr_table_t         *tx_vars;
Packit Service 384592
Packit Service 384592
    /* ENH: refactor to allow arbitrary var tables */
Packit Service 384592
    apr_table_t         *geo_vars;
Packit Service 384592
Packit Service 384592
    /* response */
Packit Service 384592
    unsigned int         response_status;
Packit Service 384592
    const char          *status_line;
Packit Service 384592
    const char          *response_protocol;
Packit Service 384592
    apr_table_t         *response_headers;
Packit Service 384592
    unsigned int         response_headers_sent;
Packit Service 384592
    apr_off_t            bytes_sent;
Packit Service 384592
Packit Service 384592
    /* modsecurity request body processing stuff */
Packit Service 384592
Packit Service 384592
    unsigned int         msc_reqbody_storage;       /* on disk or in memory */
Packit Service 384592
    unsigned int         msc_reqbody_spilltodisk;
Packit Service 384592
    unsigned int         msc_reqbody_read;
Packit Service 384592
Packit Service 384592
    apr_pool_t          *msc_reqbody_mp;             /* this is where chunks are allocated from  */
Packit Service 384592
    apr_array_header_t  *msc_reqbody_chunks;         /* data chunks when stored in memory        */
Packit Service 384592
    unsigned int         msc_reqbody_length;         /* the amount of data received              */
Packit Service 384592
    int                  msc_reqbody_chunk_position; /* used when retrieving the body            */
Packit Service 384592
    unsigned int         msc_reqbody_chunk_offset;   /* offset of the chunk currently in use     */
Packit Service 384592
    msc_data_chunk      *msc_reqbody_chunk_current;  /* current chunk                            */
Packit Service 384592
    char                *msc_reqbody_buffer;
Packit Service 384592
Packit Service 384592
    const char          *msc_reqbody_filename;       /* when stored on disk */
Packit Service 384592
    int                  msc_reqbody_fd;
Packit Service 384592
    msc_data_chunk      *msc_reqbody_disk_chunk;
Packit Service 384592
Packit Service 384592
    const char          *msc_reqbody_processor;
Packit Service 384592
    int                  msc_reqbody_error;
Packit Service 384592
    const char          *msc_reqbody_error_msg;
Packit Service 384592
Packit Service 384592
    apr_size_t           msc_reqbody_no_files_length;
Packit Service 384592
Packit Service 384592
    char		*msc_full_request_buffer;
Packit Service 384592
    int			msc_full_request_length;
Packit Service 384592
Packit Service 384592
    char                *multipart_filename;
Packit Service 384592
    char                *multipart_name;
Packit Service 384592
    multipart_data      *mpd;                        /* MULTIPART processor data structure */
Packit Service 384592
Packit Service 384592
    xml_data            *xml;                        /* XML processor data structure       */
Packit Service 384592
#ifdef WITH_YAJL
Packit Service 384592
    json_data           *json;                       /* JSON processor data structure      */
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
    /* audit logging */
Packit Service 384592
    char                *new_auditlog_boundary;
Packit Service 384592
    char                *new_auditlog_filename;
Packit Service 384592
    apr_file_t          *new_auditlog_fd;
Packit Service 384592
    unsigned int         new_auditlog_size;
Packit Service 384592
    apr_md5_ctx_t        new_auditlog_md5ctx;
Packit Service 384592
Packit Service 384592
    unsigned int         was_intercepted;
Packit Service 384592
    unsigned int         rule_was_intercepted;
Packit Service 384592
    unsigned int         intercept_phase;
Packit Service 384592
    msre_actionset      *intercept_actionset;
Packit Service 384592
    const char          *intercept_message;
Packit Service 384592
Packit Service 384592
    /* performance measurement */
Packit Service 384592
    apr_time_t       request_time;
Packit Service 384592
    apr_time_t		 time_phase1;
Packit Service 384592
    apr_time_t		 time_phase2;
Packit Service 384592
    apr_time_t		 time_phase3;
Packit Service 384592
    apr_time_t		 time_phase4;
Packit Service 384592
    apr_time_t		 time_phase5;
Packit Service 384592
    apr_time_t		 time_storage_read;
Packit Service 384592
    apr_time_t		 time_storage_write;
Packit Service 384592
    apr_time_t		 time_logging;
Packit Service 384592
    apr_time_t		 time_gc;
Packit Service 384592
    apr_table_t      *perf_rules;
Packit Service 384592
Packit Service 384592
    apr_array_header_t  *matched_rules;
Packit Service 384592
    msc_string          *matched_var;
Packit Service 384592
    int                  highest_severity;
Packit Service 384592
Packit Service 384592
    /* upload */
Packit Service 384592
    int                  upload_extract_files;
Packit Service 384592
    int                  upload_remove_files;
Packit Service 384592
    int                  upload_files_count;
Packit Service 384592
Packit Service 384592
    /* other */
Packit Service 384592
    apr_table_t         *collections_original;
Packit Service 384592
    apr_table_t         *collections;
Packit Service 384592
    apr_table_t         *collections_dirty;
Packit Service 384592
Packit Service 384592
    /* rule processing temp pool */
Packit Service 384592
    apr_pool_t          *msc_rule_mptmp;
Packit Service 384592
Packit Service 384592
    /* content injection */
Packit Service 384592
    const char          *content_prepend;
Packit Service 384592
    apr_off_t            content_prepend_len;
Packit Service 384592
    const char          *content_append;
Packit Service 384592
    apr_off_t            content_append_len;
Packit Service 384592
Packit Service 384592
    /* data cache */
Packit Service 384592
    apr_hash_t          *tcache;
Packit Service 384592
    apr_size_t           tcache_items;
Packit Service 384592
Packit Service 384592
    /* removed rules */
Packit Service 384592
    apr_array_header_t  *removed_rules;
Packit Service 384592
    apr_array_header_t  *removed_rules_tag;
Packit Service 384592
    apr_array_header_t  *removed_rules_msg;
Packit Service 384592
Packit Service 384592
    /* removed targets */
Packit Service 384592
    apr_table_t         *removed_targets;
Packit Service 384592
Packit Service 384592
    /* When "allow" is executed the variable below is
Packit Service 384592
     * updated to contain the scope of the allow action. Set
Packit Service 384592
     * at 0 by default, it will have ACTION_ALLOW if we are
Packit Service 384592
     * to allow phases 1-4 and ACTION_ALLOW_REQUEST if we
Packit Service 384592
     * are to allow phases 1-2 only.
Packit Service 384592
     */
Packit Service 384592
    unsigned int         allow_scope;
Packit Service 384592
Packit Service 384592
    /* matched vars */
Packit Service 384592
    apr_table_t         *matched_vars;
Packit Service 384592
Packit Service 384592
    /* Generic request body processor context to be used by custom parsers. */
Packit Service 384592
    void                *reqbody_processor_ctx;
Packit Service 384592
Packit Service 384592
    htmlDocPtr          crypto_html_tree;
Packit Service 384592
#if defined(WITH_LUA)
Packit Service 384592
    #ifdef CACHE_LUA
Packit Service 384592
    lua_State           *L;
Packit Service 384592
    #endif
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
    int                 msc_sdbm_delete_error;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct directory_config {
Packit Service 384592
    apr_pool_t          *mp;
Packit Service 384592
Packit Service 384592
    msre_ruleset        *ruleset;
Packit Service 384592
Packit Service 384592
    int                  is_enabled;
Packit Service 384592
    int                  reqbody_access;
Packit Service 384592
    int                  reqintercept_oe;
Packit Service 384592
    int                  reqbody_buffering;
Packit Service 384592
    long int             reqbody_inmemory_limit;
Packit Service 384592
    long int             reqbody_limit;
Packit Service 384592
    long int             reqbody_no_files_limit;
Packit Service 384592
    int                  resbody_access;
Packit Service 384592
Packit Service 384592
    long int             of_limit;
Packit Service 384592
    apr_table_t         *of_mime_types;
Packit Service 384592
    int                  of_mime_types_cleared;
Packit Service 384592
    int                  of_limit_action;
Packit Service 384592
    int                  if_limit_action;
Packit Service 384592
Packit Service 384592
    const char          *debuglog_name;
Packit Service 384592
    int                  debuglog_level;
Packit Service 384592
    apr_file_t          *debuglog_fd;
Packit Service 384592
Packit Service 384592
    int                  cookie_format;
Packit Service 384592
    int                  argument_separator;
Packit Service 384592
    const char           *cookiev0_separator;
Packit Service 384592
Packit Service 384592
    int                  rule_inheritance;
Packit Service 384592
    apr_array_header_t  *rule_exceptions;
Packit Service 384592
Packit Service 384592
Packit Service 384592
    /* -- Audit log -- */
Packit Service 384592
Packit Service 384592
    /* Max rule time */
Packit Service 384592
    int                  max_rule_time;
Packit Service 384592
Packit Service 384592
    /* Whether audit log should be enabled in the context or not */
Packit Service 384592
    int                  auditlog_flag;
Packit Service 384592
Packit Service 384592
    /* AUDITLOG_SERIAL (single file) or AUDITLOG_CONCURRENT (multiple files) */
Packit Service 384592
    int                  auditlog_type;
Packit Service 384592
Packit Service 384592
#ifdef WITH_YAJL
Packit Service 384592
    /* AUDITLOGFORMAT_NATIVE or AUDITLOGFORMAT_JSON */
Packit Service 384592
    int                  auditlog_format;
Packit Service 384592
#endif
Packit Service 384592
Packit Service 384592
    /* Mode for audit log directories and files */
Packit Service 384592
    apr_fileperms_t      auditlog_dirperms;
Packit Service 384592
    apr_fileperms_t      auditlog_fileperms;
Packit Service 384592
Packit Service 384592
    /* The name of the audit log file (for the old type), or the
Packit Service 384592
     * name of the index file (for the new audit log type)
Packit Service 384592
     */
Packit Service 384592
    char                *auditlog_name;
Packit Service 384592
    /* The name of the secondary index file */
Packit Service 384592
    char                *auditlog2_name;
Packit Service 384592
Packit Service 384592
    /* The file descriptors for the files above */
Packit Service 384592
    apr_file_t          *auditlog_fd;
Packit Service 384592
    apr_file_t          *auditlog2_fd;
Packit Service 384592
Packit Service 384592
    /* For the new-style audit log only, the path where
Packit Service 384592
     * audit log entries will be stored
Packit Service 384592
     */
Packit Service 384592
    char                *auditlog_storage_dir;
Packit Service 384592
Packit Service 384592
    /* A list of parts to include in the new-style audit log
Packit Service 384592
     * entry. By default, it contains 'ABCFHZ'. Have a look at
Packit Service 384592
     * the AUDITLOG_PART_* constants above to decipher the
Packit Service 384592
     * meaning.
Packit Service 384592
     */
Packit Service 384592
    char                *auditlog_parts;
Packit Service 384592
Packit Service 384592
    /* A regular expression that determines if a response
Packit Service 384592
     * status is treated as relevant.
Packit Service 384592
     */
Packit Service 384592
    msc_regex_t         *auditlog_relevant_regex;
Packit Service 384592
Packit Service 384592
    /* Upload */
Packit Service 384592
    const char          *tmp_dir;
Packit Service 384592
    const char          *upload_dir;
Packit Service 384592
    int                  upload_keep_files;
Packit Service 384592
    int                  upload_validates_files;
Packit Service 384592
    int                  upload_filemode; /* int only so NOT_SET works */
Packit Service 384592
    int                  upload_file_limit;
Packit Service 384592
Packit Service 384592
    /* Used only in the configuration phase. */
Packit Service 384592
    msre_rule           *tmp_chain_starter;
Packit Service 384592
    msre_actionset      *tmp_default_actionset;
Packit Service 384592
    apr_table_t         *tmp_rule_placeholders;
Packit Service 384592
Packit Service 384592
    /* Misc */
Packit Service 384592
    const char          *data_dir;
Packit Service 384592
    const char          *webappid;
Packit Service 384592
    const char          *sensor_id;
Packit Service 384592
    const char          *httpBlkey;
Packit Service 384592
Packit Service 384592
    /* Content injection. */
Packit Service 384592
    int                  content_injection_enabled;
Packit Service 384592
Packit Service 384592
    /* Stream Inspection */
Packit Service 384592
    int                 stream_inbody_inspection;
Packit Service 384592
    int                 stream_outbody_inspection;
Packit Service 384592
Packit Service 384592
    /* Geo Lookup */
Packit Service 384592
    geo_db              *geo;
Packit Service 384592
Packit Service 384592
    /* Gsb Lookup */
Packit Service 384592
    gsb_db              *gsb;
Packit Service 384592
Packit Service 384592
    /* Unicode map */
Packit Service 384592
    unicode_map         *u_map;
Packit Service 384592
Packit Service 384592
    /* Cache */
Packit Service 384592
    int                  cache_trans;
Packit Service 384592
    int                  cache_trans_incremental;
Packit Service 384592
    apr_size_t           cache_trans_min;
Packit Service 384592
    apr_size_t           cache_trans_max;
Packit Service 384592
    apr_size_t           cache_trans_maxitems;
Packit Service 384592
Packit Service 384592
    /* Array to hold signatures of components, which will
Packit Service 384592
     * appear in the ModSecurity signature in the audit log.
Packit Service 384592
     */
Packit Service 384592
    apr_array_header_t  *component_signatures;
Packit Service 384592
Packit Service 384592
    /* Request character encoding. */
Packit Service 384592
    const char          *request_encoding;
Packit Service 384592
Packit Service 384592
    int disable_backend_compression;
Packit Service 384592
Packit Service 384592
    /* Collection timeout */
Packit Service 384592
    int col_timeout;
Packit Service 384592
Packit Service 384592
    /* hash of ids */
Packit Service 384592
    apr_hash_t          *rule_id_htab;
Packit Service 384592
Packit Service 384592
    /* Hash */
Packit Service 384592
    apr_array_header_t  *hash_method;
Packit Service 384592
    const char          *crypto_key;
Packit Service 384592
    int                 crypto_key_len;
Packit Service 384592
    const char          *crypto_param_name;
Packit Service 384592
    int                 hash_is_enabled;
Packit Service 384592
    int                 hash_enforcement;
Packit Service 384592
    int                 crypto_key_add;
Packit Service 384592
    int                 crypto_hash_href_rx;
Packit Service 384592
    int                 crypto_hash_faction_rx;
Packit Service 384592
    int                 crypto_hash_location_rx;
Packit Service 384592
    int                 crypto_hash_iframesrc_rx;
Packit Service 384592
    int                 crypto_hash_framesrc_rx;
Packit Service 384592
    int                 crypto_hash_href_pm;
Packit Service 384592
    int                 crypto_hash_faction_pm;
Packit Service 384592
    int                 crypto_hash_location_pm;
Packit Service 384592
    int                 crypto_hash_iframesrc_pm;
Packit Service 384592
    int                 crypto_hash_framesrc_pm;
Packit Service 384592
Packit Service 384592
    /* xml */
Packit Service 384592
    int                 xml_external_entity;
Packit Service 384592
Packit Service 384592
    /* This will be used whenever ModSecurity will be ready
Packit Service 384592
     * to ask the server for newer rules.
Packit Service 384592
     */
Packit Service 384592
#if 0
Packit Service 384592
    msc_remote_rules_server *remote_rules;
Packit Service 384592
    int remote_timeout;
Packit Service 384592
#endif
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct error_message_t {
Packit Service 384592
    const char          *file;
Packit Service 384592
    int                  line;
Packit Service 384592
    int                  level;
Packit Service 384592
    apr_status_t         status;
Packit Service 384592
    const char          *message;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct msc_engine {
Packit Service 384592
    apr_pool_t              *mp;
Packit Service 384592
    apr_global_mutex_t      *auditlog_lock;
Packit Service 384592
    apr_global_mutex_t      *geo_lock;
Packit Service 384592
#ifdef GLOBAL_COLLECTION_LOCK
Packit Service 384592
    apr_global_mutex_t      *dbm_lock;
Packit Service 384592
#endif
Packit Service 384592
    msre_engine             *msre;
Packit Service 384592
    unsigned int             processing_mode;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct msc_data_chunk {
Packit Service 384592
    char                    *data;
Packit Service 384592
    apr_size_t               length;
Packit Service 384592
    unsigned int             is_permanent;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct msc_arg {
Packit Service 384592
    const char              *name;
Packit Service 384592
    unsigned int             name_len;
Packit Service 384592
    unsigned int             name_origin_offset;
Packit Service 384592
    unsigned int             name_origin_len;
Packit Service 384592
    const char              *value;
Packit Service 384592
    unsigned int             value_len;
Packit Service 384592
    unsigned int             value_origin_offset;
Packit Service 384592
    unsigned int             value_origin_len;
Packit Service 384592
    const char              *origin;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct msc_string {
Packit Service 384592
    char                    *name;
Packit Service 384592
    unsigned int             name_len;
Packit Service 384592
    char                    *value;
Packit Service 384592
    unsigned int             value_len;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
struct msc_parm {
Packit Service 384592
    char                    *value;
Packit Service 384592
    int                     pad_1;
Packit Service 384592
    int                     pad_2;
Packit Service 384592
};
Packit Service 384592
Packit Service 384592
/* Engine functions */
Packit Service 384592
Packit Service 384592
msc_engine DSOLOCAL *modsecurity_create(apr_pool_t *mp, int processing_mode);
Packit Service 384592
Packit Service 384592
int DSOLOCAL modsecurity_init(msc_engine *msce, apr_pool_t *mp);
Packit Service 384592
Packit Service 384592
void DSOLOCAL modsecurity_child_init(msc_engine *msce);
Packit Service 384592
Packit Service 384592
void DSOLOCAL modsecurity_shutdown(msc_engine *msce);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_tx_init(modsec_rec *msr);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_process_phase(modsec_rec *msr, unsigned int phase);
Packit Service 384592
Packit Service 384592
Packit Service 384592
/* Request body functions */
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_start(modsec_rec *msr, char **error_msg);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_store(modsec_rec *msr,
Packit Service 384592
    const char *data, apr_size_t length, char **error_msg);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_end(modsec_rec *msr, char **error_msg);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_to_stream(modsec_rec *msr, const char *buffer, int buflen, char **error_msg);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_retrieve_start(modsec_rec *msr, char **error_msg);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_retrieve_end(modsec_rec *msr);
Packit Service 384592
Packit Service 384592
/* Retrieves up to nbytes bytes of the request body. Returns 1 on
Packit Service 384592
 * success, 0 when there is no more data, or -1 on error. On return
Packit Service 384592
 * nbytes will contain the number of bytes stored in the buffer.
Packit Service 384592
 */
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_retrieve(modsec_rec *msr, msc_data_chunk **chunk,
Packit Service 384592
    long int nbytes, char **error_msg);
Packit Service 384592
Packit Service 384592
void DSOLOCAL msc_add(modsec_rec *msr, int level, msre_actionset *actionset,
Packit Service 384592
    const char *action_message, const char *rule_message);
Packit Service 384592
Packit Service 384592
const char DSOLOCAL *msc_alert_message(modsec_rec *msr, msre_actionset *actionset, const char *action_message,
Packit Service 384592
    const char *rule_message);
Packit Service 384592
Packit Service 384592
void DSOLOCAL msc_alert(modsec_rec *msr, int level, msre_actionset *actionset, const char *action_message,
Packit Service 384592
    const char *rule_message);
Packit Service 384592
Packit Service 384592
apr_status_t DSOLOCAL modsecurity_request_body_clear(modsec_rec *msr, char **error_msg);
Packit Service 384592
Packit Service 384592
#endif