MSSQL Fix Test#4382
Conversation
WalkthroughCentralized MSSQL connection-string construction into a GetMSSQLConnectionStringBuilder helper and updated CreateConnectionString/Connect to use it; normalized connection-string/credential/placeholder/decryption handling across MSSQL, PostgreSQL, MySQL, MongoDB, CosmosDB, Cassandra, and Couchbase. Public signatures unchanged. (48 words) Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Ginger/GingerCoreNET/Database/DatabaseOperations.cs(7 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use
Reporter.ToLog(eLogLevel.ERROR, message)for logging errors
Files:
Ginger/GingerCoreNET/Database/DatabaseOperations.cs
🧠 Learnings (2)
📓 Common learnings
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4286
File: Ginger/GingerCoreNET/External/ZAP/ZapProxyService.cs:287-309
Timestamp: 2025-08-29T09:35:46.020Z
Learning: In Ginger ZAP security testing, alert names should preserve their original formatting with spaces and hyphens. When comparing alert names in EvaluateScanResultAPI and similar methods, use StringComparison.OrdinalIgnoreCase for case-insensitive matching but do not normalize by removing spaces or hyphens, as alert names like "False Positive" need to remain as separate words. Confirmed by AmanPrasad43 in PR #4286.
📚 Learning: 2024-11-29T07:45:52.303Z
Learnt from: GokulBothe99
Repo: Ginger-Automation/Ginger PR: 4011
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:102-105
Timestamp: 2024-11-29T07:45:52.303Z
Learning: When reviewing the password encryption implementation in `GingerCoreNET/RunLib/CLILib`, consider that the existing approach is acceptable, and changes to enhance security aspects are not required.
Applied to files:
Ginger/GingerCoreNET/Database/DatabaseOperations.cs
🔇 Additional comments (2)
Ginger/GingerCoreNET/Database/DatabaseOperations.cs (2)
449-461: Credentials resolved directly—same mutation concern applies.The change to use
UserCalculatedand decryptedPassCalculateddirectly is cleaner than placeholder substitution. However, line 457 still stores the resolved connection string (with plain-text password) inDatabase.ConnectionString.If the side-effect concern raised for MSSQL is addressed, apply the same pattern here.
503-518: LGTM—consistent with PostgreSQL changes.The MySQL credential handling now matches the PostgreSQL approach, using calculated credentials directly. The same
Database.ConnectionStringmutation concern applies here as well.
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (3)
Ginger/GingerCoreNET/Database/DatabaseOperations.cs (3)
274-285: The new helper method is not being used, leaving duplication unresolved.This code segment duplicates the exact logic now present in
GetMSSQLConnectionStringBuilder()(lines 574-580). The past review comment specifically requested extracting this duplication into a helper, which was done, butCreateConnectionString()was not updated to use it.Apply this diff to use the helper:
case eDBTypes.MSSQL: - var builder = new SqlConnectionStringBuilder - { - DataSource = TNSCalculated - }; - - if (!string.IsNullOrEmpty(Database.Name)) builder.InitialCatalog = Database.Name; - builder.IntegratedSecurity = false; - builder.UserID = UserCalculated; - builder.Password = EncryptionHandler.DecryptwithKey(PassCalculated); + var builder = GetMSSQLConnectionStringBuilder(); Database.ConnectionString = builder.ConnectionString; break;
432-433: PostgreSQL flow now stores plaintext password inDatabase.ConnectionString.Lines 432-433 now pass the decrypted password directly to the builder, and line 436 assigns
pg.ConnectionString(containing the plaintext password) toDatabase.ConnectionString. This mirrors the concern raised in a previous review: ifDatabaseis serialized or logged elsewhere, the plaintext password may be exposed.Consider using a local variable for the resolved connection string:
var pg = new NpgsqlConnectionStringBuilder { Host = postgreSQLHost, Database = Database.Name ?? string.Empty, Username = UserCalculated, Password = EncryptionHandler.DecryptwithKey(PassCalculated) }; if (port.HasValue) pg.Port = port.Value; - Database.ConnectionString = pg.ConnectionString; oConn = new NpgsqlConnection(pg.ConnectionString);Also applies to: 436-436
486-487: MySQL flow now stores plaintext password inDatabase.ConnectionString.Similar to the PostgreSQL case, lines 486-487 pass the decrypted password directly to the builder, and line 490 assigns the connection string containing the plaintext password to
Database.ConnectionString. This creates the same security exposure ifDatabaseis serialized or logged.Apply a similar fix:
var my = new MySqlConnectionStringBuilder { Server = mySQLHost, Database = Database.Name ?? string.Empty, UserID = UserCalculated, Password = EncryptionHandler.DecryptwithKey(PassCalculated) }; if (port1.HasValue) my.Port = port1.Value; - Database.ConnectionString = my.ConnectionString; oConn = new MySqlConnection { ConnectionString = my.ConnectionString };Also applies to: 490-490
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
Ginger/GingerCoreNET/Database/DatabaseOperations.cs(8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.cs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use
Reporter.ToLog(eLogLevel.ERROR, message)for logging errors
Files:
Ginger/GingerCoreNET/Database/DatabaseOperations.cs
🧠 Learnings (2)
📓 Common learnings
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4286
File: Ginger/GingerCoreNET/External/ZAP/ZapProxyService.cs:287-309
Timestamp: 2025-08-29T09:35:46.020Z
Learning: In Ginger ZAP security testing, alert names should preserve their original formatting with spaces and hyphens. When comparing alert names in EvaluateScanResultAPI and similar methods, use StringComparison.OrdinalIgnoreCase for case-insensitive matching but do not normalize by removing spaces or hyphens, as alert names like "False Positive" need to remain as separate words. Confirmed by AmanPrasad43 in PR #4286.
📚 Learning: 2024-11-29T07:45:52.303Z
Learnt from: GokulBothe99
Repo: Ginger-Automation/Ginger PR: 4011
File: Ginger/GingerCoreNET/RunLib/CLILib/DoOptionsHanlder.cs:102-105
Timestamp: 2024-11-29T07:45:52.303Z
Learning: When reviewing the password encryption implementation in `GingerCoreNET/RunLib/CLILib`, consider that the existing approach is acceptable, and changes to enhance security aspects are not required.
Applied to files:
Ginger/GingerCoreNET/Database/DatabaseOperations.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Database/DatabaseOperations.cs (1)
Ginger/GingerCoreNET/RunLib/DynamicExecutionLib/DatabaseConfigHelper.cs (1)
eDBTypes(52-69)
Description
Type of Change
Checklist
[IsSerializedForLocalRepository]where neededReporter.ToLog()patternSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.