• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22618661228

02 Mar 2026 09:33PM UTC coverage: 42.258% (-34.4%) from 76.611%
22618661228

push

github

victorjulien
github-actions: bump actions/download-artifact from 7.0.0 to 8.0.0

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7.0.0 to 8.0.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/37930b1c2...70fc10c6e)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

91511 of 216553 relevant lines covered (42.26%)

3416852.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.78
/src/detect-sip-method.c
1
/* Copyright (C) 2019 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
 *
20
 * \author Giuseppe Longo <giuseppe@glongo.it>
21
 *
22
 * Implements the sip.method sticky buffer
23
 *
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-buffer.h"
34
#include "detect-engine-mpm.h"
35
#include "detect-engine-prefilter.h"
36
#include "detect-content.h"
37
#include "detect-pcre.h"
38

39
#include "flow.h"
40
#include "flow-var.h"
41
#include "flow-util.h"
42

43
#include "util-debug.h"
44
#include "util-unittest.h"
45
#include "util-unittest-helper.h"
46
#include "util-spm.h"
47

48
#include "app-layer.h"
49
#include "app-layer-parser.h"
50

51
#include "detect-sip-method.h"
52
#include "stream-tcp.h"
53

54
#include "rust.h"
55

56
#define KEYWORD_NAME "sip.method"
7✔
57
#define KEYWORD_DOC  "sip-keywords.html#sip-method"
7✔
58
#define BUFFER_NAME  "sip.method"
35✔
59
#define BUFFER_DESC  "sip request method"
7✔
60
static int g_buffer_id = 0;
61

62
static int DetectSipMethodSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
63
{
×
64
    if (SCDetectBufferSetActiveList(de_ctx, s, g_buffer_id) < 0)
×
65
        return -1;
×
66

67
    if (SCDetectSignatureSetAppProto(s, ALPROTO_SIP) < 0)
×
68
        return -1;
×
69

70
    return 0;
×
71
}
×
72

73
static bool DetectSipMethodValidateCallback(
74
        const Signature *s, const char **sigerror, const DetectBufferType *dbt)
75
{
×
76
    for (uint32_t x = 0; x < s->init_data->buffer_index; x++) {
×
77
        if (s->init_data->buffers[x].id != (uint32_t)dbt->id)
×
78
            continue;
×
79
        const SigMatch *sm = s->init_data->buffers[x].head;
×
80
        for (; sm != NULL; sm = sm->next) {
×
81
            if (sm->type != DETECT_CONTENT)
×
82
                continue;
×
83
            const DetectContentData *cd = (const DetectContentData *)sm->ctx;
×
84
            if (cd->content && cd->content_len) {
×
85
                if (cd->content[cd->content_len - 1] == 0x20) {
×
86
                    *sigerror = "sip.method pattern with trailing space";
×
87
                    SCLogError("%s", *sigerror);
×
88
                    return true;
×
89
                } else if (cd->content[0] == 0x20) {
×
90
                    *sigerror = "sip.method pattern with leading space";
×
91
                    SCLogError("%s", *sigerror);
×
92
                    return true;
×
93
                } else if (cd->content[cd->content_len - 1] == 0x09) {
×
94
                    *sigerror = "sip.method pattern with trailing tab";
×
95
                    SCLogError("%s", *sigerror);
×
96
                    return true;
×
97
                } else if (cd->content[0] == 0x09) {
×
98
                    *sigerror = "sip.method pattern with leading tab";
×
99
                    SCLogError("%s", *sigerror);
×
100
                    return true;
×
101
                }
×
102
            }
×
103
        }
×
104
    }
×
105
    return true;
×
106
}
×
107

108
static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx,
109
        const DetectEngineTransforms *transforms, Flow *_f,
110
        const uint8_t _flow_flags, void *txv, const int list_id)
111
{
×
112
    InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
×
113
    if (buffer->inspect == NULL) {
×
114
        const uint8_t *b = NULL;
×
115
        uint32_t b_len = 0;
×
116

117
        if (SCSipTxGetMethod(txv, &b, &b_len) != 1)
×
118
            return NULL;
×
119
        if (b == NULL || b_len == 0)
×
120
            return NULL;
×
121

122
        InspectionBufferSetupAndApplyTransforms(det_ctx, list_id, buffer, b, b_len, transforms);
×
123
    }
×
124

125
    return buffer;
×
126
}
×
127

128
void DetectSipMethodRegister(void)
129
{
7✔
130
    /* sip.method sticky buffer */
131
    sigmatch_table[DETECT_SIP_METHOD].name = KEYWORD_NAME;
7✔
132
    sigmatch_table[DETECT_SIP_METHOD].desc = "sticky buffer to match on the SIP method buffer";
7✔
133
    sigmatch_table[DETECT_SIP_METHOD].url = "/rules/" KEYWORD_DOC;
7✔
134
    sigmatch_table[DETECT_SIP_METHOD].Setup = DetectSipMethodSetup;
7✔
135
    sigmatch_table[DETECT_SIP_METHOD].flags |= SIGMATCH_NOOPT;
7✔
136

137
    DetectAppLayerInspectEngineRegister(BUFFER_NAME, ALPROTO_SIP, SIG_FLAG_TOSERVER, 0,
7✔
138
            DetectEngineInspectBufferGeneric, GetData);
7✔
139

140
    DetectAppLayerMpmRegister(BUFFER_NAME, SIG_FLAG_TOSERVER, 2, PrefilterGenericMpmRegister,
7✔
141
            GetData, ALPROTO_SIP, 1);
7✔
142

143
    DetectBufferTypeSetDescriptionByName(BUFFER_NAME, BUFFER_DESC);
7✔
144

145
    DetectBufferTypeRegisterValidateCallback(BUFFER_NAME,
7✔
146
            DetectSipMethodValidateCallback);
7✔
147

148
    g_buffer_id = DetectBufferTypeGetByName(BUFFER_NAME);
7✔
149

150
    SCLogDebug("registering " BUFFER_NAME " rule option");
7✔
151
}
7✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc