Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also use internal function name in some nasl log messages #611

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Extend nasl lint to detect if function parameter is used twice. [#585](https://github.com/greenbone/openvas/pull/585)
- Consider .csv files for checksum check and upload in redis cache. [#599](https://github.com/greenbone/openvas/pull/599)
- Add option to specify if a host can be scanned through its IPv4 and IPv6 in parallel. [#604](https://github.com/greenbone/openvas/pull/604)

### Changed
-Store results in main_kb instead of host_kb. [#550](https://github.com/greenbone/openvas/pull/550)
- Store results in main_kb instead of host_kb. [#550](https://github.com/greenbone/openvas/pull/550)
- Also use internal function name in some nasl log messages. [#611](https://github.com/greenbone/openvas/pull/611)

### Removed
- Use the nvticache name from gvm-libs, defined in nvticache.h. [#578](https://github.com/greenbone/openvas/pull/578)
Expand Down
12 changes: 6 additions & 6 deletions misc/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,10 +1222,10 @@ read_stream_connection_unbuffered (int fd, void *buf0, int min_len, int max_len)

default:
if (fp->transport || fp->fd != 0)
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Severe bug! Unhandled transport layer %d (fd=%d).",
nasl_get_function_name (), nasl_get_plugin_filename (),
fp->transport, fd);
nasl_get_function_name () ?: "script_main_function",
__func__, nasl_get_plugin_filename (), fp->transport, fd);
else
g_message ("read_stream_connection_unbuffered: "
"fd=%d is closed",
Expand Down Expand Up @@ -1403,10 +1403,10 @@ write_stream_connection4 (int fd, void *buf0, int n, int i_opt)

default:
if (fp->transport || fp->fd != 0)
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Severe bug! Unhandled transport layer %d (fd=%d).",
nasl_get_function_name (), nasl_get_plugin_filename (),
fp->transport, fd);
nasl_get_function_name () ?: "script_main_function",
__func__, nasl_get_plugin_filename (), fp->transport, fd);
else
g_message ("read_stream_connection_unbuffered: fd=%d is "
"closed",
Expand Down
114 changes: 66 additions & 48 deletions nasl/nasl_ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,10 @@ nasl_ssh_connect (lex_ctxt *lexic)
session = ssh_new ();
if (!session)
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to allocate a new SSH session",
nasl_get_function_name (), nasl_get_plugin_filename ());
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename ());
return NULL;
}

Expand All @@ -276,20 +277,20 @@ nasl_ssh_connect (lex_ctxt *lexic)

if (ssh_options_set (session, SSH_OPTIONS_HOST, ip_str))
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to set SSH hostname '%s': %s",
nasl_get_function_name (), nasl_get_plugin_filename (), ip_str,
ssh_get_error (session));
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ip_str, ssh_get_error (session));
ssh_free (session);
return NULL;
}

if (ssh_options_set (session, SSH_OPTIONS_KNOWNHOSTS, "/dev/null"))
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to disable SSH known_hosts: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ssh_get_error (session));
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ssh_get_error (session));
ssh_free (session);
return NULL;
}
Expand All @@ -298,10 +299,11 @@ nasl_ssh_connect (lex_ctxt *lexic)

if (key_type && ssh_options_set (session, SSH_OPTIONS_HOSTKEYS, key_type))
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to set SSH key type '%s': %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
key_type, ssh_get_error (session));
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), key_type,
ssh_get_error (session));
ssh_free (session);
return NULL;
}
Expand All @@ -310,21 +312,23 @@ nasl_ssh_connect (lex_ctxt *lexic)
if (csciphers
&& ssh_options_set (session, SSH_OPTIONS_CIPHERS_C_S, csciphers))
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to set SSH client to server ciphers '%s': %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
csciphers, ssh_get_error (session));
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), csciphers,
ssh_get_error (session));
ssh_free (session);
return NULL;
}
scciphers = get_str_var_by_name (lexic, "scciphers");
if (scciphers
&& ssh_options_set (session, SSH_OPTIONS_CIPHERS_S_C, scciphers))
{
g_message ("Function %s called from %s: "
g_message ("Function %s (calling internal function %s) called from %s: "
"Failed to set SSH server to client ciphers '%s': %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
scciphers, ssh_get_error (session));
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), scciphers,
ssh_get_error (session));
ssh_free (session);
return NULL;
}
Expand All @@ -335,10 +339,11 @@ nasl_ssh_connect (lex_ctxt *lexic)

if (ssh_options_set (session, SSH_OPTIONS_PORT, &my_port))
{
g_message ("Function %s called from %s: "
"Failed to set SSH port for '%s' to %d: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ip_str, port, ssh_get_error (session));
g_message (
"Function %s (calling internal function %s) called from %s: "
"Failed to set SSH port for '%s' to %d: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ip_str, port, ssh_get_error (session));
ssh_free (session);
return NULL;
}
Expand All @@ -352,10 +357,12 @@ nasl_ssh_connect (lex_ctxt *lexic)
my_fd, sock);
if (ssh_options_set (session, SSH_OPTIONS_FD, &my_fd))
{
g_message ("Function %s called from %s: "
"Failed to set SSH fd for '%s' to %d (NASL sock=%d): %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ip_str, my_fd, sock, ssh_get_error (session));
g_message (
"Function %s (calling internal function %s) called from %s: "
"Failed to set SSH fd for '%s' to %d (NASL sock=%d): %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ip_str, my_fd, sock,
ssh_get_error (session));
ssh_free (session);
return NULL;
}
Expand Down Expand Up @@ -725,10 +732,11 @@ nasl_ssh_set_login (lex_ctxt *lexic)
if (username && *username
&& ssh_options_set (session, SSH_OPTIONS_USER, username))
{
g_message ("Function %s called from %s: "
"Failed to set SSH username '%s': %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
username, ssh_get_error (session));
g_message (
"Function %s (calling internal function %s) called from %s: "
"Failed to set SSH username '%s': %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), username, ssh_get_error (session));
g_free (username);
return NULL; /* Ooops. */
}
Expand Down Expand Up @@ -1198,9 +1206,10 @@ exec_ssh_cmd (ssh_session session, char *cmd, int verbose, int compat_mode,
alarm (30);
if ((channel = ssh_channel_new (session)) == NULL)
{
g_message ("Function %s called from %s: ssh_channel_new failed: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ssh_get_error (session));
g_message ("Function %s (calling internal function %s) called from %s: "
"ssh_channel_new failed: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ssh_get_error (session));
return SSH_ERROR;
}

Expand Down Expand Up @@ -1338,8 +1347,10 @@ nasl_ssh_request_exec (lex_ctxt *lexic)
cmd = get_str_var_by_name (lexic, "cmd");
if (!cmd || !*cmd)
{
g_message ("Function %s called from %s: No command passed",
nasl_get_function_name (), nasl_get_plugin_filename ());
g_message ("Function %s (calling internal function %s) called from %s: "
"No command passed",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename ());
return NULL;
}

Expand Down Expand Up @@ -1403,9 +1414,10 @@ nasl_ssh_request_exec (lex_ctxt *lexic)
p = g_string_free (response, FALSE);
if (!p)
{
g_message ("Function %s called from %s: memory problem: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
strerror (-1));
g_message ("Function %s (calling internal function %s) called from %s: "
"memory problem: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), strerror (-1));
return NULL;
}

Expand Down Expand Up @@ -1674,18 +1686,20 @@ nasl_ssh_shell_open (lex_ctxt *lexic)
return NULL;
if (ssh_channel_open_session (channel))
{
g_message ("Function %s called from %s: ssh_channel_open_session: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ssh_get_error (session));
g_message ("Function %s (calling internal function %s) called from %s: "
"ssh_channel_open_session: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ssh_get_error (session));
ssh_channel_free (channel);
return NULL;
}

if (request_ssh_shell (channel))
{
g_message ("Function %s called from %s: request_ssh_shell: %s",
nasl_get_function_name (), nasl_get_plugin_filename (),
ssh_get_error (session));
g_message ("Function %s (calling internal function %s) called from %s: "
"request_ssh_shell: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (), ssh_get_error (session));
ssh_channel_free (channel);
return NULL;
}
Expand Down Expand Up @@ -1799,16 +1813,20 @@ nasl_ssh_shell_write (lex_ctxt *lexic)
cmd = get_str_var_by_name (lexic, "cmd");
if (!cmd || !*cmd)
{
g_message ("Function %s called from %s: No command passed",
nasl_get_function_name (), nasl_get_plugin_filename ());
g_message ("Function %s (calling internal function %s) called from %s: "
"No command passed",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename ());
goto write_ret;
}
len = strlen (cmd);
if (ssh_channel_write (channel, cmd, len) != len)
{
g_message ("Function %s called from %s: %s", nasl_get_function_name (),
nasl_get_plugin_filename (),
ssh_get_error (session_table[tbl_slot].session));
g_message (
"Function %s (calling internal function %s) called from %s: %s",
nasl_get_function_name () ?: "script_main_function", __func__,
nasl_get_plugin_filename (),
ssh_get_error (session_table[tbl_slot].session));
goto write_ret;
}
rc = 0;
Expand Down