• 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

62.82
/src/feature.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
 * \file
20
 *
21
 * \author Jeff Lucovsky <jeff@lucovsky.org>
22
 *
23
 * Implements feature tracking
24
 */
25

26
#include "suricata-common.h"
27
#include "feature.h"
28
#include "threads.h"
29

30
#include "util-debug.h"
31
#include "util-hashlist.h"
32

33
typedef struct FeatureEntryType {
34
        const char *feature;
35
} FeatureEntryType;
36

37
static SCMutex feature_table_mutex = SCMUTEX_INITIALIZER;
38
static HashListTable *feature_hash_table;
39

40
static uint32_t FeatureHashFunc(HashListTable *ht, void *data,
41
                                uint16_t datalen)
42
{
28✔
43
    FeatureEntryType *f = (FeatureEntryType *)data;
28✔
44
    uint32_t hash = 0;
28✔
45
    size_t len = strlen(f->feature);
28✔
46

47
    for (size_t i = 0; i < len; i++)
112✔
48
        hash += u8_tolower((unsigned char)f->feature[i]);
84✔
49

50
    return (hash % ht->array_size);
28✔
51
}
28✔
52

53
static char FeatureHashCompareFunc(void *data1, uint16_t datalen1,
54
                                   void *data2, uint16_t datalen2)
55
{
×
56
    FeatureEntryType *f1 = (FeatureEntryType *)data1;
×
57
    FeatureEntryType *f2 = (FeatureEntryType *)data2;
×
58

59
    if (f1 == NULL || f2 == NULL)
×
60
        return 0;
×
61

62
    if (f1->feature == NULL || f2->feature == NULL)
×
63
        return 0;
×
64

65
    return strcmp(f1->feature, f2->feature) == 0;
×
66
}
×
67

68
static void FeatureHashFreeFunc(void *data)
69
{
14✔
70
    FeatureEntryType *f = data;
14✔
71
    if (f->feature) {
14✔
72
        SCFree((void *)f->feature);
14✔
73
    }
14✔
74
    SCFree(data);
14✔
75
}
14✔
76

77
static void FeatureInit(void) {
7✔
78
    feature_hash_table = HashListTableInit(256, FeatureHashFunc,
7✔
79
                                           FeatureHashCompareFunc,
7✔
80
                                           FeatureHashFreeFunc);
7✔
81

82
    if (!feature_hash_table) {
7✔
83
        FatalError("Unable to allocate feature hash table.");
×
84
    }
×
85
}
7✔
86

87
static void FeatureAddEntry(const char *feature_name)
88
{
14✔
89
    int rc;
14✔
90

91
    FeatureEntryType *feature = SCCalloc(1, sizeof(*feature));
14✔
92
    if (!feature) {
14✔
93
        FatalError("Unable to allocate feature entry memory.");
×
94
    }
×
95

96
    feature->feature = SCStrdup(feature_name);
14✔
97
    if (feature->feature) {
14✔
98
        rc = HashListTableAdd(feature_hash_table, feature, sizeof(*feature));
14✔
99
        if (rc == 0)
14✔
100
            return;
14✔
101
    }
14✔
102

103
    FeatureHashFreeFunc(feature);
×
104
}
×
105

106
void ProvidesFeature(const char *feature_name)
107
{
14✔
108
    FeatureEntryType f = { feature_name };
14✔
109

110
    SCMutexLock(&feature_table_mutex);
14✔
111

112
    FeatureEntryType *feature = HashListTableLookup(feature_hash_table, &f, sizeof(f));
14✔
113

114
    if (!feature) {
14✔
115
        FeatureAddEntry(feature_name);
14✔
116
    }
14✔
117

118
    SCMutexUnlock(&feature_table_mutex);
14✔
119
}
14✔
120

121
bool SCRequiresFeature(const char *feature_name)
122
{
×
123
    FeatureEntryType f = { feature_name };
×
124

125
    SCMutexLock(&feature_table_mutex);
×
126
    FeatureEntryType *feature = HashListTableLookup(feature_hash_table, &f, sizeof(f));
×
127
    SCMutexUnlock(&feature_table_mutex);
×
128
    return feature != NULL;
×
129
}
×
130

131
void FeatureTrackingRelease(void)
132
{
7✔
133
    if (feature_hash_table != NULL) {
7✔
134
        HashListTableFree(feature_hash_table);
7✔
135
        feature_hash_table = NULL;
7✔
136
    }
7✔
137
}
7✔
138

139
void FeatureDump(void)
140
{
×
141
    HashListTableBucket *hb = HashListTableGetListHead(feature_hash_table);
×
142
    for (; hb != NULL; hb = HashListTableGetListNext(hb)) {
×
143
        FeatureEntryType *f = HashListTableGetListData(hb);
×
144
        printf("provided feature name: %s\n", f->feature);
×
145
    }
×
146
}
×
147
void FeatureTrackingRegister(void)
148
{
7✔
149
    FeatureInit();
7✔
150
}
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