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 \
55  "^\\s*(<|>)?\\s*([ -:TW0-9]+[-:TW0-9]+)\\s*(?:(<>)\\s*([ -:TW0-9]+[-:TW0-9]+))?\\s*$"
56 static DetectParseRegex parse_regex;
57 
58 static int DetectTlsValidityMatch (DetectEngineThreadCtx *, Flow *,
59  uint8_t, void *, void *, const Signature *,
60  const SigMatchCtx *);
61 
62 static time_t DateStringToEpoch (char *);
63 static DetectTlsValidityData *DetectTlsValidityParse (const char *);
64 static int DetectTlsExpiredSetup (DetectEngineCtx *, Signature *s, const char *str);
65 static int DetectTlsValidSetup (DetectEngineCtx *, Signature *s, const char *str);
66 static int DetectTlsNotBeforeSetup (DetectEngineCtx *, Signature *s, const char *str);
67 static int DetectTlsNotAfterSetup (DetectEngineCtx *, Signature *s, const char *str);
68 static int DetectTlsValiditySetup (DetectEngineCtx *, Signature *s, const char *str, uint8_t);
69 #ifdef UNITTESTS
70 static void TlsNotBeforeRegisterTests(void);
71 static void TlsNotAfterRegisterTests(void);
72 static void TlsExpiredRegisterTests(void);
73 static void TlsValidRegisterTests(void);
74 #endif /* UNITTESTS */
75 static void DetectTlsValidityFree(DetectEngineCtx *, void *);
76 static int g_tls_validity_buffer_id = 0;
77 
78 /**
79  * \brief Registration function for tls validity keywords.
80  */
82 {
83  sigmatch_table[DETECT_TLS_NOTBEFORE].name = "tls_cert_notbefore";
84  sigmatch_table[DETECT_TLS_NOTBEFORE].desc = "match TLS certificate notBefore field";
85  sigmatch_table[DETECT_TLS_NOTBEFORE].url = "/rules/tls-keywords.html#tls-cert-notbefore";
86  sigmatch_table[DETECT_TLS_NOTBEFORE].AppLayerTxMatch = DetectTlsValidityMatch;
87  sigmatch_table[DETECT_TLS_NOTBEFORE].Setup = DetectTlsNotBeforeSetup;
88  sigmatch_table[DETECT_TLS_NOTBEFORE].Free = DetectTlsValidityFree;
89 #ifdef UNITTESTS
91 #endif
92 
93  sigmatch_table[DETECT_TLS_NOTAFTER].name = "tls_cert_notafter";
94  sigmatch_table[DETECT_TLS_NOTAFTER].desc = "match TLS certificate notAfter field";
95  sigmatch_table[DETECT_TLS_NOTAFTER].url = "/rules/tls-keywords.html#tls-cert-notafter";
96  sigmatch_table[DETECT_TLS_NOTAFTER].AppLayerTxMatch = DetectTlsValidityMatch;
97  sigmatch_table[DETECT_TLS_NOTAFTER].Setup = DetectTlsNotAfterSetup;
98  sigmatch_table[DETECT_TLS_NOTAFTER].Free = DetectTlsValidityFree;
99 #ifdef UNITTESTS
101 #endif
102 
103  sigmatch_table[DETECT_TLS_EXPIRED].name = "tls_cert_expired";
104  sigmatch_table[DETECT_TLS_EXPIRED].desc = "match expired TLS certificates";
105  sigmatch_table[DETECT_TLS_EXPIRED].url = "/rules/tls-keywords.html#tls-cert-expired";
106  sigmatch_table[DETECT_TLS_EXPIRED].AppLayerTxMatch = DetectTlsValidityMatch;
107  sigmatch_table[DETECT_TLS_EXPIRED].Setup = DetectTlsExpiredSetup;
108  sigmatch_table[DETECT_TLS_EXPIRED].Free = DetectTlsValidityFree;
110 #ifdef UNITTESTS
112 #endif
113 
114  sigmatch_table[DETECT_TLS_VALID].name = "tls_cert_valid";
115  sigmatch_table[DETECT_TLS_VALID].desc = "match valid TLS certificates";
116  sigmatch_table[DETECT_TLS_VALID].url = "/rules/tls-keywords.html#tls-cert-valid";
117  sigmatch_table[DETECT_TLS_VALID].AppLayerTxMatch = DetectTlsValidityMatch;
118  sigmatch_table[DETECT_TLS_VALID].Setup = DetectTlsValidSetup;
119  sigmatch_table[DETECT_TLS_VALID].Free = DetectTlsValidityFree;
121 #ifdef UNITTESTS
123 #endif
124 
125  DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);
126 
127  g_tls_validity_buffer_id = DetectBufferTypeGetByName("tls:server_cert_done:generic");
128 }
129 
130 /**
131  * \internal
132  * \brief Function to match validity field in a tls certificate.
133  *
134  * \param t Pointer to thread vars.
135  * \param det_ctx Pointer to the pattern matcher thread.
136  * \param f Pointer to the current flow.
137  * \param flags Flags.
138  * \param state App layer state.
139  * \param s Pointer to the Signature.
140  * \param m Pointer to the sigmatch that we will cast into
141  * DetectTlsValidityData.
142  *
143  * \retval 0 no match.
144  * \retval 1 match.
145  */
146 static int DetectTlsValidityMatch (DetectEngineThreadCtx *det_ctx,
147  Flow *f, uint8_t flags, void *state,
148  void *txv, const Signature *s,
149  const SigMatchCtx *ctx)
150 {
151  SCEnter();
152 
153  SSLState *ssl_state = (SSLState *)state;
154  if (ssl_state == NULL) {
155  SCLogDebug("no tls state, no match");
156  SCReturnInt(0);
157  }
158 
159  int ret = 0;
160 
161  SSLStateConnp *connp = NULL;
162  if (flags & STREAM_TOSERVER)
163  connp = &ssl_state->client_connp;
164  else
165  connp = &ssl_state->server_connp;
166 
167  const DetectTlsValidityData *dd = (const DetectTlsValidityData *)ctx;
168 
169  time_t cert_epoch = 0;
170  if (dd->type == DETECT_TLS_TYPE_NOTBEFORE)
171  cert_epoch = connp->cert0_not_before;
172  else if (dd->type == DETECT_TLS_TYPE_NOTAFTER)
173  cert_epoch = connp->cert0_not_after;
174 
175  if (cert_epoch == 0)
176  SCReturnInt(0);
177 
178  if ((dd->mode & DETECT_TLS_VALIDITY_EQ) && cert_epoch == dd->epoch)
179  ret = 1;
180  else if ((dd->mode & DETECT_TLS_VALIDITY_LT) && cert_epoch <= dd->epoch)
181  ret = 1;
182  else if ((dd->mode & DETECT_TLS_VALIDITY_GT) && cert_epoch >= dd->epoch)
183  ret = 1;
184  else if ((dd->mode & DETECT_TLS_VALIDITY_RA) &&
185  cert_epoch >= dd->epoch && cert_epoch <= dd->epoch2)
186  ret = 1;
187  else if ((dd->mode & DETECT_TLS_VALIDITY_EX) && (time_t)SCTIME_SECS(f->lastts) > cert_epoch)
188  ret = 1;
189  else if ((dd->mode & DETECT_TLS_VALIDITY_VA) && (time_t)SCTIME_SECS(f->lastts) <= cert_epoch)
190  ret = 1;
191 
192  SCReturnInt(ret);
193 }
194 
195 /**
196  * \internal
197  * \brief Function to check if string is epoch.
198  *
199  * \param string Date string.
200  *
201  * \retval epoch time on success.
202  * \retval LONG_MIN on failure.
203  */
204 static time_t StringIsEpoch (char *string)
205 {
206  if (strlen(string) == 0)
207  return LONG_MIN;
208 
209  /* We assume that the date string is epoch if it consists of only
210  digits. */
211  char *sp = string;
212  while (*sp) {
213  if (isdigit(*sp++) == 0)
214  return LONG_MIN;
215  }
216 
217  return strtol(string, NULL, 10);
218 }
219 
220 #define MAX_DATE_LEN 20
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",
238  "%Y-%m",
239  "%Y-%m-%d",
240  "%Y-%m-%d %H",
241  "%Y-%m-%d %H:%M",
242  "%Y-%m-%d %H:%M:%S",
243  "%Y-%m-%dT%H",
244  "%Y-%m-%dT%H:%M",
245  "%Y-%m-%dT%H:%M:%S",
246  "%H:%M",
247  "%H:%M:%S",
248  };
249 
250  /* Skip leading whitespace. */
251  while (isspace(*string))
252  string++;
253 
254  time_t epoch = StringIsEpoch(string);
255  // inlen == 4 will get interpreted as a year
256  if (epoch != LONG_MIN && strlen(string) != 4) {
257  return epoch;
258  }
259 
260  r = SCStringPatternToTime(string, patterns, 11, &tm);
261 
262  if (r != 0)
263  return LONG_MIN;
264 
265  return SCMkTimeUtc(&tm);
266 }
267 
268 /**
269  * \internal
270  * \brief Function to parse options passed via tls validity keywords.
271  *
272  * \param rawstr Pointer to the user provided options.
273  *
274  * \retval dd pointer to DetectTlsValidityData on success.
275  * \retval NULL on failure.
276  */
277 static DetectTlsValidityData *DetectTlsValidityParse (const char *rawstr)
278 {
279  DetectTlsValidityData *dd = NULL;
280  char mode[2] = "";
281  char value1[MAX_DATE_LEN] = "";
282  char value2[MAX_DATE_LEN] = "";
283  char range[3] = "";
284 
285  pcre2_match_data *match = NULL;
286  int ret = DetectParsePcreExec(&parse_regex, &match, rawstr, 0, 0);
287  if (ret < 3 || ret > 5) {
288  SCLogError("Parse error %s", rawstr);
289  goto error;
290  }
291 
292  size_t pcre2len = sizeof(mode);
293  int res = SC_Pcre2SubstringCopy(match, 1, (PCRE2_UCHAR8 *)mode, &pcre2len);
294  if (res < 0) {
295  SCLogError("pcre2_substring_copy_bynumber failed");
296  goto error;
297  }
298  SCLogDebug("mode \"%s\"", mode);
299 
300  pcre2len = sizeof(value1);
301  res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)value1, &pcre2len);
302  if (res < 0) {
303  SCLogError("pcre2_substring_copy_bynumber failed");
304  goto error;
305  }
306  SCLogDebug("value1 \"%s\"", value1);
307 
308  if (ret > 3) {
309  pcre2len = sizeof(range);
310  res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)range, &pcre2len);
311  if (res < 0) {
312  SCLogError("pcre2_substring_copy_bynumber failed");
313  goto error;
314  }
315  SCLogDebug("range \"%s\"", range);
316 
317  if (ret > 4) {
318  pcre2len = sizeof(value2);
319  res = pcre2_substring_copy_bynumber(match, 4, (PCRE2_UCHAR8 *)value2, &pcre2len);
320  if (res < 0) {
321  SCLogError("pcre2_substring_copy_bynumber failed");
322  goto error;
323  }
324  SCLogDebug("value2 \"%s\"", value2);
325  }
326  }
327 
328  dd = SCMalloc(sizeof(DetectTlsValidityData));
329  if (unlikely(dd == NULL))
330  goto error;
331 
332  dd->epoch = 0;
333  dd->epoch2 = 0;
334  dd->mode = 0;
335 
336  if (strlen(mode) > 0) {
337  if (mode[0] == '<')
339  else if (mode[0] == '>')
341  }
342 
343  if (strlen(range) > 0) {
344  if (strcmp("<>", range) == 0)
346  }
347 
348  if (strlen(range) != 0 && strlen(mode) != 0) {
349  SCLogError("Range specified but mode also set");
350  goto error;
351  }
352 
353  if (dd->mode == 0) {
355  }
356 
357  /* set the first value */
358  dd->epoch = DateStringToEpoch(value1);
359  if (dd->epoch == LONG_MIN)
360  goto error;
361 
362  /* set the second value if specified */
363  if (strlen(value2) > 0) {
364  if (!(dd->mode & DETECT_TLS_VALIDITY_RA)) {
365  SCLogError("Multiple tls validity values specified but mode is not range");
366  goto error;
367  }
368 
369  dd->epoch2 = DateStringToEpoch(value2);
370  if (dd->epoch2 == LONG_MIN)
371  goto error;
372 
373  if (dd->epoch2 <= dd->epoch) {
374  SCLogError("Second value in range must not be smaller than the first");
375  goto error;
376  }
377  }
378  pcre2_match_data_free(match);
379  return dd;
380 
381 error:
382  if (match) {
383  pcre2_match_data_free(match);
384  }
385  if (dd)
386  SCFree(dd);
387  return NULL;
388 }
389 
390 /**
391  * \brief Function to add the parsed tls_cert_expired into the current signature.
392  *
393  * \param de_ctx Pointer to the Detection Engine Context.
394  * \param s Pointer to the Current Signature.
395  * \param rawstr Pointer to the user provided flags options.
396  *
397  * \retval 0 on Success.
398  * \retval -1 on Failure.
399  */
400 static int DetectTlsExpiredSetup (DetectEngineCtx *de_ctx, Signature *s,
401  const char *rawstr)
402 {
403  DetectTlsValidityData *dd = NULL;
404 
405  SCLogDebug("\'%s\'", rawstr);
406 
408  return -1;
409 
410  dd = SCCalloc(1, sizeof(DetectTlsValidityData));
411  if (dd == NULL) {
412  SCLogError("Allocation \'%s\' failed", rawstr);
413  goto error;
414  }
415 
416  /* okay so far so good, lets get this into a SigMatch
417  * and put it in the Signature. */
418 
421  dd->epoch = 0;
422  dd->epoch2 = 0;
423 
425  g_tls_validity_buffer_id) == NULL) {
426  goto error;
427  }
428  return 0;
429 
430 error:
431  DetectTlsValidityFree(de_ctx, dd);
432  return -1;
433 }
434 
435 /**
436  * \brief Function to add the parsed tls_cert_valid into the current signature.
437  *
438  * \param de_ctx Pointer to the Detection Engine Context.
439  * \param s Pointer to the Current Signature.
440  * \param rawstr Pointer to the user provided flags options.
441  *
442  * \retval 0 on Success.
443  * \retval -1 on Failure.
444  */
445 static int DetectTlsValidSetup (DetectEngineCtx *de_ctx, Signature *s,
446  const char *rawstr)
447 {
448  DetectTlsValidityData *dd = NULL;
449 
450  SCLogDebug("\'%s\'", rawstr);
451 
453  return -1;
454 
455  dd = SCCalloc(1, sizeof(DetectTlsValidityData));
456  if (dd == NULL) {
457  SCLogError("Allocation \'%s\' failed", rawstr);
458  goto error;
459  }
460 
461  /* okay so far so good, lets get this into a SigMatch
462  * and put it in the Signature. */
463 
466  dd->epoch = 0;
467  dd->epoch2 = 0;
468 
470  de_ctx, s, DETECT_TLS_VALID, (SigMatchCtx *)dd, g_tls_validity_buffer_id) == NULL) {
471  goto error;
472  }
473  return 0;
474 
475 error:
476  DetectTlsValidityFree(de_ctx, dd);
477  return -1;
478 }
479 
480 /**
481  * \brief Function to add the parsed tls_notbefore into the current signature.
482  *
483  * \param de_ctx Pointer to the Detection Engine Context.
484  * \param s Pointer to the Current Signature.
485  * \param rawstr Pointer to the user provided flags options.
486  *
487  * \retval 0 on Success.
488  * \retval -1 on Failure.
489  */
490 static int DetectTlsNotBeforeSetup (DetectEngineCtx *de_ctx, Signature *s,
491  const char *rawstr)
492 {
494  int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type);
495 
496  SCReturnInt(r);
497 }
498 
499 /**
500  * \brief Function to add the parsed tls_notafter into the current signature.
501  *
502  * \param de_ctx Pointer to the Detection Engine Context.
503  * \param s Pointer to the Current Signature.
504  * \param rawstr Pointer to the user provided flags options.
505  *
506  * \retval 0 on Success.
507  * \retval -1 on Failure.
508  */
509 static int DetectTlsNotAfterSetup (DetectEngineCtx *de_ctx, Signature *s,
510  const char *rawstr)
511 {
512  uint8_t type = DETECT_TLS_TYPE_NOTAFTER;
513  int r = DetectTlsValiditySetup(de_ctx, s, rawstr, type);
514 
515  SCReturnInt(r);
516 }
517 
518 /**
519  * \brief Function to add the parsed tls validity field into the current signature.
520  *
521  * \param de_ctx Pointer to the Detection Engine Context.
522  * \param s Pointer to the Current Signature.
523  * \param rawstr Pointer to the user provided flags options.
524  * \param type Defines if this is notBefore or notAfter.
525  *
526  * \retval 0 on Success.
527  * \retval -1 on Failure.
528  */
529 static int DetectTlsValiditySetup (DetectEngineCtx *de_ctx, Signature *s,
530  const char *rawstr, uint8_t type)
531 {
532  DetectTlsValidityData *dd = NULL;
533 
534  SCLogDebug("\'%s\'", rawstr);
535 
537  return -1;
538 
539  dd = DetectTlsValidityParse(rawstr);
540  if (dd == NULL) {
541  SCLogError("Parsing \'%s\' failed", rawstr);
542  goto error;
543  }
544 
545  /* okay so far so good, lets get this into a SigMatch
546  * and put it in the Signature. */
547 
550  }
551  else if (type == DETECT_TLS_TYPE_NOTAFTER) {
553  }
554  else {
555  goto error;
556  }
557 
559  g_tls_validity_buffer_id) == NULL) {
560  goto error;
561  }
562  return 0;
563 
564 error:
565  DetectTlsValidityFree(de_ctx, dd);
566  return -1;
567 }
568 
569 /**
570  * \internal
571  * \brief Function to free memory associated with DetectTlsValidityData.
572  *
573  * \param de_ptr Pointer to DetectTlsValidityData.
574  */
575 void DetectTlsValidityFree(DetectEngineCtx *de_ctx, void *de_ptr)
576 {
578  if (dd)
579  SCFree(dd);
580 }
581 
582 #ifdef UNITTESTS
584 #endif
SigTableElmt_::url
const char * url
Definition: detect.h:1461
SSLState_
SSLv[2.0|3.[0|1|2|3]] state structure.
Definition: app-layer-ssl.h:236
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:1460
sigmatch_table
SigTableElmt * sigmatch_table
Definition: detect-parse.c:79
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:1445
flow-util.h
DetectParseRegex
Definition: detect-parse.h:92
SigTableElmt_::name
const char * name
Definition: detect.h:1458
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:257
SigTableElmt_::flags
uint32_t flags
Definition: detect.h:1449
ALPROTO_TLS
@ ALPROTO_TLS
Definition: app-layer-protos.h:39
DETECT_TLS_VALIDITY_EQ
#define DETECT_TLS_VALIDITY_EQ
Definition: detect-tls-cert-validity.h:27
SCLogDebug
#define SCLogDebug(...)
Definition: util-debug.h:282
TlsNotBeforeRegisterTests
void TlsNotBeforeRegisterTests(void)
Register unit tests for tls_cert_notbefore.
Definition: detect-tls-cert-validity.c:1388
PARSE_REGEX
#define PARSE_REGEX
Definition: detect-tls-cert-validity.c:54
SSLState_::server_connp
SSLStateConnp server_connp
Definition: app-layer-ssl.h:258
SSLStateConnp_::cert0_not_before
int64_t cert0_not_before
Definition: app-layer-ssl.h:198
SSLStateConnp_
Definition: app-layer-ssl.h:172
TlsNotAfterRegisterTests
void TlsNotAfterRegisterTests(void)
Register unit tests for tls_cert_notafter.
Definition: detect-tls-cert-validity.c:1412
threads.h
Flow_
Flow data structure.
Definition: flow.h:347
ctx
struct Thresholds ctx
DetectEngineCtx_
main detection engine ctx
Definition: detect.h:933
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:1423
DetectTlsValidityRegister
void DetectTlsValidityRegister(void)
Registration function for tls validity keywords.
Definition: detect-tls-cert-validity.c:81
DetectParsePcreExec
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
Definition: detect-parse.c:3500
DETECT_TLS_EXPIRED
@ DETECT_TLS_EXPIRED
Definition: detect-engine-register.h:144
SCDetectSignatureSetAppProto
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
Definition: detect-parse.c:2235
SigTableElmt_::Setup
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition: detect.h:1440
detect-pcre.h
util-unittest.h
util-unittest-helper.h
DetectBufferTypeGetByName
int DetectBufferTypeGetByName(const char *name)
Definition: detect-engine.c:1278
DETECT_TLS_VALID
@ DETECT_TLS_VALID
Definition: detect-engine-register.h:145
SSLStateConnp_::cert0_not_after
int64_t cert0_not_after
Definition: app-layer-ssl.h:199
DETECT_TLS_NOTAFTER
@ DETECT_TLS_NOTAFTER
Definition: detect-engine-register.h:143
decode.h
de_ctx
DetectEngineCtx * de_ctx
Definition: fuzz_siginit.c:19
DetectEngineThreadCtx_
Definition: detect.h:1245
Flow_::lastts
SCTime_t lastts
Definition: flow.h:401
DetectSetupParseRegexes
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
Definition: detect-parse.c:3626
SCEnter
#define SCEnter(...)
Definition: util-debug.h:284
detect-engine-mpm.h
DETECT_TLS_NOTBEFORE
@ DETECT_TLS_NOTBEFORE
Definition: detect-engine-register.h:142
SCSigMatchAppendSMToList
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Definition: detect-parse.c:387
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:106
detect-tls-cert-validity.c
SigMatchCtx_
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition: detect.h:350
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
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:308
SCLogError
#define SCLogError(...)
Macro used to log ERROR messages.
Definition: util-debug.h:274
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:1438
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:668
SC_Pcre2SubstringCopy
int SC_Pcre2SubstringCopy(pcre2_match_data *match_data, uint32_t number, PCRE2_UCHAR *buffer, PCRE2_SIZE *bufflen)
Definition: detect-parse.c:3602
SIGMATCH_NOOPT
#define SIGMATCH_NOOPT
Definition: detect.h:1650
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
MAX_DATE_LEN
#define MAX_DATE_LEN
Definition: detect-tls-cert-validity.c:220
flow.h
SCCalloc
#define SCCalloc(nm, sz)
Definition: util-mem.h:53
SCReturnInt
#define SCReturnInt(x)
Definition: util-debug.h:288
flow-var.h
app-layer-ssl.h
TlsExpiredRegisterTests
void TlsExpiredRegisterTests(void)
Register unit tests for tls_cert_expired.
Definition: detect-tls-cert-validity.c:1430
SigTableElmt_::RegisterTests
void(* RegisterTests)(void)
Definition: detect.h:1447
app-layer.h