bd912dd8 |
/*
* Phishing module: whitelist implementation.
* |
43ecd9a1 |
|
bd912dd8 |
*
* This program is free software; you can redistribute it and/or modify |
38a00199 |
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. |
bd912dd8 |
*
* 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.
*
*/
#if HAVE_CONFIG_H
#include "clamav-config.h"
#endif
#ifndef CL_DEBUG
#define NDEBUG
#endif
#ifdef CL_THREAD_SAFE
#ifndef _REENTRANT
#define _REENTRANT
#endif
#endif
|
43ecd9a1 |
|
bd912dd8 |
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "clamav.h"
#include "others.h"
#include "phish_whitelist.h"
#include "regex_list.h"
|
8ea27f5c |
int whitelist_match(const struct cl_engine* engine,char* real_url,const char* display_url,int hostOnly) |
bd912dd8 |
{
const char* info;/*unused*/ |
4c748c36 |
cli_dbgmsg("Phishing: looking up in whitelist: %s:%s; host-only:%d\n",real_url,display_url,hostOnly); |
b5341ac0 |
return engine->whitelist_matcher ? regex_list_match(engine->whitelist_matcher,real_url,display_url,NULL,hostOnly,&info,1) : 0; |
bd912dd8 |
}
|
3da4dd4c |
int init_whitelist(struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
if(engine) { |
85820f97 |
engine->whitelist_matcher = (struct regex_matcher *) cli_malloc(sizeof(struct regex_matcher)); |
3da4dd4c |
if(!engine->whitelist_matcher)
return CL_EMEM;
return init_regex_list(engine->whitelist_matcher); |
ec481027 |
} |
3da4dd4c |
else
return CL_ENULLARG; |
bd912dd8 |
}
|
3da4dd4c |
int is_whitelist_ok(const struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
return (engine && engine->whitelist_matcher) ? is_regex_ok(engine->whitelist_matcher) : 1; |
bd912dd8 |
}
|
3da4dd4c |
void whitelist_cleanup(const struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
if(engine && engine->whitelist_matcher) {
regex_list_cleanup(engine->whitelist_matcher);
} |
bd912dd8 |
}
|
3da4dd4c |
void whitelist_done(struct cl_engine* engine) |
bd912dd8 |
{ |
3da4dd4c |
if(engine && engine->whitelist_matcher) {
regex_list_done(engine->whitelist_matcher);
free(engine->whitelist_matcher);
engine->whitelist_matcher = NULL;
} |
bd912dd8 |
}
|