/**
* \brief Regex for parsing "id" option, matching number or "number"
*/
-#define PARSE_REGEX "^\\s*([A-z0-9\\.]+|\"[A-z0-9\\.]+\")\\s*$"
+#define PARSE_REGEX "^\\s*(\\!*)\\s*([A-z0-9\\.=\\*] +|\"[A-z0-9\\.\\*= ]+\")\\s*$"
static pcre *subject_parse_regex;
static pcre_extra *subject_parse_regex_study;
int ret = 0;
SCMutexLock(&f->m);
+ if (tls_data->flags & DETECT_CONTENT_NEGATED) {
+ ret = 1;
+ } else {
+ ret = 0;
+ }
if (ssl_state->cert0_subject != NULL) {
SCLogDebug("TLS: Subject is [%s], looking for [%s]\n", ssl_state->cert0_subject, tls_data->subject);
if (strstr(ssl_state->cert0_subject, tls_data->subject) != NULL) {
- ret = 1;
+ if (tls_data->flags & DETECT_CONTENT_NEGATED) {
+ ret = 0;
+ } else {
+ ret = 1;
+ }
}
}
goto error;
}
- if (ret > 1) {
+ if (ret == 3) {
const char *str_ptr;
char *orig;
char *tmp_str;
+ uint32_t flag = 0;
+
res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 1, &str_ptr);
if (res < 0) {
SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
goto error;
}
+ if (str_ptr[0] == '!')
+ flag = DETECT_CONTENT_NEGATED;
+
+ res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 2, &str_ptr);
+ if (res < 0) {
+ SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+ goto error;
+ }
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsData));
if (tls == NULL)
goto error;
tls->subject = NULL;
+ tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
tmp_str=orig;
int ret = 0;
SCMutexLock(&f->m);
+ if (tls_data->flags & DETECT_CONTENT_NEGATED) {
+ ret = 1;
+ } else {
+ ret = 0;
+ }
if (ssl_state->cert0_issuerdn != NULL) {
SCLogDebug("TLS: IssuerDN is [%s], looking for [%s]\n", ssl_state->cert0_issuerdn, tls_data->issuerdn);
if (strstr(ssl_state->cert0_issuerdn, tls_data->issuerdn) != NULL) {
- ret = 1;
+ if (tls_data->flags & DETECT_CONTENT_NEGATED) {
+ ret = 0;
+ } else {
+ ret = 1;
+ }
}
}
ret = pcre_exec(issuerdn_parse_regex, issuerdn_parse_regex_study, str, strlen(str), 0, 0,
ov, MAX_SUBSTRINGS);
- if (ret < 1 || ret > 3) {
+ if (ret != 3) {
SCLogError(SC_ERR_PCRE_MATCH, "invalid tls.issuerdn option");
goto error;
}
- if (ret > 1) {
+ if (ret == 3) {
const char *str_ptr;
char *orig;
char *tmp_str;
+ uint32_t flag = 0;
+
res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 1, &str_ptr);
if (res < 0) {
SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
goto error;
}
+ if (str_ptr[0] == '!')
+ flag = DETECT_CONTENT_NEGATED;
+
+ res = pcre_get_substring((char *)str, ov, MAX_SUBSTRINGS, 2, &str_ptr);
+ if (res < 0) {
+ SCLogError(SC_ERR_PCRE_GET_SUBSTRING, "pcre_get_substring failed");
+ goto error;
+ }
/* We have a correct id option */
tls = SCMalloc(sizeof(DetectTlsData));
if (tls == NULL)
goto error;
tls->issuerdn = NULL;
+ tls->flags = flag;
orig = SCStrdup((char*)str_ptr);
tmp_str=orig;