Skip to content

Commit

Permalink
Change: Speed up GET_TARGETS
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Jun 15, 2023
2 parents 36d8dfb + 93413fe commit b034a1e
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -32054,13 +32054,17 @@ modify_target (const char *target_id, const char *name, const char *hosts,
{ \
GET_ITERATOR_COLUMNS (targets), \
{ "hosts", NULL, KEYWORD_TYPE_STRING }, \
{ "target_credential (id, 0, CAST ('ssh' AS text))", \
{ "(SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('ssh' AS text))", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "target_login_port (id, 0, CAST ('ssh' AS text))", \
"ssh_port", \
KEYWORD_TYPE_INTEGER }, \
{ "target_credential (id, 0, CAST ('smb' AS text))", \
{ "(SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('smb' AS text))", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "port_list", NULL, KEYWORD_TYPE_INTEGER }, \
Expand All @@ -32083,15 +32087,21 @@ modify_target (const char *target_id, const char *name, const char *hosts,
{ "reverse_lookup_only", NULL, KEYWORD_TYPE_INTEGER }, \
{ "reverse_lookup_unify", NULL, KEYWORD_TYPE_INTEGER }, \
{ "alive_test", NULL, KEYWORD_TYPE_INTEGER }, \
{ "target_credential (id, 0, CAST ('esxi' AS text))", \
{ "(SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('esxi' AS text))", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "target_credential (id, 0, CAST ('snmp' AS text))", \
{ "(SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('snmp' AS text))", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
{ "target_credential (id, 0, CAST ('elevate' AS text))", \
{ "(SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('elevate' AS text))", \
NULL, \
KEYWORD_TYPE_INTEGER }, \
{ "0", NULL, KEYWORD_TYPE_INTEGER }, \
Expand All @@ -32101,40 +32111,45 @@ modify_target (const char *target_id, const char *name, const char *hosts,
{ \
"(SELECT name FROM credentials" \
" WHERE credentials.id" \
" = target_credential (targets.id, 0," \
" CAST ('ssh' AS text)))", \
" = (SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('ssh' AS text)))", \
"ssh_credential", \
KEYWORD_TYPE_STRING \
}, \
{ \
"(SELECT name FROM credentials" \
" WHERE credentials.id" \
" = target_credential (targets.id, 0," \
" CAST ('smb' AS text)))", \
" = (SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('smb' AS text)))", \
"smb_credential", \
KEYWORD_TYPE_STRING \
}, \
{ \
"(SELECT name FROM credentials" \
" WHERE credentials.id" \
" = target_credential (targets.id, 0," \
" CAST ('esxi' AS text)))", \
" = (SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('esxi' AS text)))", \
"esxi_credential", \
KEYWORD_TYPE_STRING \
}, \
{ \
"(SELECT name FROM credentials" \
" WHERE credentials.id" \
" = target_credential (targets.id, 0," \
" CAST ('snmp' AS text)))", \
" = (SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('snmp' AS text)))", \
"snmp_credential", \
KEYWORD_TYPE_STRING \
}, \
{ \
"(SELECT name FROM credentials" \
" WHERE credentials.id" \
" = target_credential (targets.id, 0," \
" CAST ('elevate' AS text)))", \
" = (SELECT credential FROM targets_login_data" \
" WHERE target = targets.id" \
" AND type = CAST ('elevate' AS text)))", \
"ssh_elevate_credential", \
KEYWORD_TYPE_STRING \
}, \
Expand Down

0 comments on commit b034a1e

Please sign in to comment.