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

OISF / suricata / 22550902417

01 Mar 2026 07:32PM UTC coverage: 68.401% (-5.3%) from 73.687%
22550902417

Pull #14922

github

web-flow
github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

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

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #14922: github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

218243 of 319063 relevant lines covered (68.4%)

3284926.58 hits per line

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

72.26
/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,667✔
31
    BUG_ON(s->init_data == NULL);
49,667✔
32

33
    if (s->init_data->list == DETECT_SM_LIST_BASE64_DATA) {
49,667✔
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,667✔
39
        SCLogError("no matches following transform(s)");
×
40
        return -1;
×
41
    }
×
42
    s->init_data->list = list;
49,667✔
43
    s->init_data->list_set = true;
49,667✔
44

45
    // check if last has matches -> if no, error
46
    if (s->init_data->curbuf && s->init_data->curbuf->head == NULL) {
49,667✔
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++) {
443,510✔
52
        SignatureInitDataBuffer *b = &s->init_data->buffers[x];
394,283✔
53
        for (SigMatch *sm = b->head; sm != NULL; sm = sm->next) {
436,241✔
54
            SCLogDebug(
41,958✔
55
                    "buf:%p: id:%u: '%s' pos %u", b, b->id, sigmatch_table[sm->type].name, sm->idx);
41,958✔
56
        }
41,958✔
57
        if ((uint32_t)list == b->id) {
394,283✔
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
    }
394,283✔
80

81
    if (list < DETECT_SM_LIST_MAX)
49,227✔
82
        return 0;
×
83

84
    if (SignatureInitDataBufferCheckExpand(s) < 0) {
49,227✔
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++];
49,227✔
91
    s->init_data->curbuf->id = list;
49,227✔
92
    s->init_data->curbuf->head = NULL;
49,227✔
93
    s->init_data->curbuf->tail = NULL;
49,227✔
94
    s->init_data->curbuf->multi_capable =
49,227✔
95
            DetectEngineBufferTypeSupportsMultiInstanceGetById(de_ctx, list);
49,227✔
96
    if (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOCLIENT) {
49,227✔
97
        s->init_data->curbuf->only_tc = true;
×
98
    }
×
99
    if (s->init_data->init_flags & SIG_FLAG_INIT_FORCE_TOSERVER) {
49,227✔
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,
49,227✔
104
            s->init_data->curbuf);
49,227✔
105

106
    return 0;
49,227✔
107
}
49,227✔
108

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

113
    if (s->init_data->list && s->init_data->transforms.cnt) {
105,621✔
114
        if (s->init_data->list == DETECT_SM_LIST_NOTSET ||
2,192✔
115
                s->init_data->list < DETECT_SM_LIST_DYNAMIC_START) {
2,192✔
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,192✔
123
                s->init_data->transforms.cnt);
2,192✔
124
        int new_list = DetectEngineBufferTypeGetByIdTransforms(de_ctx, s->init_data->list,
2,192✔
125
                s->init_data->transforms.transforms, s->init_data->transforms.cnt);
2,192✔
126
        if (new_list == -1) {
2,192✔
127
            SCReturnInt(-1);
×
128
        }
×
129
        int base_list = s->init_data->list;
2,192✔
130
        SCLogDebug("new_list %d", new_list);
2,192✔
131
        s->init_data->list = new_list;
2,192✔
132
        s->init_data->list_set = false;
2,192✔
133
        // reset transforms now that we've set up the list
134
        s->init_data->transforms.cnt = 0;
2,192✔
135

136
        if (s->init_data->curbuf && s->init_data->curbuf->head != NULL) {
2,192✔
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,192✔
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,192✔
151
        SCLogDebug("new list after applying transforms: %u", new_list);
2,192✔
152
    }
2,192✔
153

154
    SCReturnInt(0);
105,621✔
155
}
105,621✔
156

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

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

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

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

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

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