SonarQube
Overview
This installation happens on the
dsb-hub
.
According to SonarQube's Website, SonarQube is an open-source platform used to continuously inspect the quality of code in various programming languages. It is designed to detect bugs, security vulnerabilities, and code smells, providing detailed reports to help developers maintain high standards in their codebases. SonarQube is widely used in DevSecOps environments to ensure that code remains secure, maintainable, and follows industry best practices.
Prerequisites
Note: This installation uses PostgreSQL 16.6 (Ubuntu 16.6-0ubuntu0.24.04.1)
-
Switch to the PostgreSQL User
First, switch to thepostgres
user to perform database-related tasks:sudo -i -u postgres
-
Create a Database and User for SonarQube
While logged in as thepostgres
user, create a new PostgreSQL user and database for SonarQube:# Create the sonar user and database
createuser sonar
createdb sonar -
Set Password and Grant Privileges
Still as thepostgres
user, start the PostgreSQL session. Set a password for thesonar
user and grant the necessary privileges:# Start the PostgreSQL session
psql
# Set password for sonar user
ALTER USER sonar WITH ENCRYPTED PASSWORD 'your_password';
# Grant initial database privileges
GRANT ALL PRIVILEGES ON DATABASE sonar TO sonar;
# Connect to the sonar database to grant schema privileges
\c sonar
# Grant all necessary schema privileges
GRANT ALL ON SCHEMA public TO sonar;
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO sonar;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO sonar;
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO sonar;
GRANT USAGE ON SCHEMA public TO sonar;
GRANT CREATE ON SCHEMA public TO sonar; -
Exit PostgreSQL and Return to the Original User
Exit from the PostgreSQL session return to the original user:# Exit PostgreSQL session
\q
# Return to the original user
exit