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

Include new ssh elevate credential login data in OSP request #1539

Merged
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
- Add a new modification_time column to reports [#1513](https://github.com/greenbone/gvmd/pull/1513), [#1519](https://github.com/greenbone/gvmd/pull/1519)
- Extend GMP for new privilege escalation credential[#1535](https://github.com/greenbone/gvmd/pull/1535)
- Extend GMP for new privilege escalation credential [#1535](https://github.com/greenbone/gvmd/pull/1535)
- Include new ssh elevate (escalation) credential in OSP request [#1539](https://github.com/greenbone/gvmd/pull/1539)

### Changed
- Use pg-gvm extension for C PostgreSQL functions [#1400](https://github.com/greenbone/gvmd/pull/1400), [#1453](https://github.com/greenbone/gvmd/pull/1453)
Expand Down
40 changes: 38 additions & 2 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,16 +2077,19 @@ launch_osp_task (task_t task, target_t target, const char *scan_id,
static osp_credential_t *
target_osp_ssh_credential (target_t target)
{
credential_t credential;
credential_t credential, ssh_elevate_credential;
credential = target_ssh_credential (target);
ssh_elevate_credential = target_ssh_elevate_credential (target);

if (credential)
{
iterator_t iter;
iterator_t iter, ssh_elevate_iter;
const char *type;
char *ssh_port;
osp_credential_t *osp_credential;

init_credential_iterator_one (&iter, credential);

if (!next (&iter))
{
g_warning ("%s: SSH Credential not found.", __func__);
Expand All @@ -2111,6 +2114,7 @@ target_osp_ssh_credential (target_t target)
osp_credential_set_auth_data (osp_credential,
"password",
credential_iterator_password (&iter));

if (strcmp (type, "usk") == 0)
{
const char *private_key = credential_iterator_private_key (&iter);
Expand All @@ -2119,8 +2123,40 @@ target_osp_ssh_credential (target_t target)
osp_credential_set_auth_data (osp_credential,
"private", base64);
g_free (base64);
}

if(ssh_elevate_credential)
{
const char *elevate_type;

init_credential_iterator_one (&ssh_elevate_iter,
ssh_elevate_credential);
if (!next (&ssh_elevate_iter))
{
g_warning ("%s: SSH Elevate Credential not found.", __func__);
cleanup_iterator (&ssh_elevate_iter);
osp_credential_free(osp_credential);
return NULL;
timopollmeier marked this conversation as resolved.
Show resolved Hide resolved
}
elevate_type = credential_iterator_type (&ssh_elevate_iter);
if (strcmp (elevate_type, "up"))
{
g_warning ("%s: SSH Elevate Credential not of type up", __func__);
cleanup_iterator (&ssh_elevate_iter);
osp_credential_free(osp_credential);
return NULL;
timopollmeier marked this conversation as resolved.
Show resolved Hide resolved
}
osp_credential_set_auth_data (osp_credential,
"priv_username",
credential_iterator_login
(&ssh_elevate_iter));
osp_credential_set_auth_data (osp_credential,
"priv_password",
credential_iterator_password
(&ssh_elevate_iter));
cleanup_iterator (&ssh_elevate_iter);
}

cleanup_iterator (&iter);
return osp_credential;
}
Expand Down