2006-09-12 19:38:39 +00:00
|
|
|
/*
|
|
|
|
* Match a string against a list of patterns/regexes.
|
|
|
|
*
|
2015-09-17 13:41:26 -04:00
|
|
|
* Copyright (C) 2015 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
|
2008-04-02 15:24:51 +00:00
|
|
|
* Copyright (C) 2007-2008 Sourcefire, Inc.
|
|
|
|
*
|
|
|
|
* 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 {
|
|
|
|
struct regex_list *head;
|
|
|
|
struct regex_list *tail;
|
|
|
|
};
|
|
|
|
|
2006-09-12 19:38:39 +00:00
|
|
|
struct regex_matcher {
|
2009-08-04 23:17:28 +02:00
|
|
|
struct cli_hashtable suffix_hash;
|
2008-07-23 13:51:57 +00:00
|
|
|
size_t suffix_cnt;
|
2008-07-29 15:37:23 +00:00
|
|
|
struct regex_list_ht *suffix_regexes;
|
2009-02-23 12:35:45 +00:00
|
|
|
size_t root_regex_idx;
|
2008-07-25 20:01:40 +00:00
|
|
|
size_t regex_cnt;
|
2008-07-29 10:36:26 +00:00
|
|
|
regex_t **all_pregs;
|
2008-07-23 13:51:57 +00:00
|
|
|
struct cli_matcher suffixes;
|
2009-02-18 14:54:16 +00:00
|
|
|
struct cli_matcher sha256_hashes;
|
2009-08-04 23:17:28 +02:00
|
|
|
struct cli_hashset sha256_pfx_set;
|
2009-03-11 20:06:35 +00:00
|
|
|
struct cli_matcher hostkey_prefix;
|
2008-07-23 13:51:57 +00:00
|
|
|
struct filter filter;
|
2008-10-18 00:16:23 +00:00
|
|
|
#ifdef USE_MPOOL
|
2009-01-26 19:47:02 +00:00
|
|
|
mpool_t *mempool;
|
2008-10-18 00:16:23 +00:00
|
|
|
#endif
|
2008-07-23 13:51:57 +00:00
|
|
|
int list_inited:2;
|
|
|
|
int list_loaded:2;
|
|
|
|
int list_built:2;
|
2006-09-12 19:38:39 +00:00
|
|
|
};
|
|
|
|
|
2008-07-23 13:51:57 +00:00
|
|
|
int cli_build_regex_list(struct regex_matcher* matcher);
|
2008-07-25 16:03:04 +00:00
|
|
|
int regex_list_add_pattern(struct regex_matcher *matcher, char *pattern);
|
2008-07-23 13:51:57 +00:00
|
|
|
int 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_whitelist);
|
2010-02-15 15:01:37 +02:00
|
|
|
int init_regex_list(struct regex_matcher* matcher, uint8_t dconf_prefiltering);
|
2010-08-13 00:53:45 +02:00
|
|
|
int load_regex_matcher(struct cl_engine *engine,struct regex_matcher* matcher,FILE* fd,unsigned int *signo,unsigned int options,int is_whitelist,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
|
|
|
|
|