queue.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * queue.h | ||
| 3 | * | ||
| 4 | * Created on: Sep 3, 2018 | ||
| 5 | * Author: alexey | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef REPLACER_QUEUE_H_ | ||
| 9 | #define REPLACER_QUEUE_H_ | ||
| 10 | |||
| 11 | #include "stringfunc.h" | ||
| 12 | |||
| 13 | #define SET_HYPERSCAN_DBTYPE 1 | ||
| 14 | #define SET_OLD_DBTYPE 0 | ||
| 15 | |||
| 16 | #undef INLINE_STATIC | ||
| 17 | #ifdef QUEUE_NOINLINE | ||
| 18 | #define INLINE_STATIC | ||
| 19 | #else | ||
| 20 | #define INLINE_STATIC inline static | ||
| 21 | #endif | ||
| 22 | |||
| 23 | typedef struct i360_make_global_copy_params { | ||
| 24 | char *rules_file; | ||
| 25 | const char *application_id; | ||
| 26 | } i360_make_global_copy_params; | ||
| 27 | |||
| 28 | void i360_free_queue(); | ||
| 29 | void i360_read_internal_config(char *path_to_config); | ||
| 30 | void i360_free_internal_config(); | ||
| 31 | char *i360_get_config_key(char *key_name); | ||
| 32 | char *i360_getenv(const char *name, const char *default_value); | ||
| 33 | int i360_add_func_param_value(params_list *parms, char *param, char *value, int length); | ||
| 34 | int i360_add_func_param(params_list *parms, char *param, int length); | ||
| 35 | void i360_free_func_params(params_list *parms); | ||
| 36 | char *i360_is_function_hooked(const char *name, char *buffer); | ||
| 37 | int i360_get_params_flags(char *func_info); | ||
| 38 | void i360_param_check(char *func_info, params_list *params, int flags); | ||
| 39 | void i360_free_global_copy(); | ||
| 40 | int i360_make_global_copy(i360_make_global_copy_params *params); | ||
| 41 | void i360_check_chain(params_list *params, chain_result *result, int logger, const char *function_name, | ||
| 42 | const char *queue, size_t queue_len, int level, int enabled_group); | ||
| 43 | int i360_result_action(chain_result *chains, int user_action); | ||
| 44 | #ifndef UNIT_TESTING | ||
| 45 | void i360_print_params(params_list *params, const char *fname, const char *dbgfile_name); | ||
| 46 | void i360_print_func_dict(); | ||
| 47 | void i360_print_groups_dict(); | ||
| 48 | void i360_print_func_dict_letter(); | ||
| 49 | #endif | ||
| 50 | identifier i360_make_anyop_old(uint8_t glb, uint8_t uniq); | ||
| 51 | void i360_set_cur_php_fname(char *fname, map_void_t *whitelist_map, int compile); | ||
| 52 | void i360_free_cur_php_fname(); | ||
| 53 | char *i360_get_cur_php_fname(); | ||
| 54 | void i360_read_whitelist_from_file(map_void_t *map, char *filename); | ||
| 55 | void i360_read_whitelist_from_file2(map_void_t *map, char *filename, int dump_fd); | ||
| 56 | void i360_free_rules_whitelist(map_void_t *map); | ||
| 57 | void i360_free_wl_buffer(); | ||
| 58 | |||
| 59 | params_global_data *i360_get_global_data(); | ||
| 60 | void i360_check_test_enabled(); | ||
| 61 | int i360_is_test_env_enabled(); | ||
| 62 | |||
| 63 | int i360_is_eval_in_func_list(); | ||
| 64 | int i360_check_fp(const char *queue, size_t queue_len, int check_empty); | ||
| 65 | |||
| 66 | int i360_write_debug_log(const char *file_name, int new_line, const char *format, ...); | ||
| 67 | |||
| 68 | void i360_reset_logger_rce(); | ||
| 69 | void i360_set_logger_rce(); | ||
| 70 | int i360_is_rce_logger_log_mode(); | ||
| 71 | |||
| 72 | uint8_t i360_env_gencrc(uint8_t *data); | ||
| 73 | int i360_need_save_env_variable(char *variable_name, int var_len); | ||
| 74 | void i360_init_global_server(); | ||
| 75 | void i360_init_global_server_no_env(); | ||
| 76 | void i360_add_value_to_global_server(char *key, int len); | ||
| 77 | void i360_clean_global_server(); | ||
| 78 | params_list *i360_get_global_server(); | ||
| 79 | void i360_extract_correct_php_script_name(char *cur_php_fname); | ||
| 80 | void i360_set_malware_directory_config(char *path); | ||
| 81 | void i360_load_exclude_list(char *document_root); | ||
| 82 | void i360_free_exclude_list(); | ||
| 83 | void i360_set_exclude_list_opt(int value); | ||
| 84 | int i360_precheck_params_for_inclusion_rinit(char *current_script_name); | ||
| 85 | int i360_is_file_white_listed(int rule_id); | ||
| 86 | char *i360_get_current_db_path(); | ||
| 87 | long i360_get_current_db_sig(); | ||
| 88 | void i360_check_chain_rinit(chain_result *result, int logger, int level, int enabled_group, char *file_name); | ||
| 89 | int i360_check_open_read(const char *fname, char short_name, int recognizer_id, int chain_id); | ||
| 90 | int i360_check_null_file_size(const char *fname); | ||
| 91 | void i360_clear_prepared_buffer(); | ||
| 92 | void i360_fix_prepared_buffer(); | ||
| 93 | int i360_add_prepared_buffer_req_data(char *data); | ||
| 94 | void i360_restore_buffer_for_dynamic(); | ||
| 95 | int i360_add_prepared_buffer_dyn_data(char *data); | ||
| 96 | int i360_is_prepared_buffer_fixed(); | ||
| 97 | char *i360_prepared_buffer_get(int index); | ||
| 98 | int i360_prepared_buffer_length(); | ||
| 99 | |||
| 100 | int i360_add_func_param_value_add_new(const char *param, size_t length); | ||
| 101 | int i360_add_func_param_value_new(const char *param, size_t length); | ||
| 102 | int i360_add_func_param_new(const char *param, size_t length); | ||
| 103 | void i360_free_func_params_new(); | ||
| 104 | void i360_print_params_new(const char *fname, const char *dbgfile_name); | ||
| 105 | char *i360_get_params_new(int *index, int *len); | ||
| 106 | char *i360_get_params_index_new(int *index, int *len); | ||
| 107 | int i360_get_params_new_numb(); | ||
| 108 | char *i360_get_params_new_raw(int index); | ||
| 109 | |||
| 110 | void i360_func_foreach(void (*f)(const char *key, const char *val, int is_danger, int is_openwrite, | ||
| 111 | const void *dbfunc)); | ||
| 112 | |||
| 113 | void i360_pd_set_v2_database_paths(char *global_path, char *agent_path); | ||
| 114 | int i360_pd_database_init(); | ||
| 115 | void i360_pd_database_deinit(); | ||
| 116 | #ifdef UNIT_TESTING | ||
| 117 | int i360_pd_database_is_args_requirde(const void *dbfunc); | ||
| 118 | int i360_pd_database_is_write_log(const void *dbfunc); | ||
| 119 | #endif | ||
| 120 | void i360_pd_database_make_info(const void *dbfunc, char *info); | ||
| 121 | void i360_pd_database_check(chain_result *result, const void *dbfunc, const char *queue, size_t queue_len, int logger, | ||
| 122 | int level, int enabled_group); | ||
| 123 | int i360_pd_database_check_rinit(chain_result *result, int level, int enabled_group, const char *queue, | ||
| 124 | size_t queue_len); | ||
| 125 | int i360_pd_database_func_foreach(void (*f)(const char *key, const char *val, int is_danger, int is_openwrite, | ||
| 126 | const void *dbfunc)); | ||
| 127 | void i360_set_database_version(int db_version); | ||
| 128 | int i360_get_database_version(); | ||
| 129 | |||
| 130 | INLINE_STATIC | ||
| 131 | 2 | char *i360_get_config_key_or_default(char *key_name, char *dfl) { | |
| 132 | 2 | char *tmp_value = i360_get_config_key(key_name); | |
| 133 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 1 time.
|
2 | if (!tmp_value) |
| 134 | 1 | return dfl; | |
| 135 | 1 | return tmp_value; | |
| 136 | } | ||
| 137 | |||
| 138 | INLINE_STATIC | ||
| 139 | 5 | int i360_get_config_bool(char *key_name, int dfl) { | |
| 140 | 5 | char *tmp_value = i360_get_config_key(key_name); | |
| 141 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | if (!tmp_value) |
| 142 | 2 | return dfl; | |
| 143 | 3 | return i360_atobool(tmp_value); | |
| 144 | } | ||
| 145 | |||
| 146 | INLINE_STATIC | ||
| 147 | 3 | int i360_get_config_int(char *key_name, int dfl) { | |
| 148 | 3 | char *tmp_value = i360_get_config_key(key_name); | |
| 149 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
3 | return tmp_value ? atoi(tmp_value) : dfl; |
| 150 | } | ||
| 151 | |||
| 152 | INLINE_STATIC | ||
| 153 | 5 | size_t i360_get_config_size(char *key_name, size_t dfl) { | |
| 154 | 5 | char *tmp_value = i360_get_config_key(key_name); | |
| 155 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | if (!tmp_value) |
| 156 | 2 | return dfl; | |
| 157 | 3 | ssize_t size = i360_atossize(tmp_value); | |
| 158 |
2/2✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
|
3 | if (size < 0) |
| 159 | 1 | return dfl; | |
| 160 | 2 | return size; | |
| 161 | } | ||
| 162 | |||
| 163 | INLINE_STATIC | ||
| 164 | ✗ | double i360_get_config_double(char *key_name, double dfl) { | |
| 165 | ✗ | char *tmp_value = i360_get_config_key(key_name); | |
| 166 | ✗ | return tmp_value ? atof(tmp_value) : dfl; | |
| 167 | } | ||
| 168 | |||
| 169 | #ifndef I360_LIMIT_RANGE | ||
| 170 | # define I360_LIMIT_RANGE(value, min, max, limit_min, limit_max) \ | ||
| 171 | (((value) >= (min) && (value) <= (max)) ? (value) : ((value) < (min) ? (limit_min) : (limit_max))) | ||
| 172 | #endif | ||
| 173 | |||
| 174 | #endif /* REPLACER_QUEUE_H_ */ | ||
| 175 |