|
25 | 25 | #endif
|
26 | 26 |
|
27 | 27 | #include <string.h>
|
28 |
| -#include <pcre.h> |
29 | 28 |
|
30 | 29 | #include "oscap_text.h"
|
31 | 30 | #include "item.h"
|
|
43 | 42 |
|
44 | 43 | #define XCCDF_SUPPORTED "1.2"
|
45 | 44 |
|
46 |
| -/* According to `man 3 pcreapi`, the number passed in ovecsize should always |
47 |
| - * be a multiple of three. |
48 |
| - */ |
49 |
| -#define OVECTOR_LEN 30 |
50 |
| - |
51 | 45 | static struct oscap_htable *xccdf_benchmark_find_target_htable(const struct xccdf_benchmark *, xccdf_type_t);
|
52 | 46 | static xmlNode *xccdf_plain_text_to_dom(const struct xccdf_plain_text *ptext, xmlDoc *doc, xmlNode *parent, const struct xccdf_version_info* version_info);
|
53 | 47 |
|
@@ -132,48 +126,6 @@ struct xccdf_benchmark *xccdf_benchmark_clone(const struct xccdf_benchmark *old_
|
132 | 126 | return XBENCHMARK(new_benchmark);
|
133 | 127 | }
|
134 | 128 |
|
135 |
| -static void _xccdf_benchmark_add_platform(struct xccdf_item *benchmark, xmlTextReaderPtr reader) |
136 |
| -{ |
137 |
| - char *platform_idref = xccdf_attribute_copy(reader, XCCDFA_IDREF); |
138 |
| - |
139 |
| - /* Official Windows 7 CPE according to National Vulnerability Database |
140 |
| - * CPE Dictionary as of 2018-08-29 is 'cpe:/o:microsoft:windows_7'. |
141 |
| - * However, content exported from Microsoft Security Compliance Manager |
142 |
| - * as of version 4.0.0.1 in CAB archive using 'Export in SCAP 1.0' is |
143 |
| - * 'cpe:/o:microsoft:windows7'. If this pattern is matched, we will add |
144 |
| - * an underscore to workaround the situation that this XCCDF benchmark is |
145 |
| - * not applicable. |
146 |
| - */ |
147 |
| - const char *pcreerror = NULL; |
148 |
| - int erroffset = 0; |
149 |
| - pcre *regex = pcre_compile("^(cpe:/o:microsoft:windows)(7.*)", 0, &pcreerror, &erroffset, NULL); |
150 |
| - int ovector[OVECTOR_LEN]; |
151 |
| - int rc = pcre_exec(regex, NULL, platform_idref, strlen(platform_idref), 0, 0, ovector, OVECTOR_LEN); |
152 |
| - /* 1 pattern + 2 groups = 3 */ |
153 |
| - if (rc == 3) { |
154 |
| - int match_len = ovector[1] - ovector[0]; |
155 |
| - /* match_len + 1 underscore + 1 zero byte */ |
156 |
| - char *alternate_platform_idref = malloc(match_len + 1 + 1); |
157 |
| - int first_group_start = ovector[2]; |
158 |
| - int first_group_end = ovector[3]; |
159 |
| - size_t first_group_len = first_group_end - first_group_start; |
160 |
| - int second_group_start = ovector[4]; |
161 |
| - int second_group_end = ovector[5]; |
162 |
| - size_t second_group_len = second_group_end - second_group_start; |
163 |
| - char *aptr = alternate_platform_idref; |
164 |
| - strncpy(aptr, platform_idref + first_group_start, first_group_len); |
165 |
| - aptr += first_group_len; |
166 |
| - *aptr = '_'; |
167 |
| - aptr++; |
168 |
| - strncpy(aptr, platform_idref + second_group_start, second_group_len); |
169 |
| - aptr += second_group_len; |
170 |
| - *aptr = '\0'; |
171 |
| - oscap_list_add(benchmark->item.platforms, alternate_platform_idref); |
172 |
| - } |
173 |
| - |
174 |
| - oscap_list_add(benchmark->item.platforms, platform_idref); |
175 |
| -} |
176 |
| - |
177 | 129 | bool xccdf_benchmark_parse(struct xccdf_item * benchmark, xmlTextReaderPtr reader)
|
178 | 130 | {
|
179 | 131 | XCCDF_ASSERT_ELEMENT(reader, XCCDFE_BENCHMARK);
|
@@ -208,7 +160,7 @@ bool xccdf_benchmark_parse(struct xccdf_item * benchmark, xmlTextReaderPtr reade
|
208 | 160 | oscap_list_add(benchmark->sub.benchmark.rear_matter, oscap_text_new_parse(XCCDF_TEXT_HTMLSUB, reader));
|
209 | 161 | break;
|
210 | 162 | case XCCDFE_PLATFORM:
|
211 |
| - _xccdf_benchmark_add_platform(benchmark, reader); |
| 163 | + xccdf_item_add_applicable_platform(benchmark, reader); |
212 | 164 | break;
|
213 | 165 | case XCCDFE_MODEL:
|
214 | 166 | parsed_model = xccdf_model_new_xml(reader);
|
|
0 commit comments