DefectDojo / godojo

Golang installer for DefectDojo
GNU General Public License v3.0
25 stars 22 forks source link

check if db user already exists #93

Closed dandersonsw closed 2 months ago

dandersonsw commented 2 months ago

This solves an issue where if the user already exists then the code will fail on trying to create the user. This allows skipping the user creation piece and moving on with the code rather than erroring out.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

dryrunsecurity[bot] commented 2 months ago

DryRun Security Summary

The pull request focuses on improving the database setup and configuration for the DefectDojo application, including handling existing users and databases, granting appropriate privileges, and enhancing logging and error handling to ensure a more robust and secure deployment.

Expand for full summary
**Summary:** The code changes in this pull request are focused on improving the database setup and configuration for the DefectDojo application. The key changes include: 1. Ensuring the database user for DefectDojo is created with the `IF NOT EXISTS` clause to prevent errors if the user already exists. 2. Handling the scenario where the existing database user already exists, raising a notice and skipping the creation step instead of throwing an error. 3. Providing the ability to drop and recreate the existing DefectDojo database based on the configuration setting `Install.DB.Drop`. 4. Granting the appropriate privileges to the DefectDojo database user, allowing it to access the database. 5. Improving logging and error handling to provide better feedback during the database setup process. From an application security perspective, these changes are focused on ensuring a robust and reliable database setup process for the DefectDojo application. The handling of existing users and databases, as well as the privilege management, are important security considerations to prevent potential issues during the installation and setup of the application. Overall, the changes appear to be aimed at improving the database setup process and ensuring a more reliable and secure deployment of the DefectDojo application. **Files Changed:** - `cmd/database.go`: This file contains the code changes related to the database setup and configuration for the DefectDojo application. The changes ensure a more reliable and secure database setup process by handling existing users and databases, granting appropriate privileges, and improving logging and error handling.

Code Analysis

We ran 9 analyzers against 1 file and 1 analyzer had findings. 8 analyzers had no findings.

Analyzer Findings
Authn/Authz Analyzer 2 findings

Riskiness

:green_circle: Risk threshold not exceeded.

View PR in the DryRun Dashboard.