Skip to content

Commit

Permalink
Merge branch 'main' into faster-rebuild-2
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Apr 19, 2023
2 parents 2bc419b + ac8a880 commit 9c0878d
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 75 deletions.
34 changes: 19 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ endif (NOT CMAKE_BUILD_TYPE)

OPTION (ENABLE_COVERAGE "Enable support for coverage analysis" OFF)
OPTION (DEBUG_FUNCTION_NAMES "Print function names on entry and exit" OFF)
# the shell based scripts got replaced by https://github.com/greenbone/greenbone-feed-sync/
OPTION (INSTALL_OLD_SYNC_SCRIPTS "Install shell based feed sync scripts" OFF)

## Retrieve git revision (at configure time)
include (GetGit)
Expand Down Expand Up @@ -96,7 +98,7 @@ include (CPack)

## Variables

set (GVMD_DATABASE_VERSION 251)
set (GVMD_DATABASE_VERSION 253)

set (GVMD_SCAP_DATABASE_VERSION 20)

Expand Down Expand Up @@ -394,20 +396,22 @@ install (FILES tools/cert_bund_getbyname.xsl tools/dfn_cert_getbyname.xsl
DESTINATION ${GVM_CERT_RES_DIR}
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ)

install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-feed-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-scapdata-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-certdata-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
if (INSTALL_OLD_SYNC_SCRIPTS)
install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-feed-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-scapdata-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

install (FILES ${CMAKE_BINARY_DIR}/tools/greenbone-certdata-sync
DESTINATION ${SBINDIR}
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
endif (INSTALL_OLD_SYNC_SCRIPTS)

install (FILES ${CMAKE_SOURCE_DIR}/tools/gvm-lsc-deb-creator
${CMAKE_SOURCE_DIR}/tools/gvm-lsc-exe-creator
Expand Down
19 changes: 2 additions & 17 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,18 @@ endif (NOT XSLTPROC_EXECUTABLE)

if (XMLTOMAN_EXECUTABLE)
add_custom_target (man COMMENT "Building manual page..."
DEPENDS gvmd.8 greenbone-certdata-sync.8 greenbone-scapdata-sync.8)
DEPENDS gvmd.8)

add_custom_command (OUTPUT gvmd.8
COMMAND sh
ARGS -c \"${XMLTOMAN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/gvmd.8.xml > ${CMAKE_CURRENT_BINARY_DIR}/gvmd.8\;\"
DEPENDS gvmd.8.xml)

add_custom_command (OUTPUT greenbone-certdata-sync.8
COMMAND sh
ARGS -c \"${XMLTOMAN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/greenbone-certdata-sync.8.xml > ${CMAKE_CURRENT_BINARY_DIR}/greenbone-certdata-sync.8\;\"
DEPENDS greenbone-certdata-sync.8.xml)

add_custom_command (OUTPUT greenbone-scapdata-sync.8
COMMAND sh
ARGS -c \"${XMLTOMAN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/greenbone-scapdata-sync.8.xml > ${CMAKE_CURRENT_BINARY_DIR}/greenbone-scapdata-sync.8\;\"
DEPENDS greenbone-scapdata-sync.8.xml)
else (XMLTOMAN_EXECUTABLE)
message (STATUS "WARNING: xmltoman is required to generate manpage.")
add_custom_command (OUTPUT gvmd.8
COMMAND echo "[Error: xmltoman required to see manpage here]"
> gvmd.8)
add_custom_command (OUTPUT greenbone-certdata-sync.8
COMMAND echo "[Error: xmltoman required to see manpage here]"
> greenbone-certdata-sync.8)
add_custom_command (OUTPUT greenbone-scapdata-sync.8
COMMAND echo "[Error: xmltoman required to see manpage here]"
> greenbone-scapdata-sync.8)
endif (XMLTOMAN_EXECUTABLE)

if (XMLMANTOHTML_EXECUTABLE)
Expand All @@ -158,6 +143,6 @@ if (XSLTPROC_EXECUTABLE)
COMPONENT doc)
endif (XSLTPROC_EXECUTABLE)

install (FILES gvmd.8 greenbone-certdata-sync.8 greenbone-scapdata-sync.8
install (FILES gvmd.8
DESTINATION share/man/man8/
COMPONENT doc)
29 changes: 16 additions & 13 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@ handle_osp_scan (task_t task, report_t report, const char *scan_id)
(task, "", "", "",
threat_message_type ("Error"),
"Erroneous scan progress value", "", "",
QOD_DEFAULT, NULL);
QOD_DEFAULT, NULL, NULL);
report_add_result (report, result);
delete_osp_scan (scan_id, host, port, ca_pub, key_pub,
key_priv);
Expand Down Expand Up @@ -1824,7 +1824,7 @@ handle_osp_scan (task_t task, report_t report, const char *scan_id)
(task, "", "", "",
threat_message_type ("Error"),
"Erroneous scan progress value", "", "",
QOD_DEFAULT, NULL);
QOD_DEFAULT, NULL, NULL);
report_add_result (report, result);
rc = -1;
break;
Expand Down Expand Up @@ -1854,7 +1854,7 @@ handle_osp_scan (task_t task, report_t report, const char *scan_id)
(task, "", "", "",
threat_message_type ("Error"),
"Task interrupted unexpectedly", "", "",
QOD_DEFAULT, NULL);
QOD_DEFAULT, NULL, NULL);
report_add_result (report, result);
delete_osp_scan (scan_id, host, port, ca_pub, key_pub,
key_priv);
Expand All @@ -1877,7 +1877,7 @@ handle_osp_scan (task_t task, report_t report, const char *scan_id)
(task, "", "", "",
threat_message_type ("Error"),
"Scan stopped unexpectedly by the server", "", "",
QOD_DEFAULT, NULL);
QOD_DEFAULT, NULL, NULL);
report_add_result (report, result);
delete_osp_scan (scan_id, host, port, ca_pub, key_pub,
key_priv);
Expand Down Expand Up @@ -2748,7 +2748,7 @@ fork_osp_scan_handler (task_t task, target_t target, int from,
g_warning ("OSP start_scan %s: %s", report_id, error);
result = make_osp_result (task, "", "", "",
threat_message_type ("Error"),
error, "", "", QOD_DEFAULT, NULL);
error, "", "", QOD_DEFAULT, NULL, NULL);
report_add_result (global_current_report, result);
set_task_run_status (task, TASK_STATUS_DONE);
set_report_scan_run_status (global_current_report, TASK_STATUS_DONE);
Expand Down Expand Up @@ -2936,7 +2936,7 @@ cve_scan_host (task_t task, report_t report, gvm_host_t *gvm_host)
locations = g_string_new("");

insert_report_host_detail (global_current_report, ip, "cve", cve,
"CVE Scanner", "App", app);
"CVE Scanner", "App", app, NULL);

init_app_locations_iterator (&locations_iter, report_host, app);

Expand All @@ -2957,16 +2957,16 @@ cve_scan_host (task_t task, report_t report, gvm_host_t *gvm_host)
g_string_append (locations, location);

insert_report_host_detail (report, ip, "cve", cve,
"CVE Scanner", app, location);
"CVE Scanner", app, location, NULL);

insert_report_host_detail (report, ip, "cve", cve,
"CVE Scanner", "detected_at",
location);
location, NULL);

insert_report_host_detail (report, ip, "cve", cve,
"CVE Scanner", "detected_by",
/* Detected by itself. */
cve);
cve, NULL);
}

desc = g_strdup_printf ("The host carries the product: %s\n"
Expand Down Expand Up @@ -3010,26 +3010,29 @@ cve_scan_host (task_t task, report_t report, gvm_host_t *gvm_host)
hostname = report_host_hostname (report_host);
if (hostname) {
insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "hostname", hostname);
"CVE Scanner", "hostname", hostname,
NULL);
g_free(hostname);
}

best = report_host_best_os_cpe (report_host);
if (best) {
insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "best_os_cpe", best);
"CVE Scanner", "best_os_cpe", best,
NULL);
g_free(best);
}

best = report_host_best_os_txt (report_host);
if (best) {
insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "best_os_txt", best);
"CVE Scanner", "best_os_txt", best,
NULL);
g_free(best);
}

insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "CVE Scan", "1");
"CVE Scanner", "CVE Scan", "1", NULL);
update_report_modification_time (report);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/manage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,8 @@ make_result (task_t, const char*, const char*, const char*, const char*,

result_t
make_osp_result (task_t, const char*, const char*, const char*, const char*,
const char *, const char *, const char *, int, const char*);
const char *, const char *, const char *, int, const char*,
const char *);

result_t
make_cve_result (task_t, const char*, const char*, double, const char*);
Expand Down Expand Up @@ -1234,7 +1235,8 @@ host_detail_free (host_detail_t *);

void
insert_report_host_detail (report_t, const char *, const char *, const char *,
const char *, const char *, const char *);
const char *, const char *, const char *,
const char *);

int
manage_report_host_detail (report_t, const char *, const char *);
Expand Down
65 changes: 65 additions & 0 deletions src/manage_migrators.c
Original file line number Diff line number Diff line change
Expand Up @@ -2996,6 +2996,69 @@ migrate_250_to_251 ()
return 0;
}

/**
* @brief Migrate the database from version 251 to version 252.
*
* @return 0 success, -1 error.
*/
int
migrate_251_to_252 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 251. */

if (manage_db_version () != 251)
{
sql_rollback ();
return -1;
}

/* Update the database. */

sql ("ALTER TABLE IF EXISTS results ADD COLUMN hash_value text;");

/* Set the database version to 252. */

set_db_version (252);

sql_commit ();

return 0;
}

/**
* @brief Migrate the database from version 252 to version 253.
*
* @return 0 success, -1 error.
*/
int
migrate_252_to_253 ()
{
sql_begin_immediate ();

/* Ensure that the database is currently version 252. */

if (manage_db_version () != 252)
{
sql_rollback ();
return -1;
}

/* Update the database. */

sql ("ALTER TABLE IF EXISTS report_host_details ADD COLUMN hash_value text;");

/* Set the database version to 253. */

set_db_version (253);

sql_commit ();

return 0;
}


#undef UPDATE_DASHBOARD_SETTINGS

/**
Expand Down Expand Up @@ -3053,6 +3116,8 @@ static migrator_t database_migrators[] = {
{249, migrate_248_to_249},
{250, migrate_249_to_250},
{251, migrate_250_to_251},
{252, migrate_251_to_252},
{253, migrate_252_to_253},
/* End marker. */
{-1, NULL}};

Expand Down
Loading

0 comments on commit 9c0878d

Please sign in to comment.