tcell_agent 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +9 -22
- data/bin/tcell_agent +127 -132
- data/lib/tcell_agent/agent/event_processor.rb +23 -22
- data/lib/tcell_agent/agent/fork_pipe_manager.rb +7 -7
- data/lib/tcell_agent/agent/policy_manager.rb +20 -15
- data/lib/tcell_agent/agent/policy_types.rb +5 -11
- data/lib/tcell_agent/agent/static_agent.rb +5 -1
- data/lib/tcell_agent/agent.rb +6 -4
- data/lib/tcell_agent/api.rb +7 -9
- data/lib/tcell_agent/appsensor/meta_data.rb +11 -4
- data/lib/tcell_agent/authlogic.rb +3 -3
- data/lib/tcell_agent/cmdi.rb +6 -4
- data/lib/tcell_agent/config/unknown_options.rb +3 -1
- data/lib/tcell_agent/configuration.rb +47 -49
- data/lib/tcell_agent/devise.rb +2 -2
- data/lib/tcell_agent/hooks/login_fraud.rb +58 -29
- data/lib/tcell_agent/instrumentation.rb +11 -10
- data/lib/tcell_agent/logger.rb +2 -2
- data/lib/tcell_agent/patches/meta_data.rb +9 -13
- data/lib/tcell_agent/patches.rb +7 -10
- data/lib/tcell_agent/policies/clickjacking_policy.rb +4 -5
- data/lib/tcell_agent/policies/content_security_policy.rb +6 -12
- data/lib/tcell_agent/policies/dataloss_policy.rb +2 -2
- data/lib/tcell_agent/policies/http_redirect_policy.rb +2 -2
- data/lib/tcell_agent/policies/policy.rb +0 -2
- data/lib/tcell_agent/policies/rust_policies.rb +90 -0
- data/lib/tcell_agent/policies/secure_headers_policy.rb +2 -2
- data/lib/tcell_agent/rails/auth/authlogic.rb +42 -24
- data/lib/tcell_agent/rails/auth/devise.rb +44 -23
- data/lib/tcell_agent/rails/auth/doorkeeper.rb +33 -15
- data/lib/tcell_agent/rails/better_ip.rb +1 -1
- data/lib/tcell_agent/rails/csrf_exception.rb +2 -2
- data/lib/tcell_agent/rails/dlp/process_request.rb +1 -1
- data/lib/tcell_agent/rails/dlp.rb +6 -6
- data/lib/tcell_agent/rails/dlp_handler.rb +1 -1
- data/lib/tcell_agent/rails/js_agent_insert.rb +1 -1
- data/lib/tcell_agent/rails/middleware/body_filter_middleware.rb +1 -1
- data/lib/tcell_agent/rails/middleware/context_middleware.rb +3 -2
- data/lib/tcell_agent/rails/middleware/headers_middleware.rb +10 -9
- data/lib/tcell_agent/rails/routes/grape.rb +6 -6
- data/lib/tcell_agent/rails/routes.rb +8 -11
- data/lib/tcell_agent/rust/libtcellagent-0.11.1.dylib +0 -0
- data/lib/tcell_agent/rust/{libtcellagent-0.6.1.so → libtcellagent-0.11.1.so} +0 -0
- data/lib/tcell_agent/rust/models.rb +16 -0
- data/lib/tcell_agent/rust/tcellagent-0.11.1.dll +0 -0
- data/lib/tcell_agent/rust/whisperer.rb +119 -48
- data/lib/tcell_agent/sensor_events/appsensor_meta_event.rb +17 -20
- data/lib/tcell_agent/sensor_events/command_injection.rb +50 -5
- data/lib/tcell_agent/sensor_events/login_fraud.rb +34 -18
- data/lib/tcell_agent/sensor_events/patches.rb +21 -0
- data/lib/tcell_agent/sensor_events/server_agent.rb +3 -3
- data/lib/tcell_agent/sensor_events/util/utils.rb +4 -3
- data/lib/tcell_agent/servers/puma.rb +2 -2
- data/lib/tcell_agent/servers/unicorn.rb +1 -1
- data/lib/tcell_agent/utils/passwords.rb +28 -0
- data/lib/tcell_agent/version.rb +1 -1
- data/lib/tcell_agent.rb +1 -5
- data/spec/apps/rails-3.2/config/tcell_agent.config +15 -0
- data/spec/apps/rails-3.2/log/development.log +0 -0
- data/spec/apps/rails-3.2/log/test.log +12 -0
- data/spec/apps/rails-4.1/log/test.log +0 -0
- data/spec/lib/tcell_agent/agent/fork_pipe_manager_spec.rb +46 -45
- data/spec/lib/tcell_agent/agent/policy_manager_spec.rb +276 -164
- data/spec/lib/tcell_agent/agent/static_agent_spec.rb +44 -47
- data/spec/lib/tcell_agent/api/api_spec.rb +16 -16
- data/spec/lib/tcell_agent/appsensor/injections_reporter_spec.rb +131 -116
- data/spec/lib/tcell_agent/appsensor/meta_data_spec.rb +55 -51
- data/spec/lib/tcell_agent/cmdi_spec.rb +413 -436
- data/spec/lib/tcell_agent/config/unknown_options_spec.rb +145 -128
- data/spec/lib/tcell_agent/configuration_spec.rb +165 -169
- data/spec/lib/tcell_agent/hooks/login_fraud_spec.rb +144 -153
- data/spec/lib/tcell_agent/instrumentation_spec.rb +84 -85
- data/spec/lib/tcell_agent/patches_spec.rb +70 -111
- data/spec/lib/tcell_agent/policies/appsensor_policy_spec.rb +313 -244
- data/spec/lib/tcell_agent/policies/clickjacking_policy_spec.rb +28 -28
- data/spec/lib/tcell_agent/policies/command_injection_policy_spec.rb +643 -513
- data/spec/lib/tcell_agent/policies/content_security_policy_spec.rb +55 -102
- data/spec/lib/tcell_agent/policies/dataloss_policy_spec.rb +111 -134
- data/spec/lib/tcell_agent/policies/http_redirect_policy_spec.rb +141 -146
- data/spec/lib/tcell_agent/policies/http_tx_policy_spec.rb +8 -8
- data/spec/lib/tcell_agent/policies/login_policy_spec.rb +15 -17
- data/spec/lib/tcell_agent/policies/patches_policy_spec.rb +231 -559
- data/spec/lib/tcell_agent/policies/secure_headers_policy_spec.rb +27 -27
- data/spec/lib/tcell_agent/rails/better_ip_spec.rb +30 -34
- data/spec/lib/tcell_agent/rails/logger_spec.rb +50 -49
- data/spec/lib/tcell_agent/rails/middleware/appsensor_middleware_spec.rb +182 -199
- data/spec/lib/tcell_agent/rails/middleware/dlp_middleware_spec.rb +110 -84
- data/spec/lib/tcell_agent/rails/middleware/global_middleware_spec.rb +107 -85
- data/spec/lib/tcell_agent/rails/middleware/redirect_middleware_spec.rb +68 -40
- data/spec/lib/tcell_agent/rails/middleware/tcell_body_proxy_spec.rb +81 -67
- data/spec/lib/tcell_agent/rails/responses_spec.rb +33 -37
- data/spec/lib/tcell_agent/rails/routes/grape_spec.rb +116 -121
- data/spec/lib/tcell_agent/rails/routes/route_id_spec.rb +25 -28
- data/spec/lib/tcell_agent/rails/routes/routes_spec.rb +87 -85
- data/spec/lib/tcell_agent/rails_spec.rb +1 -6
- data/spec/lib/tcell_agent/rust/models_spec.rb +112 -0
- data/spec/lib/tcell_agent/rust/whisperer_spec.rb +502 -179
- data/spec/lib/tcell_agent/sensor_events/appsensor_meta_event_spec.rb +44 -33
- data/spec/lib/tcell_agent/sensor_events/dlp_spec.rb +4 -4
- data/spec/lib/tcell_agent/sensor_events/sessions_metric_spec.rb +183 -169
- data/spec/lib/tcell_agent/sensor_events/util/sanitizer_utilities_spec.rb +25 -25
- data/spec/lib/tcell_agent/utils/bounded_queue_spec.rb +17 -20
- data/spec/lib/tcell_agent/utils/params_spec.rb +28 -28
- data/spec/lib/tcell_agent/utils/passwords_spec.rb +143 -0
- data/spec/lib/tcell_agent/utils/strings_spec.rb +35 -35
- data/spec/lib/tcell_agent_spec.rb +8 -8
- data/spec/spec_helper.rb +4 -4
- data/spec/support/middleware_helper.rb +10 -10
- data/spec/support/static_agent_overrides.rb +16 -12
- data/tcell_agent.gemspec +17 -33
- metadata +43 -198
- data/LICENSE_libinjection +0 -32
- data/Readme.txt +0 -7
- data/ext/libinjection/extconf.rb +0 -3
- data/ext/libinjection/libinjection.h +0 -65
- data/ext/libinjection/libinjection_html5.c +0 -847
- data/ext/libinjection/libinjection_html5.h +0 -54
- data/ext/libinjection/libinjection_sqli.c +0 -2317
- data/ext/libinjection/libinjection_sqli.h +0 -295
- data/ext/libinjection/libinjection_sqli_data.h +0 -9004
- data/ext/libinjection/libinjection_wrap.c +0 -3525
- data/ext/libinjection/libinjection_xss.c +0 -531
- data/ext/libinjection/libinjection_xss.h +0 -21
- data/lib/tcell_agent/appsensor/injections_matcher.rb +0 -155
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_manager.rb +0 -49
- data/lib/tcell_agent/appsensor/rules/appsensor_rule_set.rb +0 -67
- data/lib/tcell_agent/appsensor/rules/baserules.json +0 -467
- data/lib/tcell_agent/patches/block_rule.rb +0 -93
- data/lib/tcell_agent/patches/sensors_matcher.rb +0 -31
- data/lib/tcell_agent/policies/appsensor/cmdi_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/fpt_sensor.rb +0 -23
- data/lib/tcell_agent/policies/appsensor/injection_sensor.rb +0 -117
- data/lib/tcell_agent/policies/appsensor/nullbyte_sensor.rb +0 -26
- data/lib/tcell_agent/policies/appsensor/retr_sensor.rb +0 -22
- data/lib/tcell_agent/policies/appsensor/sqli_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor/xss_sensor.rb +0 -34
- data/lib/tcell_agent/policies/appsensor_policy.rb +0 -49
- data/lib/tcell_agent/policies/command_injection_policy.rb +0 -196
- data/lib/tcell_agent/policies/honeytokens_policy.rb +0 -69
- data/lib/tcell_agent/policies/patches_policy.rb +0 -84
- data/lib/tcell_agent/rust/libtcellagent-0.6.1.dylib +0 -0
- data/lib/tcell_agent/rust/tcellagent-0.6.1.dll +0 -0
- data/spec/apps/rails-3.2/Gemfile +0 -25
- data/spec/apps/rails-3.2/Gemfile.lock +0 -126
- data/spec/apps/rails-3.2/Rakefile +0 -7
- data/spec/apps/rails-3.2/app/assets/images/rails.png +0 -0
- data/spec/apps/rails-3.2/app/assets/javascripts/application.js +0 -15
- data/spec/apps/rails-3.2/app/assets/stylesheets/application.css +0 -13
- data/spec/apps/rails-3.2/app/controllers/application_controller.rb +0 -3
- data/spec/apps/rails-3.2/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-3.2/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-3.2/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-3.2/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-3.2/config/application.rb +0 -63
- data/spec/apps/rails-3.2/config/boot.rb +0 -6
- data/spec/apps/rails-3.2/config/environment.rb +0 -5
- data/spec/apps/rails-3.2/config/environments/test.rb +0 -37
- data/spec/apps/rails-3.2/config/routes.rb +0 -11
- data/spec/apps/rails-3.2/config.ru +0 -4
- data/spec/apps/rails-4.1/Gemfile +0 -7
- data/spec/apps/rails-4.1/Gemfile.lock +0 -114
- data/spec/apps/rails-4.1/Rakefile +0 -6
- data/spec/apps/rails-4.1/app/assets/javascripts/application.js +0 -16
- data/spec/apps/rails-4.1/app/assets/stylesheets/application.css +0 -15
- data/spec/apps/rails-4.1/app/controllers/application_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/controllers/t_cell_app_controller.rb +0 -5
- data/spec/apps/rails-4.1/app/helpers/application_helper.rb +0 -2
- data/spec/apps/rails-4.1/app/views/layouts/application.html.erb +0 -14
- data/spec/apps/rails-4.1/app/views/t_cell_app/index.html.erb +0 -1
- data/spec/apps/rails-4.1/config/application.rb +0 -24
- data/spec/apps/rails-4.1/config/boot.rb +0 -4
- data/spec/apps/rails-4.1/config/environment.rb +0 -5
- data/spec/apps/rails-4.1/config/environments/test.rb +0 -41
- data/spec/apps/rails-4.1/config/initializers/assets.rb +0 -8
- data/spec/apps/rails-4.1/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/apps/rails-4.1/config/initializers/cookies_serializer.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/inflections.rb +0 -16
- data/spec/apps/rails-4.1/config/initializers/mime_types.rb +0 -4
- data/spec/apps/rails-4.1/config/initializers/session_store.rb +0 -3
- data/spec/apps/rails-4.1/config/initializers/wrap_parameters.rb +0 -14
- data/spec/apps/rails-4.1/config/locales/en.yml +0 -23
- data/spec/apps/rails-4.1/config/routes.rb +0 -12
- data/spec/apps/rails-4.1/config/secrets.yml +0 -22
- data/spec/apps/rails-4.1/config.ru +0 -4
- data/spec/controllers/application_controller.rb +0 -12
- data/spec/lib/tcell_agent/appsensor/injections_matcher_spec.rb +0 -522
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_manager_spec.rb +0 -23
- data/spec/lib/tcell_agent/appsensor/rules/appsensor_rule_set_spec.rb +0 -159
- data/spec/lib/tcell_agent/patches/block_rule_spec.rb +0 -458
- data/spec/lib/tcell_agent/patches/sensors_matcher_spec.rb +0 -35
- data/spec/lib/tcell_agent/policies/appsensor/cmdi_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/fpt_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/nullbyte_sensor_spec.rb +0 -167
- data/spec/lib/tcell_agent/policies/appsensor/retr_sensor_spec.rb +0 -139
- data/spec/lib/tcell_agent/policies/appsensor/sqli_sensor_spec.rb +0 -246
- data/spec/lib/tcell_agent/policies/appsensor/xss_sensor_spec.rb +0 -882
- data/spec/lib/tcell_agent/policies/honeytokens_policy_spec.rb +0 -22
@@ -1,295 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Copyright 2012-2016 Nick Galbreath
|
3
|
-
* nickg@client9.com
|
4
|
-
* BSD License -- see `COPYING.txt` for details
|
5
|
-
*
|
6
|
-
* https://libinjection.client9.com/
|
7
|
-
*
|
8
|
-
*/
|
9
|
-
|
10
|
-
#ifndef LIBINJECTION_SQLI_H
|
11
|
-
#define LIBINJECTION_SQLI_H
|
12
|
-
|
13
|
-
#ifdef __cplusplus
|
14
|
-
extern "C" {
|
15
|
-
#endif
|
16
|
-
|
17
|
-
/*
|
18
|
-
* Pull in size_t
|
19
|
-
*/
|
20
|
-
#include <string.h>
|
21
|
-
|
22
|
-
enum sqli_flags {
|
23
|
-
FLAG_NONE = 0
|
24
|
-
, FLAG_QUOTE_NONE = 1 /* 1 << 0 */
|
25
|
-
, FLAG_QUOTE_SINGLE = 2 /* 1 << 1 */
|
26
|
-
, FLAG_QUOTE_DOUBLE = 4 /* 1 << 2 */
|
27
|
-
|
28
|
-
, FLAG_SQL_ANSI = 8 /* 1 << 3 */
|
29
|
-
, FLAG_SQL_MYSQL = 16 /* 1 << 4 */
|
30
|
-
};
|
31
|
-
|
32
|
-
enum lookup_type {
|
33
|
-
LOOKUP_WORD = 1
|
34
|
-
, LOOKUP_TYPE = 2
|
35
|
-
, LOOKUP_OPERATOR = 3
|
36
|
-
, LOOKUP_FINGERPRINT = 4
|
37
|
-
};
|
38
|
-
|
39
|
-
struct libinjection_sqli_token {
|
40
|
-
#ifdef SWIG
|
41
|
-
%immutable;
|
42
|
-
#endif
|
43
|
-
char type;
|
44
|
-
char str_open;
|
45
|
-
char str_close;
|
46
|
-
|
47
|
-
/*
|
48
|
-
* position and length of token
|
49
|
-
* in original string
|
50
|
-
*/
|
51
|
-
size_t pos;
|
52
|
-
size_t len;
|
53
|
-
|
54
|
-
/* count:
|
55
|
-
* in type 'v', used for number of opening '@'
|
56
|
-
* but maybe used in other contexts
|
57
|
-
*/
|
58
|
-
int count;
|
59
|
-
|
60
|
-
char val[32];
|
61
|
-
};
|
62
|
-
|
63
|
-
typedef struct libinjection_sqli_token stoken_t;
|
64
|
-
|
65
|
-
/**
|
66
|
-
* Pointer to function, takes c-string input,
|
67
|
-
* returns '\0' for no match, else a char
|
68
|
-
*/
|
69
|
-
struct libinjection_sqli_state;
|
70
|
-
typedef char (*ptr_lookup_fn)(struct libinjection_sqli_state*, int lookuptype, const char* word, size_t len);
|
71
|
-
|
72
|
-
struct libinjection_sqli_state {
|
73
|
-
#ifdef SWIG
|
74
|
-
%immutable;
|
75
|
-
#endif
|
76
|
-
|
77
|
-
/*
|
78
|
-
* input, does not need to be null terminated.
|
79
|
-
* it is also not modified.
|
80
|
-
*/
|
81
|
-
const char *s;
|
82
|
-
|
83
|
-
/*
|
84
|
-
* input length
|
85
|
-
*/
|
86
|
-
size_t slen;
|
87
|
-
|
88
|
-
/*
|
89
|
-
* How to lookup a word or fingerprint
|
90
|
-
*/
|
91
|
-
ptr_lookup_fn lookup;
|
92
|
-
void* userdata;
|
93
|
-
|
94
|
-
/*
|
95
|
-
*
|
96
|
-
*/
|
97
|
-
int flags;
|
98
|
-
|
99
|
-
/*
|
100
|
-
* pos is the index in the string during tokenization
|
101
|
-
*/
|
102
|
-
size_t pos;
|
103
|
-
|
104
|
-
#ifndef SWIG
|
105
|
-
/* for SWIG.. don't use this.. use functional API instead */
|
106
|
-
|
107
|
-
/* MAX TOKENS + 1 since we use one extra token
|
108
|
-
* to determine the type of the previous token
|
109
|
-
*/
|
110
|
-
struct libinjection_sqli_token tokenvec[8];
|
111
|
-
#endif
|
112
|
-
|
113
|
-
/*
|
114
|
-
* Pointer to token position in tokenvec, above
|
115
|
-
*/
|
116
|
-
struct libinjection_sqli_token *current;
|
117
|
-
|
118
|
-
/*
|
119
|
-
* fingerprint pattern c-string
|
120
|
-
* +1 for ending null
|
121
|
-
* Minimum of 8 bytes to add gcc's -fstack-protector to work
|
122
|
-
*/
|
123
|
-
char fingerprint[8];
|
124
|
-
|
125
|
-
/*
|
126
|
-
* Line number of code that said decided if the input was SQLi or
|
127
|
-
* not. Most of the time it's line that said "it's not a matching
|
128
|
-
* fingerprint" but there is other logic that sometimes approves
|
129
|
-
* an input. This is only useful for debugging.
|
130
|
-
*
|
131
|
-
*/
|
132
|
-
int reason;
|
133
|
-
|
134
|
-
/* Number of ddw (dash-dash-white) comments
|
135
|
-
* These comments are in the form of
|
136
|
-
* '--[whitespace]' or '--[EOF]'
|
137
|
-
*
|
138
|
-
* All databases treat this as a comment.
|
139
|
-
*/
|
140
|
-
int stats_comment_ddw;
|
141
|
-
|
142
|
-
/* Number of ddx (dash-dash-[notwhite]) comments
|
143
|
-
*
|
144
|
-
* ANSI SQL treats these are comments, MySQL treats this as
|
145
|
-
* two unary operators '-' '-'
|
146
|
-
*
|
147
|
-
* If you are parsing result returns FALSE and
|
148
|
-
* stats_comment_dd > 0, you should reparse with
|
149
|
-
* COMMENT_MYSQL
|
150
|
-
*
|
151
|
-
*/
|
152
|
-
int stats_comment_ddx;
|
153
|
-
|
154
|
-
/*
|
155
|
-
* c-style comments found /x .. x/
|
156
|
-
*/
|
157
|
-
int stats_comment_c;
|
158
|
-
|
159
|
-
/* '#' operators or MySQL EOL comments found
|
160
|
-
*
|
161
|
-
*/
|
162
|
-
int stats_comment_hash;
|
163
|
-
|
164
|
-
/*
|
165
|
-
* number of tokens folded away
|
166
|
-
*/
|
167
|
-
int stats_folds;
|
168
|
-
|
169
|
-
/*
|
170
|
-
* total tokens processed
|
171
|
-
*/
|
172
|
-
int stats_tokens;
|
173
|
-
|
174
|
-
};
|
175
|
-
|
176
|
-
typedef struct libinjection_sqli_state sfilter;
|
177
|
-
|
178
|
-
struct libinjection_sqli_token* libinjection_sqli_get_token(
|
179
|
-
struct libinjection_sqli_state* sqlistate, int i);
|
180
|
-
|
181
|
-
/*
|
182
|
-
* Version info.
|
183
|
-
*
|
184
|
-
* This is moved into a function to allow SWIG and other auto-generated
|
185
|
-
* binding to not be modified during minor release changes. We change
|
186
|
-
* change the version number in the c source file, and not regenerated
|
187
|
-
* the binding
|
188
|
-
*
|
189
|
-
* See python's normalized version
|
190
|
-
* http://www.python.org/dev/peps/pep-0386/#normalizedversion
|
191
|
-
*/
|
192
|
-
const char* libinjection_version(void);
|
193
|
-
|
194
|
-
/**
|
195
|
-
*
|
196
|
-
*/
|
197
|
-
void libinjection_sqli_init(struct libinjection_sqli_state* sql_state,
|
198
|
-
const char* s, size_t slen,
|
199
|
-
int flags);
|
200
|
-
|
201
|
-
/**
|
202
|
-
* Main API: tests for SQLi in three possible contexts, no quotes,
|
203
|
-
* single quote and double quote
|
204
|
-
*
|
205
|
-
* \param sql_state core data structure
|
206
|
-
*
|
207
|
-
* \return 1 (true) if SQLi, 0 (false) if benign
|
208
|
-
*/
|
209
|
-
int libinjection_is_sqli(struct libinjection_sqli_state* sql_state);
|
210
|
-
|
211
|
-
/* FOR HACKERS ONLY
|
212
|
-
* provides deep hooks into the decision making process
|
213
|
-
*/
|
214
|
-
void libinjection_sqli_callback(struct libinjection_sqli_state* sql_state,
|
215
|
-
ptr_lookup_fn fn,
|
216
|
-
void* userdata);
|
217
|
-
|
218
|
-
|
219
|
-
/*
|
220
|
-
* Resets state, but keeps initial string and callbacks
|
221
|
-
*/
|
222
|
-
void libinjection_sqli_reset(struct libinjection_sqli_state* sql_state,
|
223
|
-
int flags);
|
224
|
-
|
225
|
-
/**
|
226
|
-
*
|
227
|
-
*/
|
228
|
-
|
229
|
-
/**
|
230
|
-
* This detects SQLi in a single context, mostly useful for custom
|
231
|
-
* logic and debugging.
|
232
|
-
*
|
233
|
-
* \param sql_state Main data structure
|
234
|
-
* \param flags flags to adjust parsing
|
235
|
-
*
|
236
|
-
* \returns a pointer to sfilter.fingerprint as convenience
|
237
|
-
* do not free!
|
238
|
-
*
|
239
|
-
*/
|
240
|
-
const char* libinjection_sqli_fingerprint(struct libinjection_sqli_state* sql_state,
|
241
|
-
int flags);
|
242
|
-
|
243
|
-
/**
|
244
|
-
* The default "word" to token-type or fingerprint function. This
|
245
|
-
* uses a ASCII case-insensitive binary tree.
|
246
|
-
*/
|
247
|
-
char libinjection_sqli_lookup_word(struct libinjection_sqli_state* sql_state,
|
248
|
-
int lookup_type,
|
249
|
-
const char* s,
|
250
|
-
size_t slen);
|
251
|
-
|
252
|
-
/* Streaming tokenization interface.
|
253
|
-
*
|
254
|
-
* sql_state->current is updated with the current token.
|
255
|
-
*
|
256
|
-
* \returns 1, has a token, keep going, or 0 no tokens
|
257
|
-
*
|
258
|
-
*/
|
259
|
-
int libinjection_sqli_tokenize(struct libinjection_sqli_state * sql_state);
|
260
|
-
|
261
|
-
/**
|
262
|
-
* parses and folds input, up to 5 tokens
|
263
|
-
*
|
264
|
-
*/
|
265
|
-
int libinjection_sqli_fold(struct libinjection_sqli_state * sql_state);
|
266
|
-
|
267
|
-
/** The built-in default function to match fingerprints
|
268
|
-
* and do false negative/positive analysis. This calls the following
|
269
|
-
* two functions. With this, you over-ride one part or the other.
|
270
|
-
*
|
271
|
-
* return libinjection_sqli_blacklist(sql_state) &&
|
272
|
-
* libinjection_sqli_not_whitelist(sql_state);
|
273
|
-
*
|
274
|
-
* \param sql_state should be filled out after libinjection_sqli_fingerprint is called
|
275
|
-
*/
|
276
|
-
int libinjection_sqli_check_fingerprint(struct libinjection_sqli_state * sql_state);
|
277
|
-
|
278
|
-
/* Given a pattern determine if it's a SQLi pattern.
|
279
|
-
*
|
280
|
-
* \return TRUE if sqli, false otherwise
|
281
|
-
*/
|
282
|
-
int libinjection_sqli_blacklist(struct libinjection_sqli_state* sql_state);
|
283
|
-
|
284
|
-
/* Given a positive match for a pattern (i.e. pattern is SQLi), this function
|
285
|
-
* does additional analysis to reduce false positives.
|
286
|
-
*
|
287
|
-
* \return TRUE if SQLi, false otherwise
|
288
|
-
*/
|
289
|
-
int libinjection_sqli_not_whitelist(struct libinjection_sqli_state * sql_state);
|
290
|
-
|
291
|
-
#ifdef __cplusplus
|
292
|
-
}
|
293
|
-
#endif
|
294
|
-
|
295
|
-
#endif /* LIBINJECTION_SQLI_H */
|