9#include <cgreen/assertions.h>
10#include <cgreen/cgreen.h>
11#include <cgreen/constraint_syntax_helpers.h>
12#include <cgreen/internal/c_assertions.h>
13#include <cgreen/mocks.h>
15#define VT_NAME "Example: Security Advisory for eg (EXAMPLE-2025-cb7b)"
19 " \"oid\": \"1.3.6.1.4.1.25623.1.0.877440\"," \
20 " \"name\": \"" VT_NAME "\"," \
21 " \"filename\": \"2020/fedora/gb_fedora_2020_cb7b7181a0_sox_fc30.nasl\"," \
23 " \"affected\": \"'sox' package(s) on Fedora 30.\"," \
24 " \"creation_date\": 1581134661," \
25 " \"cvss_base_vector\": \"AV:N/AC:L/Au:N/C:N/I:N/A:P\"," \
26 " \"insight\": \"SoX (Sound eXchange) is a sound file format...\"," \
27 " \"last_modification\": 1626919250," \
28 " \"qod_type\": \"package\"," \
29 " \"severity_date\": 1624547760," \
30 " \"severity_origin\": \"NVD\"," \
31 " \"severity_vector\": \"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H\"," \
32 " \"solution\": \"Please install the updated package(s).\"," \
33 " \"solution_type\": \"VendorFix\"," \
34 " \"summary\": \"The remote host is missing an update for ...\"" \
36 " \"dependencies\": [" \
37 " \"gather-package-list.nasl\"" \
39 " \"required_keys\": []," \
40 " \"mandatory_keys\": [" \
41 " \"ssh/login/fedora\"," \
42 " \"ssh/login/rpms\"," \
43 " \"ssh/login/release=FC30\"" \
45 " \"excluded_keys\": []," \
46 " \"required_ports\": []," \
47 " \"required_udp_ports\": []," \
48 " \"references\": [" \
50 " \"class\": \"cve\"," \
51 " \"id\": \"CVE-2017-18189\"" \
54 " \"class\": \"2020-cb7b7181a0\"," \
55 " \"id\": \"FEDORA\"" \
58 " \"class\": \"https://example.org/ann/EG-IZ3CX\"," \
62 " \"preferences\": []," \
63 " \"category\": \"gather_info\"," \
64 " \"family\": \"Fedora Local Security Checks\"" \
79 return fmemopen ((
void *) str, strlen (str),
"r");
84Ensure (vtparser, parse_vt_json_parses_a_vt)
93 assert_that (file, is_not_null);
102 assert_that (nvt, is_not_null);
106 is_equal_to_string (
"cve:CVE-2017-18189,"
107 " 2020-cb7b7181a0:FEDORA,"
108 " https://example.org/ann/EG-IZ3CX:URL"));
125 suite = create_test_suite ();
127 add_test_with_context (suite, vtparser, parse_vt_json_parses_a_vt);
130 ret = run_single_test (suite, argv[1], create_text_reporter ());
132 ret = run_test_suite (suite, create_text_reporter ());
134 destroy_test_suite (suite);
void gvm_json_pull_parser_cleanup(gvm_json_pull_parser_t *parser)
Frees the data of a JSON pull parser.
void gvm_json_pull_event_cleanup(gvm_json_pull_event_t *event)
Frees all data of JSON pull event data structure.
void gvm_json_pull_parser_next(gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event)
Get the next event from a JSON pull parser.
void gvm_json_pull_parser_init(gvm_json_pull_parser_t *parser, FILE *input_stream)
Initializes a JSON pull parser with default buffer sizes.
void gvm_json_pull_event_init(gvm_json_pull_event_t *event)
Initializes a JSON pull event data structure.
gchar * nvti_refs(const nvti_t *n, const gchar *type, const gchar *exclude_types, guint use_types)
Get references as string.
struct nvti nvti_t
The structure of a information record that corresponds to a NVT.
gchar * nvti_name(const nvti_t *n)
Get the name.
void nvti_free(nvti_t *n)
Free memory of a nvti structure.
Protos and data structures for NVT Information data sets.
Event generated by the JSON pull parser.
int parse_vt_json(gvm_json_pull_parser_t *parser, gvm_json_pull_event_t *event, nvti_t **nvt)
Parse a VT element given in json format.
int main(int argc, char **argv)
static FILE * memopen(const gchar *str)
Ensure(vtparser, parse_vt_json_parses_a_vt)