• 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

59.85
/src/detect-engine-buffer.c
1
/* Copyright (C) 2025 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 Victor Julien <victor@inliniac.net>
22
 */
23

24
#include "suricata-common.h"
25
#include "detect-engine.h"
26
#include "detect-parse.h"
27
#include "detect-engine-buffer.h"
28

29
int SCDetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
30
{
49,322✔
31
    BUG_ON(s->init_data == NULL);
49,322✔
32

33
    if (s->init_data->list == DETECT_SM_LIST_BASE64_DATA) {
49,322✔
34
        SCLogError("Rule buffer cannot be reset after base64_data.");
×
35
        return -1;
×
36
    }
×
37

38
    if (s->init_data->list && s->init_data->transforms.cnt) {
49,322✔
39
        SCLogError("no matches following transform(s)");
×
40
        return -1;
×
41
    }
×
42
    s->init_data->list = list;
49,322✔
43
    s->init_data->list_set = true;
49,322✔
44

45
    // check if last has matches -> if no, error
46
    if (s->init_data->curbuf && s->init_data->curbuf->head == NULL) {
49,322✔
47
        SCLogError("previous sticky buffer has no matches");
×
48
        return -1;
×
49
    }
×
50

51
    for (uint32_t x = 0; x < s->init_data->buffers_size; x++) {
440,405✔
52
        SignatureInitDataBuffer *b = &s->init_data->buffers[x];
391,523✔
53
        for (SigMatch *sm = b->head; sm != NULL; sm = sm->next) {
433,457✔
54
            SCLogDebug(
41,934✔
55
                    "buf:%p: id:%u: '%s' pos %u", b, b->id, sigmatch_table[sm->type].name, sm->idx);
41,934✔
56
        }
41,934✔
57
        if ((uint32_t)list == b->id) {
391,523✔
58
            SCLogDebug("found buffer %p for list %d", b, list);
441✔
59
            if (s->init_data->buffers[x].sm_init) {
441✔
60
                s->init_data->buffers[x].sm_init = false;
438✔
61
                SCLogDebug("sm_init was true for %p list %d", b, list);
438✔
62
                s->init_data->curbuf = b;
438✔
63
                return 0;
438✔
64

65
            } else if (DetectEngineBufferTypeSupportsMultiInstanceGetById(de_ctx, list)) {
438✔
66
                // fall through
67
            } else if (!b->only_ts && (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOSERVER)) {
2✔
68
                // fall through
69
            } else if (!b->only_tc && (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOCLIENT)) {
2✔
70
                // fall through
71
            } else {
2✔
72
                // we create a new buffer for the same id but forced different direction
73
                SCLogWarning("duplicate instance for %s in '%s'",
2✔
74
                        DetectEngineBufferTypeGetNameById(de_ctx, list), s->sig_str);
2✔
75
                s->init_data->curbuf = b;
2✔
76
                return 0;
2✔
77
            }
2✔
78
        }
441✔
79
    }
391,523✔
80

81
    if (list < DETECT_SM_LIST_MAX)
48,882✔
82
        return 0;
×
83

84
    if (SignatureInitDataBufferCheckExpand(s) < 0) {
48,882✔
85
        SCLogError("failed to expand rule buffer array");
×
86
        return -1;
×
87
    }
×
88

89
    /* initialize new buffer */
90
    s->init_data->curbuf = &s->init_data->buffers[s->init_data->buffer_index++];
48,882✔
91
    s->init_data->curbuf->id = list;
48,882✔
92
    s->init_data->curbuf->head = NULL;
48,882✔
93
    s->init_data->curbuf->tail = NULL;
48,882✔
94
    s->init_data->curbuf->multi_capable =
48,882✔
95
            DetectEngineBufferTypeSupportsMultiInstanceGetById(de_ctx, list);
48,882✔
96
    if (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOCLIENT) {
48,882✔
97
        s->init_data->curbuf->only_tc = true;
×
98
    }
×
99
    if (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOSERVER) {
48,882✔
100
        s->init_data->curbuf->only_ts = true;
×
101
    }
×
102

103
    SCLogDebug("new: idx %u list %d set up curbuf %p", s->init_data->buffer_index - 1, list,
48,882✔
104
            s->init_data->curbuf);
48,882✔
105

106
    return 0;
48,882✔
107
}
48,882✔
108

109
int DetectBufferGetActiveList(DetectEngineCtx *de_ctx, Signature *s)
110
{
102,934✔
111
    BUG_ON(s->init_data == NULL);
102,934✔
112

113
    if (s->init_data->list && s->init_data->transforms.cnt) {
102,934✔
114
        if (s->init_data->list == DETECT_SM_LIST_NOTSET ||
2,191✔
115
                s->init_data->list < DETECT_SM_LIST_DYNAMIC_START) {
2,191✔
116
            SCLogError("previous transforms not consumed "
×
117
                       "(list: %u, transform_cnt %u)",
×
118
                    s->init_data->list, s->init_data->transforms.cnt);
×
119
            SCReturnInt(-1);
×
120
        }
×
121

122
        SCLogDebug("buffer %d has transform(s) registered: %d", s->init_data->list,
2,191✔
123
                s->init_data->transforms.cnt);
2,191✔
124
        int new_list = DetectEngineBufferTypeGetByIdTransforms(de_ctx, s->init_data->list,
2,191✔
125
                s->init_data->transforms.transforms, s->init_data->transforms.cnt);
2,191✔
126
        if (new_list == -1) {
2,191✔
127
            SCReturnInt(-1);
×
128
        }
×
129
        int base_list = s->init_data->list;
2,191✔
130
        SCLogDebug("new_list %d", new_list);
2,191✔
131
        s->init_data->list = new_list;
2,191✔
132
        s->init_data->list_set = false;
2,191✔
133
        // reset transforms now that we've set up the list
134
        s->init_data->transforms.cnt = 0;
2,191✔
135

136
        if (s->init_data->curbuf && s->init_data->curbuf->head != NULL) {
2,191✔
137
            if (SignatureInitDataBufferCheckExpand(s) < 0) {
2✔
138
                SCLogError("failed to expand rule buffer array");
×
139
                return -1;
×
140
            }
×
141
            s->init_data->curbuf = &s->init_data->buffers[s->init_data->buffer_index++];
2✔
142
            s->init_data->curbuf->multi_capable =
2✔
143
                    DetectEngineBufferTypeSupportsMultiInstanceGetById(de_ctx, base_list);
2✔
144
        }
2✔
145
        if (s->init_data->curbuf == NULL) {
2,191✔
146
            SCLogError("failed to setup buffer");
×
147
            DEBUG_VALIDATE_BUG_ON(1);
×
148
            SCReturnInt(-1);
×
149
        }
×
150
        s->init_data->curbuf->id = new_list;
2,191✔
151
        SCLogDebug("new list after applying transforms: %u", new_list);
2,191✔
152
    }
2,191✔
153

154
    SCReturnInt(0);
102,934✔
155
}
102,934✔
156

157
SigMatch *DetectBufferGetFirstSigMatch(const Signature *s, const uint32_t buf_id)
158
{
×
159
    for (uint32_t i = 0; i < s->init_data->buffer_index; i++) {
×
160
        if (buf_id == s->init_data->buffers[i].id) {
×
161
            return s->init_data->buffers[i].head;
×
162
        }
×
163
    }
×
164
    return NULL;
×
165
}
×
166

167
SigMatch *DetectBufferGetLastSigMatch(const Signature *s, const uint32_t buf_id)
168
{
×
169
    SigMatch *last = NULL;
×
170
    for (uint32_t i = 0; i < s->init_data->buffer_index; i++) {
×
171
        if (buf_id == s->init_data->buffers[i].id) {
×
172
            last = s->init_data->buffers[i].tail;
×
173
        }
×
174
    }
×
175
    return last;
×
176
}
×
177

178
int SCDetectSignatureAddTransform(Signature *s, int transform, void *options)
179
{
2,191✔
180
    /* we only support buffers */
181
    if (s->init_data->list == 0) {
2,191✔
182
        SCReturnInt(-1);
×
183
    }
×
184
    if (!s->init_data->list_set) {
2,191✔
185
        SCLogError("transforms must directly follow stickybuffers");
×
186
        SCReturnInt(-1);
×
187
    }
×
188
    if (s->init_data->transforms.cnt >= DETECT_TRANSFORMS_MAX) {
2,191✔
189
        SCReturnInt(-1);
×
190
    }
×
191

192
    s->init_data->transforms.transforms[s->init_data->transforms.cnt].transform = transform;
2,191✔
193
    s->init_data->transforms.transforms[s->init_data->transforms.cnt].options = options;
2,191✔
194

195
    s->init_data->transforms.cnt++;
2,191✔
196
    SCLogDebug("Added transform #%d [%s]", s->init_data->transforms.cnt, s->sig_str);
2,191✔
197

198
    SCReturnInt(0);
2,191✔
199
}
2,191✔
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