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

Added a test, if the ssh_elevate_credential is different from the ssh_credential. #1582

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add NVT tag "deprecated" [#1536](https://github.com/greenbone/gvmd/pull/1536)
- 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)
- Add test if the ssh elevate credential is different from the ssh credential [#1582](https://github.com/greenbone/gvmd/pull/1582)

### Changed
- Update default log config [#1501](https://github.com/greenbone/gvmd/pull/1501)
Expand Down
15 changes: 15 additions & 0 deletions src/gmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21778,6 +21778,13 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
" an SSH credential"));
log_event_fail ("target", "Target", NULL, "created");
break;
case 15:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_target",
"The elevate credential must be"
" different from the SSH credential"));
log_event_fail ("target", "Target", NULL, "created");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("create_target",
Expand Down Expand Up @@ -24489,6 +24496,14 @@ gmp_xml_handle_end_element (/* unused */ GMarkupParseContext* context,
log_event_fail ("target", "Target",
modify_target_data->target_id, "modified");
break;
case 25:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_target",
"The elevate credential must be different"
" from the SSH credential"));
log_event_fail ("target", "Target",
modify_target_data->target_id, "modified");
break;
case 99:
SEND_TO_CLIENT_OR_FAIL
(XML_ERROR_SYNTAX ("modify_target",
Expand Down
9 changes: 9 additions & 0 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -30669,6 +30669,9 @@ create_target (const char* name, const char* asset_hosts_filter,
if (ssh_elevate_credential && (!ssh_credential))
return 14;

if (ssh_elevate_credential == ssh_credential)
return 15;

sql_begin_immediate ();

if (acl_user_may ("create_target") == 0)
Expand Down Expand Up @@ -31155,6 +31158,12 @@ modify_target (const char *target_id, const char *name, const char *hosts,
return 24;
}

if (ssh_elevate_credential_id == ssh_credential_id)
{
sql_rollback ();
return 25;
}

target = 0;
if (find_target_with_permission (target_id, &target, "modify_target"))
{
Expand Down