suricata
detect-tls-cert-validity.c
Go to the documentation of this file.
1 /* Copyright (C) 2015-2020 Open Information Security Foundation
2  *
3  * You can copy, redistribute or modify this Program under the terms of
4  * the GNU General Public License version 2 as published by the Free
5  * Software Foundation.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * version 2 along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15  * 02110-1301, USA.
16  */
17 
18 /**
19  * \file
20  *
21  * \author Mats Klepsland <mats.klepsland@gmail.com>
22  *
23  * Implements tls certificate validity keywords
24  */
25 
26 #include "suricata-common.h"
27 #include "threads.h"
28 #include "decode.h"
29 #include "detect.h"
30 
31 #include "detect-parse.h"
32 #include "detect-engine.h"
33 #include "detect-engine-mpm.h"
34 #include "detect-content.h"
35 #include "detect-pcre.h"
37 
38 #include "flow.h"
39 #include "flow-util.h"
40 #include "flow-var.h"
41 
42 #include "stream-tcp.h"
43 
44 #include "app-layer.h"
45 #include "app-layer-ssl.h"
46 
47 #include "util-time.h"
48 #include "util-unittest.h"
49 #include "util-unittest-helper.h"
50 
51 /**
52  * [tls_notbefore|tls_notafter]:[<|>]<date string>[<><date string>];
53  */
54 #define PARSE_REGEX "^\\s*(<|>)?\\s*([ -:TW0-9]+)\\s*(?:(<>)\\s*([ -:TW0-9]+))?\\s*$"
55 static DetectParseRegex parse_regex;
56 
57 static int DetectTlsValidityMatch (DetectEngineThreadCtx *, Flow *,
58  uint8_t, void *, void *, const Signature *,
59  const SigMatchCtx *);
60 
61 static time_t DateStringToEpoch (char *);
62 static DetectTlsValidityData *DetectTlsValidityParse (const char *);
63 static int DetectTlsExpiredSetup (DetectEngineCtx *, Signature *s, const char *str);
64 static int DetectTlsValidSetup (DetectEngineCtx *, Signature *s, const char *str);
65 static int DetectTlsNotBeforeSetup (DetectEngineCtx *, Signature *s, const char *str);
66 static int DetectTlsNotAfterSetup (DetectEngineCtx *, Signature *s, const char *str);
67 static int DetectTlsValiditySetup (DetectEngineCtx *, Signature *s, const char *str, uint8_t);
68 #ifdef UNITTESTS
69 static void TlsNotBeforeRegisterTests(void);
70 static void TlsNotAfterRegisterTests(void);
71 static void TlsExpiredRegisterTests(void);
72 static void TlsValidRegisterTests(void);
73 #endif /* UNITTESTS */
74 static void DetectTlsValidityFree(DetectEngineCtx *, void *);
75 static int g_tls_validity_buffer_id = 0;
76 
77 /**
78  * \brief Registration function for tls validity keywords.
79  */
81 {
82  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].name = "tls_cert_notbefore";
83  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].desc = "match TLS certificate notBefore field";
84  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].url = "/rules/tls-keywords.html#tls-cert-notbefore";
85  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].AppLayerTxMatch = DetectTlsValidityMatch;
86  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].Setup = DetectTlsNotBeforeSetup;
87  sigmatch_table[DETECT_AL_TLS_NOTBEFORE].Free = DetectTlsValidityFree;
88 #ifdef UNITTESTS
90 #endif
91 
92  sigmatch_table[DETECT_AL_TLS_NOTAFTER].name = "tls_cert_notafter";
93  sigmatch_table[DETECT_AL_TLS_NOTAFTER].desc = "match TLS certificate notAfter field";
94  sigmatch_table[DETECT_AL_TLS_NOTAFTER].url = "/rules/tls-keywords.html#tls-cert-notafter";
95  sigmatch_table[DETECT_AL_TLS_NOTAFTER].AppLayerTxMatch = DetectTlsValidityMatch;
96  sigmatch_table[DETECT_AL_TLS_NOTAFTER].Setup = DetectTlsNotAfterSetup;
97  sigmatch_table[DETECT_AL_TLS_NOTAFTER].Free = DetectTlsValidityFree;
98 #ifdef UNITTESTS
100 #endif
101 
102  sigmatch_table[DETECT_AL_TLS_EXPIRED].name = "tls_cert_expired";
103  sigmatch_table[DETECT_AL_TLS_EXPIRED].desc = "match expired TLS certificates";
104  sigmatch_table[DETECT_AL_TLS_EXPIRED].url = "/rules/tls-keywords.html#tls-cert-expired";
105  sigmatch_table[DETECT_AL_TLS_EXPIRED].AppLayerTxMatch = DetectTlsValidityMatch;
106  sigmatch_table[DETECT_AL_TLS_EXPIRED].Setup = DetectTlsExpiredSetup;
107  sigmatch_table[DETECT_AL_TLS_EXPIRED].Free = DetectTlsValidityFree;
109 #ifdef UNITTESTS
111 #endif
112 
113  sigmatch_table[DETECT_AL_TLS_VALID].name = "tls_cert_valid";
114  sigmatch_table[DETECT_AL_TLS_VALID].desc = "match valid TLS certificates";
115  sigmatch_table[DETECT_AL_TLS_VALID].url = "/rules/tls-keywords.html#tls-cert-valid";
116  sigmatch_table[DETECT_AL_TLS_VALID].AppLayerTxMatch = DetectTlsValidityMatch;
117  sigmatch_table[DETECT_AL_TLS_VALID].Setup = DetectTlsValidSetup;
118  sigmatch_table[DETECT_AL_TLS_VALID].Free = DetectTlsValidityFree;
120 #ifdef UNITTESTS
122 #endif
123 
124  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
125 
128 
129  g_tls_validity_buffer_id = DetectBufferTypeGetByName("tls_validity");
130 }
131 
132 /**
133  * \internal
134  * \brief Function to match validity field in a tls certificate.
135  *
136  * \param t Pointer to thread vars.
137  * \param det_ctx Pointer to the pattern matcher thread.
138  * \param f Pointer to the current flow.
139  * \param flags Flags.
140  * \param state App layer state.
141  * \param s Pointer to the Signature.
142  * \param m Pointer to the sigmatch that we will cast into
143  * DetectTlsValidityData.
144  *
145  * \retval 0 no match.
146  * \retval 1 match.
147  */
148 static int DetectTlsValidityMatch (DetectEngineThreadCtx *det_ctx,
149  Flow *f, uint8_t flags, void *state,
150  void *txv, const Signature *s,
151  const SigMatchCtx *ctx)
152 {
153  SCEnter();
154 
155  SSLState *ssl_state = (SSLState *)state;
156  if (ssl_state == NULL) {
157  SCLogDebug("no tls state, no match");
158  SCReturnInt(0);
159  }
160 
161  int ret = 0;
162 
163  SSLStateConnp *connp = NULL;
164  if (flags & STREAM_TOSERVER)
165  connp = &ssl_state->client_connp;
166  else
167  connp = &ssl_state->server_connp;
168 
169  const DetectTlsValidityData *dd = (const DetectTlsValidityData *)ctx;
170 
171  time_t cert_epoch = 0;
172  if (dd->type == DETECT_TLS_TYPE_NOTBEFORE)
173  cert_epoch = connp->cert0_not_before;
174  else if (dd->type == DETECT_TLS_TYPE_NOTAFTER)
175  cert_epoch = connp->cert0_not_after;
176 
177  if (cert_epoch == 0)
178  SCReturnInt(0);
179 
180  if ((dd->mode & DETECT_TLS_VALIDITY_EQ) && cert_epoch == dd->epoch)
181  ret = 1;
182  else if ((dd->mode & DETECT_TLS_VALIDITY_LT) && cert_epoch <= dd->epoch)
183  ret = 1;
184  else if ((dd->mode & DETECT_TLS_VALIDITY_GT) && cert_epoch >= dd->epoch)
185  ret = 1;
186  else if ((dd->mode & DETECT_TLS_VALIDITY_RA) &&
187  cert_epoch >= dd->epoch && cert_epoch <= dd->epoch2)
188  ret = 1;
189  else if ((dd->mode & DETECT_TLS_VALIDITY_EX) && (time_t)SCTIME_SECS(f->lastts) > cert_epoch)
190  ret = 1;
191  else if ((dd->mode & DETECT_TLS_VALIDITY_VA) && (time_t)SCTIME_SECS(f->lastts) <= cert_epoch)
192  ret = 1;
193 
194  SCReturnInt(ret);
195 }
196 
197 /**
198  * \internal
199  * \brief Function to check if string is epoch.
200  *
201  * \param string Date string.
202  *
203  * \retval epoch time on success.
204  * \retval LONG_MIN on failure.
205  */
206 static time_t StringIsEpoch (char *string)
207 {
208  if (strlen(string) == 0)
209  return LONG_MIN;
210 
211  /* We assume that the date string is epoch if it consists of only
212  digits. */
213  char *sp = string;
214  while (*sp) {
215  if (isdigit(*sp++) == 0)
216  return LONG_MIN;
217  }
218 
219  return strtol(string, NULL, 10);
220 }
221 
222 /**
223  * \internal
224  * \brief Function to convert date string to epoch.
225  *
226  * \param string Date string.
227  *
228  * \retval epoch on success.
229  * \retval 0 on failure.
230  */
231 static time_t DateStringToEpoch (char *string)
232 {
233  int r = 0;
234  struct tm tm;
235  const char *patterns[] = {
236  /* ISO 8601 */
237  "%Y-%m",
238  "%Y-%m-%d",
239  "%Y-%m-%d %H",
240  "%Y-%m-%d %H:%M",
241  "%Y-%m-%d %H:%M:%S",
242  "%Y-%m-%dT%H",
243  "%Y-%m-%dT%H:%M",
244  "%Y-%m-%dT%H:%M:%S",
245  "%H:%M",
246  "%H:%M:%S",
247  };
248 
249  /* Skip leading whitespace. */
250  while (isspace(*string))
251  string++;
252 
253  size_t inlen, oldlen;
254 
255  oldlen = inlen = strlen(string);
256 
257  /* Skip trailing whitespace */
258  while (inlen > 0 && isspace(string[inlen - 1]))
259  inlen--;
260 
261  char tmp[inlen + 1];
262 
263  if (inlen < oldlen) {
264  strlcpy(tmp, string, inlen + 1);
265  string = tmp;
266  }
267 
268  time_t epoch = StringIsEpoch(string);
269  if (epoch != LONG_MIN) {
270  return epoch;
271  }
272 
273  r = SCStringPatternToTime(string, patterns, 10, &tm);
274 
275  if (r != 0)
276  return LONG_MIN;
277 
278  return SCMkTimeUtc(&tm);
279 }
280 
281 /**
282  * \internal
283  * \brief Function to parse options passed via tls validity keywords.
284  *
285  * \param rawstr Pointer to the user provided options.
286  *
287  * \retval dd pointer to DetectTlsValidityData on success.
288  * \retval NULL on failure.
289  */
290 static DetectTlsValidityData *DetectTlsValidityParse (const char *rawstr)
291 {
292  DetectTlsValidityData *dd = NULL;
293  char mode[2] = "";
294  char value1[20] = "";
295  char value2[20] = "";
296  char range[3] = "";
297 
298  pcre2_match_data *match = NULL;
299  int ret = DetectParsePcreExec(&parse_regex, &match, rawstr, 0, 0);
300  if (ret < 3 || ret > 5) {
301  SCLogError("Parse error %s", rawstr);
302  goto error;
303  }
304 
305  size_t pcre2len = sizeof(mode);
306  int res = SC_Pcre2SubstringCopy(match, 1, (PCRE2_UCHAR8 *)mode, &pcre2len);
307  if (res < 0) {
308  SCLogError("pcre2_substring_copy_bynumber failed");
309  goto error;
310  }
311  SCLogDebug("mode \"%s\"", mode);
312 
313  pcre2len = sizeof(value1);
314  res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)value1, &pcre2len);
315  if (res < 0) {
316  SCLogError("pcre2_substring_copy_bynumber failed");
317  goto error;
318  }
319  SCLogDebug("value1 \"%s\"", value1);
320 
321  if (ret > 3) {
322  pcre2len = sizeof(range);
323  res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)range, &pcre2len);
324  if (res < 0) {
325  SCLogError("pcre2_substring_copy_bynumber failed");
326  goto error;
327  }
328  SCLogDebug("range \"%s\"", range);
329 
330  if (ret > 4) {
331  pcre2len = sizeof(value2);
332  res = pcre2_substring_copy_bynumber(match, 4, (PCRE2_UCHAR8 *)value2, &pcre2len);
333  if (res < 0) {
334  SCLogError("pcre2_substring_copy_bynumber failed");
335  goto error;
336  }
337  SCLogDebug("value2 \"%s\"", value2);
338  }
339  }
340 
341  dd = SCMalloc(sizeof(DetectTlsValidityData));
342  if (unlikely(dd == NULL))
343  goto error;
344 
345  dd->epoch = 0;
346  dd->epoch2 = 0;
347  dd->mode = 0;
348 
349  if (strlen(mode) > 0) {
350  if (mode[0] == '<')
352  else if (mode[0] == '>')
354  }
355 
356  if (strlen(range) > 0) {
357  if (strcmp("<>", range) == 0)
359  }
360 
361  if (strlen(range) != 0 && strlen(mode) != 0) {
362  SCLogError("Range specified but mode also set");
363  goto error;
364  }
365 
366  if (dd->mode == 0) {
368  }
369 
370  /* set the first value */
371  dd->epoch = DateStringToEpoch(value1);
372  if (dd->epoch == LONG_MIN)
373  goto error;
374 
375  /* set the second value if specified */
376  if (strlen(value2) > 0) {
377  if (!(dd->mode & DETECT_TLS_VALIDITY_RA)) {
378  SCLogError("Multiple tls validity values specified but mode is not range");
379  goto error;
380  }
381 
382  dd->epoch2 = DateStringToEpoch(value2);
383  if (dd->epoch2 == LONG_MIN)
384  goto error;
385 
386  if (dd->epoch2 <= dd->epoch) {
387  SCLogError("Second value in range must not be smaller than the first");
388  goto error;
389  }
390  }
391  pcre2_match_data_free(match);
392  return dd;
393 
394 error:
395  if (match) {
396  pcre2_match_data_free(match);
397  }
398  if (dd)
399  SCFree(dd);
400  return NULL;
401 }
402 
403 /**
404  * \brief Function to add the parsed tls_cert_expired into the current signature.
405  *
406  * \param de_ctx Pointer to the Detection Engine Context.
407  * \param s Pointer to the Current Signature.
408  * \param rawstr Pointer to the user provided flags options.
409  *
410  * \retval 0 on Success.
411  * \retval -1 on Failure.
412  */
413 static int DetectTlsExpiredSetup (DetectEngineCtx *de_ctx, Signature *s,
414  const char *rawstr)
415 {
416  DetectTlsValidityData *dd = NULL;
417 
418  SCLogDebug("\'%s\'", rawstr);
419 
421  return -1;
422 
423  dd = SCCalloc(1, sizeof(DetectTlsValidityData));
424  if (dd == NULL) {
425  SCLogError("Allocation \'%s\' failed", rawstr);
426  goto error;
427  }
428 
429  /* okay so far so good, lets get this into a SigMatch
430  * and put it in the Signature. */
431 
434  dd->epoch = 0;
435  dd->epoch2 = 0;
436 
438  g_tls_validity_buffer_id) == NULL) {
439  goto error;
440  }
441  return 0;
442 
443 error:
444  DetectTlsValidityFree(de_ctx, dd);
445  return -1;
446 }
447 
448 /**
449  * \brief Function to add the parsed tls_cert_valid into the current signature.
450  *
451  * \param de_ctx Pointer to the Detection Engine Context.
452  * \param s Pointer to the Current Signature.
453  * \param rawstr Pointer to the user provided flags options.
454  *
455  * \retval 0 on Success.
456  * \retval -1 on Failure.
457  */
458 static int DetectTlsValidSetup (DetectEngineCtx *de_ctx, Signature *s,
459  const char *rawstr)
460 {
461  DetectTlsValidityData *dd = NULL;
462 
463  SCLogDebug("\'%s\'", rawstr);
464 
466  return -1;
467 
468  dd = SCCalloc(1, sizeof(DetectTlsValidityData));
469  if (dd == NULL) {
470  SCLogError("Allocation \'%s\' failed", rawstr);
471  goto error;
472  }
473 
474  /* okay so far so good, lets get this into a SigMatch
475  * and put it in the Signature. */
476 
479  dd->epoch = 0;
480  dd->epoch2 = 0;
481 
483  g_tls_validity_buffer_id) == NULL) {
484  goto error;
485  }
486  return 0;
487 
488 error:
489  DetectTlsValidityFree(de_ctx, dd);
490  return -1;
491 }
492 
493 /**
494  * \brief Function to add the parsed tls_notbefore into the current signature.
495  *
496  * \param de_ctx Pointer to the Detection Engine Context.
497  * \param s Pointer to the Current Signature.
498  * \param rawstr Pointer to the user provided flags options.
499  *
500  * \retval 0 on Success.
501  * \retval -1 on Failure.
502  */
503 static int DetectTlsNotBeforeSetup (DetectEngineCtx *de_ctx, Signature *s,
504  const char *rawstr)
505 {
507  int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type);
508 
509  SCReturnInt(r);
510 }
511 
512 /**
513  * \brief Function to add the parsed tls_notafter into the current signature.
514  *
515  * \param de_ctx Pointer to the Detection Engine Context.
516  * \param s Pointer to the Current Signature.
517  * \param rawstr Pointer to the user provided flags options.
518  *
519  * \retval 0 on Success.
520  * \retval -1 on Failure.
521  */
522 static int DetectTlsNotAfterSetup (DetectEngineCtx *de_ctx, Signature *s,
523  const char *rawstr)
524 {
525  uint8_t type = DETECT_TLS_TYPE_NOTAFTER;
526  int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type);
527 
528  SCReturnInt(r);
529 }
530 
531 /**
532  * \brief Function to add the parsed tls validity field into the current signature.
533  *
534  * \param de_ctx Pointer to the Detection Engine Context.
535  * \param s Pointer to the Current Signature.
536  * \param rawstr Pointer to the user provided flags options.
537  * \param type Defines if this is notBefore or notAfter.
538  *
539  * \retval 0 on Success.
540  * \retval -1 on Failure.
541  */
542 static int DetectTlsValiditySetup (DetectEngineCtx *de_ctx, Signature *s,
543  const char *rawstr, uint8_t type)
544 {
545  DetectTlsValidityData *dd = NULL;
546 
547  SCLogDebug("\'%s\'", rawstr);
548 
550  return -1;
551 
552  dd = DetectTlsValidityParse(rawstr);
553  if (dd == NULL) {
554  SCLogError("Parsing \'%s\' failed", rawstr);
555  goto error;
556  }
557 
558  /* okay so far so good, lets get this into a SigMatch
559  * and put it in the Signature. */
560 
563  }
564  else if (type == DETECT_TLS_TYPE_NOTAFTER) {
566  }
567  else {
568  goto error;
569  }
570 
572  g_tls_validity_buffer_id) == NULL) {
573  goto error;
574  }
575  return 0;
576 
577 error:
578  DetectTlsValidityFree(de_ctx, dd);
579  return -1;
580 }
581 
582 /**
583  * \internal
584  * \brief Function to free memory associated with DetectTlsValidityData.
585  *
586  * \param de_ptr Pointer to DetectTlsValidityData.
587  */
588 void DetectTlsValidityFree(DetectEngineCtx *de_ctx, void *de_ptr)
589 {
591  if (dd)
592  SCFree(dd);
593 }
594 
595 #ifdef UNITTESTS
597 #endif
DETECT_AL_TLS_EXPIRED
@ DETECT_AL_TLS_EXPIRED
Definition: detect-engine-register.h:139
SigTableElmt_::url
const char * url
Definition: detect.h:1307
DetectSignatureSetAppProto
int DetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:1737
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:296
detect-content.h
DetectTlsValidityData_::type
uint8_t type
Definition: detect-tls-cert-validity.h:45
detect-engine.h
SigTableElmt_::desc
const char * desc
Definition: detect.h:1306
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:127
DETECT_TLS_TYPE_NOTAFTER
#define DETECT_TLS_TYPE_NOTAFTER
Definition: detect-tls-cert-validity.h:39
SigTableElmt_::Free
void(* Free)(DetectEngineCtx *, void *)
Definition: detect.h:1294
flow-util.h
DetectParseRegex
Definition: detect-parse.h:62
SigTableElmt_::name
const char * name
Definition: detect.h:1304
stream-tcp.h
detect-tls-cert-validity.h
unlikely
#define unlikely(expr)
Definition: util-optimize.h:35
SSLState_::client_connp
SSLStateConnp client_connp
Definition: app-layer-ssl.h:314
ALPROTO_TLS
@ ALPROTO_TLS
Definition: app-layer-protos.h:33
DETECT_TLS_VALIDITY_EQ
#define DETECT_TLS_VALIDITY_EQ
Definition: detect-tls-cert-validity.h:27
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:269
TlsNotBeforeRegisterTests
void TlsNotBeforeRegisterTests(void)
Register unit tests for tls_cert_notbefore.
Definition: detect-tls-cert-validity.c:1371
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-tls-cert-validity.c:54
SSLState_::server_connp
SSLStateConnp server_connp
Definition: app-layer-ssl.h:315
SSLStateConnp_::cert0_not_before
int64_t cert0_not_before
Definition: app-layer-ssl.h:258
SSLStateConnp_
Definition: app-layer-ssl.h:235
TlsNotAfterRegisterTests
void TlsNotAfterRegisterTests(void)
Register unit tests for tls_cert_notafter.
Definition: detect-tls-cert-validity.c:1393
threads.h
Flow_
Flow data structure.
Definition: flow.h:356
SigTableElmt_::flags
uint16_t flags
Definition: detect.h:1298
ctx
struct Thresholds ctx
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:841
SCMkTimeUtc
time_t SCMkTimeUtc(struct tm *tp)
Convert broken-down time to seconds since Unix epoch.
Definition: util-time.c:442
DETECT_TLS_VALIDITY_RA
#define DETECT_TLS_VALIDITY_RA
Definition: detect-tls-cert-validity.h:30
SigTableElmt_::AppLayerTxMatch
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
Definition: detect.h:1275
DetectTlsValidityRegister
void DetectTlsValidityRegister(void)
Registration function for tls validity keywords.
Definition: detect-tls-cert-validity.c:80
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:2641
SIG_FLAG_TOCLIENT
#define SIG_FLAG_TOCLIENT
Definition: detect.h:268
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1289
detect-pcre.h
util-unittest.h
util-unittest-helper.h
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1093
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: util-strlcpyu.c:43
SSLStateConnp_::cert0_not_after
int64_t cert0_not_after
Definition: app-layer-ssl.h:259
decode.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:17
DetectEngineThreadCtx_
Definition: detect.h:1093
Flow_::lastts
SCTime_t lastts
Definition: flow.h:415
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:2767
SCEnter
#define SCEnter(...)
Definition: util-debug.h:271
detect-engine-mpm.h
detect.h
DetectTlsValidityData_
Definition: detect-tls-cert-validity.h:41
util-time.h
DetectTlsValidityData_::mode
uint8_t mode
Definition: detect-tls-cert-validity.h:44
type
uint16_t type
Definition: decode-vlan.c:107
TLS_STATE_CERT_READY
@ TLS_STATE_CERT_READY
Definition: app-layer-ssl.h:78
detect-tls-cert-validity.c
DETECT_AL_TLS_NOTAFTER
@ DETECT_AL_TLS_NOTAFTER
Definition: detect-engine-register.h:138
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:344
flags
uint8_t flags
Definition: decode-gre.h:0
DETECT_TLS_VALIDITY_LT
#define DETECT_TLS_VALIDITY_LT
Definition: detect-tls-cert-validity.h:28
suricata-common.h
DETECT_TLS_VALIDITY_EX
#define DETECT_TLS_VALIDITY_EX
Definition: detect-tls-cert-validity.h:33
SCTIME_SECS
#define SCTIME_SECS(t)
Definition: util-time.h:57
DetectTlsValidityData_::epoch2
time_t epoch2
Definition: detect-tls-cert-validity.h:43
DetectEngineInspectGenericList
uint8_t DetectEngineInspectGenericList(DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const struct DetectEngineAppInspectionEngine_ *engine, const Signature *s, Flow *f, uint8_t flags, void *alstate, void *txv, uint64_t tx_id)
Do the content inspection & validation for a signature.
Definition: detect-engine.c:2111
DETECT_TLS_VALIDITY_GT
#define DETECT_TLS_VALIDITY_GT
Definition: detect-tls-cert-validity.h:29
DETECT_TLS_VALIDITY_VA
#define DETECT_TLS_VALIDITY_VA
Definition: detect-tls-cert-validity.h:36
SCMalloc
#define SCMalloc(sz)
Definition: util-mem.h:47
str
#define str(s)
Definition: suricata-common.h:291
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:261
SCFree
#define SCFree(p)
Definition: util-mem.h:61
TlsValidRegisterTests
void TlsValidRegisterTests(void)
Register unit tests for tls_cert_valid.
Definition: detect-tls-cert-validity.c:1419
DetectTlsValidityData_::epoch
time_t epoch
Definition: detect-tls-cert-validity.h:42
DETECT_TLS_TYPE_NOTBEFORE
#define DETECT_TLS_TYPE_NOTBEFORE
Definition: detect-tls-cert-validity.h:38
detect-parse.h
Signature_
Signature container.
Definition: detect.h:601
SC_Pcre2SubstringCopy
int SC_Pcre2SubstringCopy(pcre2_match_data *match_data, uint32_t number, PCRE2_UCHAR *buffer, PCRE2_SIZE *bufflen)
Definition: detect-parse.c:2743
DETECT_AL_TLS_NOTBEFORE
@ DETECT_AL_TLS_NOTBEFORE
Definition: detect-engine-register.h:137
DETECT_AL_TLS_VALID
@ DETECT_AL_TLS_VALID
Definition: detect-engine-register.h:140
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1488
DetectAppLayerInspectEngineRegister
void DetectAppLayerInspectEngineRegister(const char *name, AppProto alproto, uint32_t dir, int progress, InspectEngineFuncPtr Callback, InspectionBufferGetDataPtr GetData)
Registers an app inspection engine.
Definition: detect-engine.c:240
SigMatchAppendSMToList
SigMatch * SigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:436
SCStringPatternToTime
int SCStringPatternToTime(char *string, const char **patterns, int num_patterns, struct tm *tp)
Parse a date string based on specified patterns.
Definition: util-time.c:485
flow.h
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:275
flow-var.h
app-layer-ssl.h
TlsExpiredRegisterTests
void TlsExpiredRegisterTests(void)
Register unit tests for tls_cert_expired.
Definition: detect-tls-cert-validity.c:1411
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1296
app-layer.h