greenbone / pg-gvm

Greenbone Library for helper functions in PostgreSQL
GNU General Public License v3.0
7 stars 15 forks source link

Extension "pg-gvm" has no installation script nor update path for version "1.1" #39

Closed heywoodlh closed 2 years ago

heywoodlh commented 2 years ago

Trying to run the docker-compose.yml exactly as outlined here: Greenbone Community Containers

I run into this error:

postgres@postgres ERROR:  extension "pg-gvm" has no installation script nor update path for version "1.1"

Running CREATE EXTENSION "pg-gvm"; from within the container creates the same error message.

Any suggestions on how to fix this?

timopollmeier commented 2 years ago

It looks like the automatic release broke the versioning. I'll fix it and replace the broken release.

simonjiri commented 2 years ago

there is workaround cp /usr/share/postgresql/11/extension/pg-gvm--22.4.1.sql /usr/share/postgresql/11/extension/pg-gvm--1.1.sql or change version in /usr/share/postgresql/11/extension/pg-gvm.control

Jirka

timopollmeier commented 2 years ago

I've updated the versions in the extension files and created the 22.4 release again now.

simonjiri commented 2 years ago

thank you, I can confirm, it is solved now.

Jirka

timopollmeier commented 2 years ago

Sorry for the trouble, but I had to change the version number again from 22.4 to 22.4.0, but issues with the old version number can probably be fixed by removing the extension and reinstalling the updated release.

sagar98cyber commented 9 months ago

there is workaround cp /usr/share/postgresql/11/extension/pg-gvm--22.4.1.sql /usr/share/postgresql/11/extension/pg-gvm--1.1.sql or change version in /usr/share/postgresql/11/extension/pg-gvm.control

Jirka

What if the .control file doesn't exist?

image

PS I am using the version 16.1 as you can see above.

secdoc commented 9 months ago

I have the same issue within a clean/new install of kali 2023.4 6.5.0-kali3-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.5.6-1kali1 (2023-10-09) x86_64 GNU/Linux

I get the follwoing when trying to run the gvm-setup:

┌──(secdoc㉿kali-vulnerability-kvm)-[~]
└─$ sudo gvm-setup

[>] Starting PostgreSQL service

[>] Creating GVM's certificate files

[>] Creating PostgreSQL database
[i] User _gvm already exists in PostgreSQL
[i] Database gvmd already exists in PostgreSQL
[i] Role DBA already exists in PostgreSQL

[*] Applying permissions
NOTICE:  role "_gvm" has already been granted membership in role "dba" by role "postgres"
GRANT ROLE
[i] Extension uuid-ossp already exists for gvmd database
[i] Extension pgcrypto already exists for gvmd database
[i] Remove old parts from DB for new pg-gvm extension
NOTICE:  view "result_new_severities_dynamic" does not exist, skipping
NOTICE:  view "result_new_severities" does not exist, skipping
NOTICE:  view "result_new_severities_static" does not exist, skipping
NOTICE:  view "result_overrides" does not exist, skipping
NOTICE:  function hosts_contains() does not exist, skipping
NOTICE:  function max_hosts() does not exist, skipping
NOTICE:  function regexp() does not exist, skipping

[*] Creating extension pg-gvm
ERROR:  extension "pg-gvm" is not available
DETAIL:  Could not open extension control file "/usr/share/postgresql/16/extension/pg-gvm.control": No such file or directory.
HINT:  The extension must first be installed on the system where PostgreSQL is running.
[>] Migrating database
md manage-Message: 13:54:26.838: db_extension_available: Extension 'pg-gvm' is not available.

(gvmd:25460): md manage-WARNING **: 13:54:26.838: check_db_extensions: A required extension is not available.

(gvmd:25460): md manage-WARNING **: 13:54:26.838: init_manage_create_functions: failed to create functions
[>] Checking for GVM admin user
[*] Creating user admin for gvm
[*] Please note the generated admin password
[*] 
[*] Configure Feed Import Owner
ERROR:  relation "settings" does not exist
LINE 1: SELECT value FROM settings WHERE uuid = '78eceaec-3385-11ea-...
                          ^
[*] Define Feed Import Owner

(gvmd:25479): md   main-CRITICAL **: 13:54:26.969: gvmd: g_option_context_parse: Missing argument for --value
[*] Update GVM feeds
Running as root. Switching to user '_gvm' and group '_gvm'.
Trying to acquire lock on /var/lib/openvas/feed-update.lock
Acquired lock on /var/lib/openvas/feed-update.lock
⠋ Downloading Notus files from rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/vt-data/notus/ to /var/lib/notus
⠦ Downloading NASL files from rsync://feed.community.greenbone.net/community/vulnerability-feed/22.04/vt-data/nasl/ to /var/lib/openvas/plugins
Releasing lock on /var/lib/openvas/feed-update.lock
[*] Checking Default scanner
[*] Modifying Default Scanner

[+] Done
[i] Admin user already exists for GVM
[i] If you have forgotten it, you can change it. See gvmd manpage for more information

[>] You can now run gvm-check-setup to make sure everything is correctly configured

┌──(secdoc㉿kali-vulnerability-kvm)-[~]
└─$ sudo gvm-check-setup
gvm-check-setup 23.11.0
  Test completeness and readiness of GVM-23.11.0
Step 1: Checking OpenVAS (Scanner)... 
        OK: OpenVAS Scanner is present in version 22.7.7.
        OK: Notus Scanner is present in version 22.6.2.
        OK: Server CA Certificate is present as /var/lib/gvm/CA/servercert.pem.
Checking permissions of /var/lib/openvas/gnupg/*
        OK: _gvm owns all files in /var/lib/openvas/gnupg
        OK: redis-server is present.
        OK: scanner (db_address setting) is configured properly using the redis-server socket: /var/run/redis-openvas/redis-server.sock
        OK: the mqtt_server_uri is defined in /etc/openvas/openvas.conf
        OK: _gvm owns all files in /var/lib/openvas/plugins
        OK: NVT collection in /var/lib/openvas/plugins contains 87639 NVTs.
        OK: The notus directory /var/lib/notus/products contains 451 NVTs.
Checking that the obsolete redis database has been removed
Could not connect to Redis at /var/run/redis-openvas/redis-server.sock: No such file or directory
        OK: No old Redis DB
        Starting ospd-openvas service
        Waiting for ospd-openvas service
        OK: ospd-openvas service is active.
        OK: ospd-OpenVAS is present in version 22.6.2.                                                                                                    
Step 2: Checking GVMD Manager ...                                                                                                                         
        OK: GVM Manager (gvmd) is present in version 23.1.0.                                                                                              
Step 3: Checking Certificates ...                                                                                                                         
        OK: GVM client certificate is valid and present as /var/lib/gvm/CA/clientcert.pem.                                                                
        OK: Your GVM certificate infrastructure passed validation.                                                                                        
Step 4: Checking data ...                                                                                                                                 
        OK: SCAP data found in /var/lib/gvm/scap-data.                                                                                                    
        ERROR: CERT data are missing.                                                                                                                     
        FIX: Run the CERT synchronization script greenbone-feed-sync.                                                                                     
        sudo greenbone-feed-sync --type cert.                                                                                                             

 ERROR: Your GVM-23.11.0 installation is not yet complete!                                                                                                

Please follow the instructions marked with FIX above and run this                                                                                         
script again. 
┌──(secdoc㉿kali-vulnerability-kvm)-[~]
└─$ sudo gvm-check-setup    
gvm-check-setup 23.11.0
  Test completeness and readiness of GVM-23.11.0
Step 1: Checking OpenVAS (Scanner)... 
        OK: OpenVAS Scanner is present in version 22.7.7.
        OK: Notus Scanner is present in version 22.6.2.
        OK: Server CA Certificate is present as /var/lib/gvm/CA/servercert.pem.
Checking permissions of /var/lib/openvas/gnupg/*
        OK: _gvm owns all files in /var/lib/openvas/gnupg
        OK: redis-server is present.
        OK: scanner (db_address setting) is configured properly using the redis-server socket: /var/run/redis-openvas/redis-server.sock
        OK: the mqtt_server_uri is defined in /etc/openvas/openvas.conf
        OK: _gvm owns all files in /var/lib/openvas/plugins
        OK: NVT collection in /var/lib/openvas/plugins contains 87639 NVTs.
        OK: The notus directory /var/lib/notus/products contains 451 NVTs.
Checking that the obsolete redis database has been removed
        OK: No old Redis DB
        OK: ospd-openvas service is active.
        OK: ospd-OpenVAS is present in version 22.6.2.
Step 2: Checking GVMD Manager ... 
        OK: GVM Manager (gvmd) is present in version 23.1.0.
Step 3: Checking Certificates ... 
        OK: GVM client certificate is valid and present as /var/lib/gvm/CA/clientcert.pem.
        OK: Your GVM certificate infrastructure passed validation.
Step 4: Checking data ... 
        OK: SCAP data found in /var/lib/gvm/scap-data.
        OK: CERT data found in /var/lib/gvm/cert-data.
Step 5: Checking Postgresql DB and user ... 
        OK: Postgresql version and default port are OK.
 gvmd      | _gvm     | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |            |           | 
        ERROR: The new extension pgcrypto does not exist for gvmd database
        FIX: Run 'sudo runuser -u postgres -- /usr/share/gvm/create-postgresql-database'

 ERROR: Your GVM-23.11.0 installation is not yet complete!

Please follow the instructions marked with FIX above and run this
script again.

┌──(secdoc㉿kali-vulnerability-kvm)-[~]
└─$ sudo runuser -u postgres -- /usr/share/gvm/create-postgresql-database
[sudo] password for secdoc: 
[i] User _gvm already exists in PostgreSQL
[i] Database gvmd already exists in PostgreSQL
[i] Role DBA already exists in PostgreSQL

[*] Applying permissions
NOTICE:  role "_gvm" has already been granted membership in role "dba" by role "postgres"
GRANT ROLE
[i] Extension uuid-ossp already exists for gvmd database
[i] Extension pgcrypto already exists for gvmd database
[i] Remove old parts from DB for new pg-gvm extension
NOTICE:  view "result_new_severities_dynamic" does not exist, skipping
NOTICE:  view "result_new_severities" does not exist, skipping
NOTICE:  view "result_new_severities_static" does not exist, skipping
NOTICE:  view "result_overrides" does not exist, skipping
NOTICE:  function hosts_contains() does not exist, skipping
NOTICE:  function max_hosts() does not exist, skipping
NOTICE:  function regexp() does not exist, skipping

[*] Creating extension pg-gvm
ERROR:  extension "pg-gvm" is not available
DETAIL:  Could not open extension control file "/usr/share/postgresql/16/extension/pg-gvm.control": No such file or directory.
HINT:  The extension must first be installed on the system where PostgreSQL is running.
bjoernricks commented 9 months ago

@sagar98cyber @secdoc your problem is a packaging issue with Kali and not an issue with pg-gvm itself. It is not really related to the initial issue. Please ensure that the postgresql-16-pg-gvm package is installed which contains the /usr/share/postgresql/16/extension/pg-gvm.control file.