"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/manage_sql_nvts.c" between
gvmd-21.4.2.tar.gz and gvmd-21.4.3.tar.gz

About: OpenVAS Greenbone Vulnerability Manager is a layer between OpenVAS-Scanner and various client applications such as OpenVAS-Client or Greenbone Security Assistant. Among other features, it adds server-side storage of scan results and it makes it unnecessary for scan clients to keep connection until a scan finishes.

manage_sql_nvts.c  (gvmd-21.4.2):manage_sql_nvts.c  (gvmd-21.4.3)
skipping to change at line 1593 skipping to change at line 1593
* - the OID * - the OID
* - the modification time as seconds since epoch * - the modification time as seconds since epoch
* - the preferences sorted as strings(!) and concatenated including: * - the preferences sorted as strings(!) and concatenated including:
* - the id * - the id
* - the name * - the name
* - the default value (including choices for the "radio" type) * - the default value (including choices for the "radio" type)
* *
* All values are concatenated without a separator. * All values are concatenated without a separator.
*/ */
db_vts_hash db_vts_hash
= sql_string ("WITH pref_str AS (" = sql_string ("SELECT encode ("
" SELECT name," " digest (vts_verification_str (), 'SHA256'),"
" substring(name, '^(.*?):') AS oid," " 'hex'"
" substring (name, '^.*?:([^:]+):') AS pref_id," " );");
" (substring (name, '^.*?:([^:]+):')"
" || substring (name,"
" '^[^:]*:[^:]*:[^:]*:(.*)')"
" || value) AS pref"
" FROM nvt_preferences"
" ),"
" nvt_str AS ("
" SELECT (SELECT nvts.oid"
" || max(modification_time)"
" || coalesce (string_agg(pref_str.pref, ''"
" ORDER BY pref_id),"
" ''))"
" AS vt_string"
" FROM nvts"
" LEFT JOIN pref_str ON nvts.oid = pref_str.oid"
" GROUP BY nvts.oid"
" ORDER BY nvts.oid ASC"
" )"
" SELECT encode"
" (digest"
" (coalesce (string_agg (nvt_str.vt_string, ''),
"
" ''),"
" 'sha256'),"
" 'hex')"
" FROM nvt_str;");
if (strcmp (osp_vt_hash, db_vts_hash ? db_vts_hash : "")) if (strcmp (osp_vt_hash, db_vts_hash ? db_vts_hash : ""))
{ {
g_warning ("%s: SHA-256 hash of the VTs in the database (%s)" g_warning ("%s: SHA-256 hash of the VTs in the database (%s)"
" does not match the one from the scanner (%s).", " does not match the one from the scanner (%s).",
__func__, db_vts_hash, osp_vt_hash); __func__, db_vts_hash, osp_vt_hash);
g_free (db_vts_hash); g_free (db_vts_hash);
return 1; return 1;
} }
skipping to change at line 2223 skipping to change at line 2198
if (ret) if (ret)
sql_rollback (); sql_rollback ();
else else
sql_commit (); sql_commit ();
feed_lockfile_unlock (&lockfile); feed_lockfile_unlock (&lockfile);
manage_option_cleanup (); manage_option_cleanup ();
return ret; return ret;
} }
/**
* @brief Dump the string used to calculate the VTs verification hash
* to stdout.
*
* @param[in] log_config Log configuration.
* @param[in] database Location of manage database.
*
* @return 0 success, -1 error, -2 database is wrong version,
* -3 database needs to be initialised from server, -5 sync active.
*/
int
manage_dump_vt_verification (GSList *log_config,
const db_conn_info_t *database)
{
int ret;
static lockfile_t lockfile;
char *verification_str;
switch (feed_lockfile_lock_timeout (&lockfile))
{
case 1:
printf ("A feed sync is already running.\n");
return -5;
case -1:
printf ("Error getting sync lock.\n");
return -1;
}
ret = manage_option_setup (log_config, database);
if (ret)
{
feed_lockfile_unlock (&lockfile);
return ret;
}
verification_str = sql_string ("SELECT vts_verification_str ();");
printf ("%s\n", verification_str);
feed_lockfile_unlock (&lockfile);
manage_option_cleanup ();
return 0;
}
 End of changes. 2 change blocks. 
30 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)