Debian Codegraph @

src/FOptionContainer.hpp

raw
1 // FOptionContainer class - contains the options for a filter group,
2 // including the banned/grey/exception site lists and the content/site/url regexp lists
3
4 // For all support, instructions and copyright go to:
5 // http://e2guardian.org/
6 // Released under the GPL v2, with the OpenSSL exception described in the README file.
7
8 #ifndef __HPP_FOPTIONCONTAINER
9 #define __HPP_FOPTIONCONTAINER
10
11 // INCLUDES
12
13 #include "String.hpp"
14 #include "HTMLTemplate.hpp"
15 #include "ListContainer.hpp"
16 #include "ListMeta.hpp"
17 #include "LanguageContainer.hpp"
18 #include "ImageContainer.hpp"
19 #include "RegExp.hpp"
20 //#include "HTTPHeader.hpp"
21 //#include "NaughtyFilter.hpp"
22 #include "StoryBoard.hpp"
23 #include <string>
24 #include <deque>
25
26 // DECLARATIONS
27
28 std::deque<String> *ipToHostname(const char *ip);
29
30 void getClientFromIP(const char *ip, std::string &clienthost);
31
32 class FOptionContainer {
33
34 public:
35 int reporting_level;
36 int category_threshold;
37 bool infection_bypass_errors_only;
38 bool disable_content_scan;
39 bool disable_content_scan_error;
40 bool content_scan_exceptions;
41 bool automitm;
42 int weighted_phrase_mode;
43 unsigned int banned_phrase_list;
44 int group_mode;
45 int embedded_url_weight;
46 int naughtyness_limit;
47 int searchterm_limit;
48 off_t max_upload_size;
49 int filtergroup;
50 bool non_standard_delimiter;
51
52 //SSL certificate checking
53 bool ssl_check_cert = false;
54
55 //SSL Man in the middle
56 bool ssl_mitm = false;
57 bool mitm_check_cert = true;
58
59 #ifdef ENABLE_EMAIL
60 // Email notification patch by J. Gauthier
61 bool notifyav;
62 bool notifycontent;
63 bool use_smtp;
64 int violations;
65 int current_violations;
66 int threshold;
67 long threshold_stamp;
68 bool byuser;
69 #endif
70
71 bool reverse_lookups;
72 bool force_quick_search;
73 int bypass_mode = 0;
74 bool bypass_v2 = false;
75 bool cgi_bypass_v2 = false;
76 int bypass_version = 2;
77 bool cgi_bypass = false;
78 int infection_bypass_mode;
79 bool cgi_infection_bypass = false;
80 bool scan_bypass = false;
81
82 std::string name;
83 std::string magic;
84 std::string imagic;
85 std::string cookie_magic;
86 std::string cgi_magic;
87
88 #ifdef ENABLE_EMAIL
89 // Email notification patch by J. Gauthier
90 std::string mailfrom;
91 std::string avadmin;
92 std::string contentadmin;
93 std::string avsubject;
94 std::string contentsubject;
95 std::string violationbody;
96 #endif
97 #ifdef PRT_DNSAUTH
98 unsigned int auth_exception_site_list;
99 unsigned int auth_exception_url_list;
100 #endif
101 bool use_only_local_allow_lists;
102
103 bool url_redirect_regexp_flag;
104 bool allow_empty_host_certs = false;
105
106
107 // regex search & replace lists
108 std::deque <RegExp> content_regexp_list_comp;
109 std::deque <String> content_regexp_list_rep;
110 RegExp isiphost;
111
112 // access denied address & domain - if they override the defaults
113 std::string access_denied_address;
114 String access_denied_domain;
115 bool ssl_denied_rewrite = false;
116 // search term blocking
117 unsigned int searchterm_list;
118 bool searchterm_flag = false;
119 bool read_errors = false;
120
121 FOptionContainer()
122 : searchterm_flag(false), banned_page(NULL)
123 {};
124
125 ~FOptionContainer();
126 bool read(const char *filename);
127 bool readConfFile(const char *filename, String &list_pwd);
128 void reset();
129 void resetJustListData();
130
131 bool isOurWebserver(String url);
132 #ifdef PRT_DNSAUTH
133 bool inAuthExceptionSiteList(String url, bool doblanket = false, bool ip = false, bool ssl = false);
134 bool inAuthExceptionURLList(String url, bool doblanket = false, bool ip = false, bool ssl = false);
135 #endif
136
137
138
139 StoryBoard StoryB;
140
141 // get HTML template for this group
142 HTMLTemplate *getHTMLTemplate(bool upfail);
143 std::deque<std::string> text_mime;
144 std::deque<std::string> text_mime_stop; // used to exclude text/ mime type from standard e2g phrase scan
145
146 private:
147 // HTML template - if it overrides the default
148 HTMLTemplate *banned_page = nullptr;
149 HTMLTemplate *neterr_page = nullptr;
150
151 ListMeta LMeta;
152
153 bool banned_phrase_flag = false;
154 bool content_regexp_flag = false;
155 #ifdef PRT_DNSAUTH
156 bool auth_exception_site_flag;
157 bool auth_exception_url_flag;
158 #endif
159 bool banned_search_flag;
160
161 std::deque<int> banned_phrase_list_index;
162
163 std::deque<std::string> conffile;
164
165 bool precompileregexps();
166 bool readFile(const char *filename, const char *list_pwd, unsigned int *whichlist, bool sortsw, bool cache, const char *listname);
167 bool compileRegExMatchFile(unsigned int list, std::deque<RegExp> &list_comp,
168 std::deque<String> &list_source, std::deque<unsigned int> &list_ref);
169 bool readRegExReplacementFile(const char *filename, const char *listname, unsigned int &listid,
170 std::deque<String> &list_rep, std::deque<RegExp> &list_comp);
171
172 int findoptionI(const char *option);
173 std::string findoptionS(const char *option);
174 std::deque<String> findoptionM(const char *option);
175 bool realitycheck(int l, int minl, int maxl, const char *emessage);
176 int inRegExpURLList(String &url, std::deque<RegExp> &list_comp, std::deque<unsigned int> &list_ref, unsigned int list, String &lastcategory);
177
178 char *inURLList(String &url, unsigned int list, bool doblanket , bool ip , bool ssl , String &lastcategory);
179 char *inSiteList(String &url, unsigned int list, bool doblanket , bool ip , bool ssl , String &lastcategory);
180
181 char *testBlanketBlock(unsigned int list, bool ip, bool ssl, String &lastcategory);
182 };
183
184 #define __HPP_FOPTIONCONTAINER
185 #endif