Closed fcolista closed 4 years ago
I've enabled postgresql log, the last query done is:
2019-10-17 13:32:06.603 UTC [7019] LOG: execute <unnamed>: CREATE OR REPLACE FUNCTION order_threat (text) RETURNS integer AS $$ BEGIN IF $1 = 'High' THEN RETURN 1; ELSIF $1 = 'Medium' THEN RETURN 2; ELSIF $1 = 'Low' THEN RETURN 3; ELSIF $1 = 'Log' THEN RETURN 4; ELSIF $1 = 'Debug' THEN RETURN 5; ELSIF $1 = 'False Positive' THEN RETURN 6; ELSIF $1 = 'None' THEN RETURN 7; ELSE RETURN 8; END IF; END;$$ LANGUAGE plpgsql IMMUTABLE;
Looking at manage_pg.c file
, on lines 905-927
, this is the last query run:
sql ("CREATE OR REPLACE FUNCTION order_threat (text)"
" RETURNS integer AS $$"
" BEGIN"
" IF $1 = 'High' THEN"
" RETURN 1;"
" ELSIF $1 = 'Medium' THEN"
" RETURN 2;"
" ELSIF $1 = 'Low' THEN"
" RETURN 3;"
" ELSIF $1 = 'Log' THEN"
" RETURN 4;"
" ELSIF $1 = 'Debug' THEN"
" RETURN 5;"
" ELSIF $1 = 'False Positive' THEN"
" RETURN 6;"
" ELSIF $1 = 'None' THEN"
" RETURN 7;"
" ELSE"
" RETURN 8;"
" END IF;"
" END;"
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");
If I try to ran by hand, no issues are returned.
The next one (which appears to be the one giving sql: (null)
result, is:
sql ("CREATE OR REPLACE FUNCTION severity_to_type (double precision)"
" RETURNS text AS $$"
" BEGIN"
" IF $1 IS NULL THEN"
" RETURN NULL;"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_LOG) " THEN"
" RETURN 'Log Message';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_FP) " THEN"
" RETURN 'False Positive';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_DEBUG) " THEN"
" RETURN 'Debug Message';"
" ELSIF $1 = " G_STRINGIFY (SEVERITY_ERROR) " THEN"
" RETURN 'Error Message';"
" ELSIF $1 > 0.0 AND $1 <= 10.0 THEN"
" RETURN 'Alarm';"
" ELSE"
" RAISE EXCEPTION 'Invalid severity score given: %', $1;"
" END IF;"
" END;"
"$$ LANGUAGE plpgsql"
" IMMUTABLE;");
But also this query, if ran by "hand", it works nicely.
openvas:~$ psql gvmd
psql (12.0)
Type "help" for help.
gvmd=> CREATE OR REPLACE FUNCTION severity_to_type (double precision)
gvmd-> RETURNS text AS $$
gvmd$> BEGIN
gvmd$> IF $1 IS NULL THEN
gvmd$> RETURN NULL;
gvmd$> ELSIF $1 = " G_STRINGIFY (SEVERITY_LOG) " THEN
gvmd$> RETURN 'Log Message';
gvmd$> ELSIF $1 = " G_STRINGIFY (SEVERITY_FP) " THEN
gvmd$> RETURN 'False Positive';
gvmd$> ELSIF $1 = " G_STRINGIFY (SEVERITY_DEBUG) " THEN
gvmd$> RETURN 'Debug Message';
gvmd$> ELSIF $1 = " G_STRINGIFY (SEVERITY_ERROR) " THEN
gvmd$> RETURN 'Error Message';
gvmd$> ELSIF $1 > 0.0 AND $1 <= 10.0 THEN
gvmd$> RETURN 'Alarm';
gvmd$> ELSE
gvmd$> RAISE EXCEPTION 'Invalid severity score given: %', $1;
gvmd$> END IF;
gvmd$> END;
gvmd$> $$ LANGUAGE plpgsql IMMUTABLE;
CREATE FUNCTION
.: Francesco
Fix was merged in #818 , closing.
Expected behavior
gvmd postgresql database should be initialized
Current behavior
Database is not initalized, gvmd crashes See the logfile section for further info.
Steps to reproduce
GVM versions
gsa: (gsad --version) Greenbone Security Assistant 9.0
gvm: (gvmd --version) Greenbone Vulnerability Manager 9.0.0 Manager DB revision 221 Copyright (C) 2010-2017 Greenbone Networks GmbH License GPLv2+: GNU GPL version 2 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
openvas-scanner: (openvassd --version) OpenVAS 7.0.0 Most new code since 2005: (C) 2019 Greenbone Networks GmbH Nessus origin: (C) 2004 Renaud Deraison deraison@nessus.org License GPLv2: GNU GPL version 2 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
gvm-libs: gvm-libs-11.0.0 openvas-smb:
Environment
Alpine Linux edge (with musl libc)
Installation method / source: (packages, source installation) Source
Logfiles
.: Francesco