Go to the documentation of this file.
55 "^\\s*(<|>)?\\s*([ -:TW0-9]+[-:TW0-9]+)\\s*(?:(<>)\\s*([ -:TW0-9]+[-:TW0-9]+))?\\s*$"
59 uint8_t,
void *,
void *,
const Signature *,
62 static time_t DateStringToEpoch (
char *);
76 static int g_tls_validity_buffer_id = 0;
154 if (ssl_state == NULL) {
162 if (
flags & STREAM_TOSERVER)
169 time_t cert_epoch = 0;
185 cert_epoch >= dd->
epoch && cert_epoch <= dd->epoch2)
204 static time_t StringIsEpoch (
char *
string)
206 if (strlen(
string) == 0)
213 if (isdigit(*sp++) == 0)
217 return strtol(
string, NULL, 10);
220 #define MAX_DATE_LEN 20
231 static time_t DateStringToEpoch (
char *
string)
235 const char *patterns[] = {
250 while (isspace(*
string))
253 time_t epoch = StringIsEpoch(
string);
254 if (epoch != LONG_MIN) {
283 pcre2_match_data *match = NULL;
285 if (ret < 3 || ret > 5) {
290 size_t pcre2len =
sizeof(mode);
293 SCLogError(
"pcre2_substring_copy_bynumber failed");
298 pcre2len =
sizeof(value1);
299 res = pcre2_substring_copy_bynumber(match, 2, (PCRE2_UCHAR8 *)value1, &pcre2len);
301 SCLogError(
"pcre2_substring_copy_bynumber failed");
307 pcre2len =
sizeof(range);
308 res = pcre2_substring_copy_bynumber(match, 3, (PCRE2_UCHAR8 *)range, &pcre2len);
310 SCLogError(
"pcre2_substring_copy_bynumber failed");
316 pcre2len =
sizeof(value2);
317 res = pcre2_substring_copy_bynumber(match, 4, (PCRE2_UCHAR8 *)value2, &pcre2len);
319 SCLogError(
"pcre2_substring_copy_bynumber failed");
334 if (strlen(mode) > 0) {
337 else if (mode[0] ==
'>')
341 if (strlen(range) > 0) {
342 if (strcmp(
"<>", range) == 0)
346 if (strlen(range) != 0 && strlen(mode) != 0) {
347 SCLogError(
"Range specified but mode also set");
356 dd->
epoch = DateStringToEpoch(value1);
357 if (dd->
epoch == LONG_MIN)
361 if (strlen(value2) > 0) {
363 SCLogError(
"Multiple tls validity values specified but mode is not range");
367 dd->
epoch2 = DateStringToEpoch(value2);
368 if (dd->
epoch2 == LONG_MIN)
372 SCLogError(
"Second value in range must not be smaller than the first");
376 pcre2_match_data_free(match);
381 pcre2_match_data_free(match);
410 SCLogError(
"Allocation \'%s\' failed", rawstr);
423 g_tls_validity_buffer_id) == NULL) {
429 DetectTlsValidityFree(
de_ctx, dd);
455 SCLogError(
"Allocation \'%s\' failed", rawstr);
474 DetectTlsValidityFree(
de_ctx, dd);
492 int r = DetectTlsValiditySetup(
de_ctx, s, rawstr,
type);
511 int r = DetectTlsValiditySetup(
de_ctx, s, rawstr,
type);
528 const char *rawstr, uint8_t
type)
537 dd = DetectTlsValidityParse(rawstr);
557 g_tls_validity_buffer_id) == NULL) {
563 DetectTlsValidityFree(
de_ctx, dd);
SSLv[2.0|3.[0|1|2|3]] state structure.
SigTableElmt * sigmatch_table
#define DETECT_TLS_TYPE_NOTAFTER
void(* Free)(DetectEngineCtx *, void *)
SSLStateConnp client_connp
#define DETECT_TLS_VALIDITY_EQ
void TlsNotBeforeRegisterTests(void)
Register unit tests for tls_cert_notbefore.
SSLStateConnp server_connp
void TlsNotAfterRegisterTests(void)
Register unit tests for tls_cert_notafter.
main detection engine ctx
time_t SCMkTimeUtc(struct tm *tp)
Convert broken-down time to seconds since Unix epoch.
#define DETECT_TLS_VALIDITY_RA
int(* AppLayerTxMatch)(DetectEngineThreadCtx *, Flow *, uint8_t flags, void *alstate, void *txv, const Signature *, const SigMatchCtx *)
void DetectTlsValidityRegister(void)
Registration function for tls validity keywords.
int DetectParsePcreExec(DetectParseRegex *parse_regex, pcre2_match_data **match, const char *str, int start_offset, int options)
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
int DetectBufferTypeGetByName(const char *name)
void DetectSetupParseRegexes(const char *parse_str, DetectParseRegex *detect_parse)
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
#define DETECT_TLS_VALIDITY_LT
#define DETECT_TLS_VALIDITY_EX
#define DETECT_TLS_VALIDITY_GT
#define DETECT_TLS_VALIDITY_VA
#define SCLogError(...)
Macro used to log ERROR messages.
void TlsValidRegisterTests(void)
Register unit tests for tls_cert_valid.
#define DETECT_TLS_TYPE_NOTBEFORE
int SC_Pcre2SubstringCopy(pcre2_match_data *match_data, uint32_t number, PCRE2_UCHAR *buffer, PCRE2_SIZE *bufflen)
int SCStringPatternToTime(char *string, const char **patterns, int num_patterns, struct tm *tp)
Parse a date string based on specified patterns.
void TlsExpiredRegisterTests(void)
Register unit tests for tls_cert_expired.
void(* RegisterTests)(void)