Skip to content

MSSQL Fix Test#4382

Merged
rathimayur merged 3 commits into
masterfrom
MSSQL-Alert-Fix
Dec 15, 2025
Merged

MSSQL Fix Test#4382
rathimayur merged 3 commits into
masterfrom
MSSQL-Alert-Fix

Conversation

@rathimayur

@rathimayur rathimayur commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Description

Type of Change

  • Bug fix - [ ] New feature - [ ] Breaking change - [ ] Plugin update

Checklist

  • PR description clearly describes the changes
  • Target branch is correct (master for features, Releases/* for fixes)
  • Latest code from target branch merged
  • No commented/junk code included
  • No new build warnings or errors
  • All existing unit tests pass
  • New unit tests added for new functionality
  • Cross-platform compatibility verified (Windows/Linux/macOS)
  • CI/CD pipeline passes
  • Code follows project conventions (Act{Platform}{Type}, {Platform}Driver)
  • Repository objects use [IsSerializedForLocalRepository] where needed
  • Error handling uses Reporter.ToLog() pattern
  • Documentation updated for user-facing changes
  • Self-review completed and code review comments addressed

Summary by CodeRabbit

  • Refactor
    • Encapsulated MSSQL connection-string construction and standardized connection initialization across database types. Connection strings are now normalized and placeholders, credentials (including decrypted passwords) and catalog/source values are resolved consistently for MSSQL, PostgreSQL, MySQL, MongoDB, Cosmos DB and Cassandra. Minor formatting and validation standardization applied. Public APIs and signatures remain unchanged.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Centralized 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

Cohort / File(s) Change Summary
Database connection string refactor
Ginger/GingerCoreNET/Database/DatabaseOperations.cs
Added private GetMSSQLConnectionStringBuilder and switched MSSQL paths in CreateConnectionString/Connect to use it; consolidated builder usage and placeholder/password decryption logic across multiple DB-type branches; minor formatting and reordering.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Review focus:
    • GetMSSQLConnectionStringBuilder branches (build-from-credentials vs parse-existing)
    • Correctness of placeholder replacement and password decryption
    • Behavioral parity across per-DB-type connection-string paths

Possibly related PRs

Suggested reviewers

  • ravirk91

Poem

🐇 I hop through strings both long and neat,

Builders hummed till connections meet.
Secrets unwrapped and placeholders sewn,
Databases answered — seeds well sown.
A tiny rabbit cheers the refactored feat! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete with all checklist items unchecked and the description section empty, providing no context about the changes made. Fill in the Description section with details about the changes, select the appropriate Type of Change, and check off completed checklist items to provide proper documentation.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'MSSQL Fix Test' is vague and overly generic, using non-descriptive terminology that doesn't convey the specific nature of the refactoring changes. Replace with a more descriptive title that clearly indicates the main change, such as 'Refactor MSSQL connection string construction' or 'Extract MSSQL connection builder to dedicated method'.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch MSSQL-Alert-Fix

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7ba3098 and f7211b5.

📒 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 UserCalculated and decrypted PassCalculated directly is cleaner than placeholder substitution. However, line 457 still stores the resolved connection string (with plain-text password) in Database.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.ConnectionString mutation concern applies here as well.

Comment thread Ginger/GingerCoreNET/Database/DatabaseOperations.cs
Comment thread Ginger/GingerCoreNET/Database/DatabaseOperations.cs Outdated
coderabbitai[bot]
coderabbitai Bot previously approved these changes Dec 15, 2025
Comment thread Ginger/GingerCoreNET/Database/DatabaseOperations.cs Fixed
coderabbitai[bot]
coderabbitai Bot previously approved these changes Dec 15, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, but CreateConnectionString() 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 in Database.ConnectionString.

Lines 432-433 now pass the decrypted password directly to the builder, and line 436 assigns pg.ConnectionString (containing the plaintext password) to Database.ConnectionString. This mirrors the concern raised in a previous review: if Database is 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 in Database.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 if Database is 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

📥 Commits

Reviewing files that changed from the base of the PR and between b680dfd and 04e16b1.

📒 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)

Comment thread Ginger/GingerCoreNET/Database/DatabaseOperations.cs
Comment thread Ginger/GingerCoreNET/Database/DatabaseOperations.cs
@rathimayur
rathimayur merged commit 19c2958 into master Dec 15, 2025
14 checks passed
@rathimayur
rathimayur deleted the MSSQL-Alert-Fix branch December 15, 2025 13:56
@coderabbitai coderabbitai Bot mentioned this pull request Dec 16, 2025
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants