2006-09-12 19:38:39 +00:00
|
|
|
/*
|
|
|
|
* Match a string against a list of patterns/regexes.
|
|
|
|
*
|
2025-02-14 10:24:30 -05:00
|
|
|
* Copyright (C) 2013-2025 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
2019-01-25 10:15:50 -05:00
|
|
|
* Copyright (C) 2007-2013 Sourcefire, Inc.
|
2008-04-02 15:24:51 +00:00
|
|
|
*
|
|
|
|
* Authors: Török Edvin
|
2006-09-12 19:38:39 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2008-04-02 15:24:51 +00:00
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
2007-06-30 11:50:56 +00:00
|
|
|
* published by the Free Software Foundation.
|
2006-09-12 19:38:39 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
* MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _REGEX_LIST_H
|
|
|
|
#define _REGEX_LIST_H
|
|
|
|
|
2007-09-27 21:27:37 +00:00
|
|
|
#include "phishcheck.h"
|
2008-05-18 21:32:27 +00:00
|
|
|
#include "readdb.h"
|
|
|
|
#include "matcher.h"
|
2010-02-09 12:01:31 +02:00
|
|
|
#include "filtering.h"
|
2010-06-29 13:51:59 +02:00
|
|
|
#include "hashtab.h"
|
2007-12-18 19:23:56 +00:00
|
|
|
#include <zlib.h> /* for gzFile */
|
2008-07-23 13:51:57 +00:00
|
|
|
|
2008-10-18 00:16:23 +00:00
|
|
|
#include "mpool.h"
|
|
|
|
|
2008-07-29 15:37:23 +00:00
|
|
|
struct regex_list_ht {
|
2018-12-03 12:40:13 -05:00
|
|
|
struct regex_list* head;
|
|
|
|
struct regex_list* tail;
|
2008-07-29 15:37:23 +00:00
|
|
|
};
|
|
|
|
|
2006-09-12 19:38:39 +00:00
|
|
|
struct regex_matcher {
|
2018-12-03 12:40:13 -05:00
|
|
|
struct cli_hashtable suffix_hash;
|
|
|
|
size_t suffix_cnt;
|
|
|
|
struct regex_list_ht* suffix_regexes;
|
|
|
|
size_t root_regex_idx;
|
|
|
|
size_t regex_cnt;
|
|
|
|
regex_t** all_pregs;
|
|
|
|
struct cli_matcher suffixes;
|
2025-06-03 19:03:20 -04:00
|
|
|
struct cli_matcher sha2_256_hashes;
|
|
|
|
struct cli_hashset sha2_256_pfx_set;
|
2018-12-03 12:40:13 -05:00
|
|
|
struct cli_matcher hostkey_prefix;
|
|
|
|
struct filter filter;
|
2008-10-18 00:16:23 +00:00
|
|
|
#ifdef USE_MPOOL
|
2018-12-03 12:40:13 -05:00
|
|
|
mpool_t* mempool;
|
2008-10-18 00:16:23 +00:00
|
|
|
#endif
|
2018-12-03 12:40:13 -05:00
|
|
|
int list_inited : 2;
|
|
|
|
int list_loaded : 2;
|
|
|
|
int list_built : 2;
|
2006-09-12 19:38:39 +00:00
|
|
|
};
|
|
|
|
|
2019-02-27 00:47:38 -05:00
|
|
|
cl_error_t cli_build_regex_list(struct regex_matcher* matcher);
|
|
|
|
cl_error_t regex_list_add_pattern(struct regex_matcher* matcher, char* pattern);
|
2021-05-27 13:15:52 -07:00
|
|
|
cl_error_t regex_list_match(struct regex_matcher* matcher, char* real_url, const char* display_url, const struct pre_fixup_info* pre_fixup, int hostOnly, const char** info, int is_allow_list_lookup);
|
2019-02-27 00:47:38 -05:00
|
|
|
cl_error_t init_regex_list(struct regex_matcher* matcher, uint8_t dconf_prefiltering);
|
2021-05-27 13:15:52 -07:00
|
|
|
cl_error_t load_regex_matcher(struct cl_engine* engine, struct regex_matcher* matcher, FILE* fd, unsigned int* signo, unsigned int options, int is_allow_list_lookup, struct cli_dbio* dbio, uint8_t dconf_prefiltering);
|
2006-09-12 19:38:39 +00:00
|
|
|
void regex_list_cleanup(struct regex_matcher* matcher);
|
|
|
|
void regex_list_done(struct regex_matcher* matcher);
|
|
|
|
int is_regex_ok(struct regex_matcher* matcher);
|
2006-10-07 11:00:46 +00:00
|
|
|
|
2006-09-12 19:38:39 +00:00
|
|
|
#endif
|