Esempio n. 1
0
/**
 * \brief this function is used to add the parsed "id" option
 * \brief into the current signature
 *
 * \param de_ctx pointer to the Detection Engine Context
 * \param s pointer to the Current Signature
 * \param idstr pointer to the user provided "id" option
 *
 * \retval 0 on Success
 * \retval -1 on Failure
 */
static int DetectTlsVersionSetup (DetectEngineCtx *de_ctx, Signature *s, char *str)
{
    DetectTlsVersionData *tls = NULL;
    SigMatch *sm = NULL;

    tls = DetectTlsVersionParse(str);
    if (tls == NULL) goto error;

    /* Okay so far so good, lets get this into a SigMatch
     * and put it in the Signature. */
    sm = SigMatchAlloc();
    if (sm == NULL)
        goto error;

    sm->type = DETECT_AL_TLS_VERSION;
    sm->ctx = (void *)tls;

    SigMatchAppendSMToList(s, sm, DETECT_SM_LIST_AMATCH);

    if (s->alproto != ALPROTO_UNKNOWN && s->alproto != ALPROTO_TLS) {
        SCLogError(SC_ERR_CONFLICTING_RULE_KEYWORDS, "rule contains conflicting keywords.");
        goto error;
    }

    s->alproto = ALPROTO_TLS;
    return 0;

error:
    if (tls != NULL) DetectTlsVersionFree(tls);
    if (sm != NULL) SCFree(sm);
    return -1;

}
Esempio n. 2
0
/**
 * \test DetectTlsVersionTestParse02 is a test to make sure that we parse the "id"
 *       option correctly when given an invalid id option
 *       it should return id_d = NULL
 */
int DetectTlsVersionTestParse02 (void) {
    DetectTlsVersionData *tls = NULL;
    tls = DetectTlsVersionParse("2.5");
    if (tls == NULL) {
        DetectTlsVersionFree(tls);
        return 1;
    }

    return 0;
}
Esempio n. 3
0
/**
 * \test DetectTlsVersionTestParse01 is a test to make sure that we parse the "id"
 *       option correctly when given valid id option
 */
int DetectTlsVersionTestParse01 (void) {
    DetectTlsVersionData *tls = NULL;
    tls = DetectTlsVersionParse("1.0");
    if (tls != NULL && tls->ver == TLS_VERSION_10) {
        DetectTlsVersionFree(tls);
        return 1;
    }

    return 0;
}