Skip to content

Commit

Permalink
Merge branch 'main' into enum-error-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Dec 5, 2024
2 parents 0f63731 + 2f613e5 commit f9526b8
Show file tree
Hide file tree
Showing 43 changed files with 1,270 additions and 428 deletions.
1 change: 1 addition & 0 deletions .github/workflows/push-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
org.opencontainers.image.base.name=greenbone/gvm-libs
artifact-name: rs-binaries
artifact-path: assets
service: openvas-scanner
secrets:
COSIGN_KEY_OPENSIGHT: ${{ secrets.cosign_key_opensight }}
COSIGN_KEY_PASSWORD_OPENSIGHT: ${{ secrets.cosign_password_opensight }}
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message ("-- Configuring the Scanner...")

# VERSION: Always include major, minor and patch level.
project (openvas
VERSION 23.12.1
VERSION 23.13.1
LANGUAGES C)

if (POLICY CMP0005)
Expand Down
2 changes: 1 addition & 1 deletion charts/openvasd/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ version: 0.1.0
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "23.12.1"
appVersion: "23.13.1"
74 changes: 48 additions & 26 deletions misc/ipc_openvas_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Ensure (ipc_openvas, ipc_data_from_json_ua_ok)
gchar *ua = "localhost";

// Preapre data to be sent
data_s = g_malloc0 (sizeof (ipc_data_t *));
data_s = g_malloc0 (sizeof (ipc_data_t));
data_s = ipc_data_type_from_user_agent (ua, strlen (ua));

const char *json = ipc_data_to_json (data_s);
Expand All @@ -48,7 +48,7 @@ Ensure (ipc_openvas, ipc_data_from_json_hostname_ok)
gchar *hns = "TLS certificate";

// Preapre data to be sent
data_s = g_malloc0 (sizeof (ipc_data_t *));
data_s = g_malloc0 (sizeof (ipc_data_t));
data_s = ipc_data_type_from_hostname (hns, strlen (hns), hn, strlen (hn));

const char *json = ipc_data_to_json (data_s);
Expand All @@ -70,10 +70,8 @@ Ensure (ipc_openvas, ipc_data_from_json_hostname_ok)
Ensure (ipc_openvas, ipc_data_from_json_parse_error)
{
ipc_data_t *data_r = NULL;
char *json_fake = NULL;

// malformed json string
json_fake = g_strdup (
char json_fake[1024] =
"{\"type\":2,\"user-agent\":\"Mozilla/5.0 [en] (X11, U; Greenbone OS "
"22.04.4)\"}{\"type\":2,\"user-agent\":\"Mozilla/5.0 [en] (X11, U; "
"Greenbone OS 22.04.4)\"}{\"type\":2,\"user-agent\":\"Mozilla/5.0 [en] "
Expand All @@ -90,10 +88,10 @@ Ensure (ipc_openvas, ipc_data_from_json_parse_error)
"22.04.4)\"}{\"type\":2,\"user-agent\":\"Mozilla/5.0 [en] (X11, U; "
"Greenbone OS 22.04.4)\"}{\"type\":2,\"user-agent\":\"Mozilla/5.0 [en] "
"(X11, U; Greenbone OS 22.04.4)\"}{\"type\":2,\"user-agent\":\"Mozilla/5.0 "
"[en] (X11, U; Greenbone OS 22.04.4)\"}{\"type\":");
"[en] (X11, U; Greenbone OS 22.04.4)\"}{\"type\":";

// Read received data
data_r = g_malloc0 (sizeof (ipc_data_t *));
data_r = g_malloc0 (sizeof (ipc_data_t));
data_r = ipc_data_from_json (json_fake, strlen (json_fake));
assert_that (ipc_get_hostname_from_data (data_r), is_null);
assert_that (ipc_get_hostname_source_from_data (data_r), is_null);
Expand All @@ -103,25 +101,49 @@ Ensure (ipc_openvas, ipc_data_from_json_parse_error)
Ensure (ipc_openvas, ipc_data_from_json_parse_many_objects)
{
ipc_data_t *data_r = NULL;
char *json_fake = NULL;

// malformed json string
json_fake =
g_strdup ("{\"type\":1,\"source\":\"TLS "
"certificate\",\"hostname\":\"localhost\"}{\"type\":2,\"user-"
"agent\":\"Mozilla/5.0 [en] (X11, U; Greenbone OS "
"22.04.4)\"}");

// Read received data
data_r = g_malloc0 (sizeof (ipc_data_t *));
data_r = ipc_data_from_json (json_fake, strlen (json_fake));

assert_that (ipc_get_hostname_from_data (data_r),
is_equal_to_string ("localhost"));
assert_that (ipc_get_hostname_source_from_data (data_r),
is_equal_to_string ("TLS certificate"));

ipc_data_destroy (&data_r);
int len = 0;
int pos = 0;

// json string with more than one objects
char json_fake[256] =
"{\"type\":1,\"source\":\"TLS "
"certificate\",\"hostname\":\"localhost\"}{\"type\":2,\"user-agent\":"
"\"Mozilla/5.0 [en] (X11, U; Greenbone OS 22.04.4)\"}";

for (int i = 0; json_fake[i] != '\0'; i++)
{
if (json_fake[i] == '}')
{
gchar *message = NULL;
len = i - pos + 1;

message = g_malloc0 (sizeof (gchar) * (len + 1));
memcpy (message, &json_fake[pos], len);
printf ("\n\nel mensaje %s\n\n", message);
pos = i + 1;
len = 0;
data_r = g_malloc0 (sizeof (ipc_data_t));
data_r = ipc_data_from_json (message, strlen (message));
if (ipc_get_data_type_from_data (data_r) == IPC_DT_HOSTNAME)
{
assert_that (ipc_get_hostname_from_data (data_r),
is_equal_to_string ("localhost"));
assert_that (ipc_get_hostname_source_from_data (data_r),
is_equal_to_string ("TLS certificate"));

ipc_data_destroy (&data_r);
}
else
{
assert_that (
ipc_get_user_agent_from_data (data_r),
is_equal_to_string (
"Mozilla/5.0 [en] (X11, U; Greenbone OS 22.04.4)"));
ipc_data_destroy (&data_r);
}
g_free (message);
}
}
assert_that (data_r, is_null);
}

Expand Down
Loading

0 comments on commit f9526b8

Please sign in to comment.