Skip to content

Conversation

@subrata-ms
Copy link
Contributor

@subrata-ms subrata-ms commented Dec 11, 2025

Work Item / Issue Reference

[AB#40951

GitHub Issue: #<ISSUE_NUMBER>


Summary

This pull request updates several test files to improve security and consistency in database connection strings. The main change is replacing hardcoded usernames and passwords with Trusted_Connection=yes in all connection strings, and in some cases, using environment variables for server and database names. This prevents the exposure of credentials and avoids related security warnings.

Test connection string improvements:

These changes make the test suite safer to run in different environments and prevent accidental credential leaks.

@github-actions github-actions bot added the pr-size: small Minimal code update label Dec 11, 2025
@github-actions
Copy link

github-actions bot commented Dec 11, 2025

📊 Code Coverage Report

🔥 Diff Coverage

100%


🎯 Overall Coverage

75%


📈 Total Lines Covered: 5255 out of 7003
📁 Project: mssql-python


Diff Coverage

Diff: main...HEAD, staged and unstaged changes

No lines with coverage information in this diff.


📋 Files Needing Attention

📉 Files with overall lowest coverage (click to expand)
mssql_python.pybind.logger_bridge.hpp: 58.8%
mssql_python.pybind.logger_bridge.cpp: 59.2%
mssql_python.row.py: 66.2%
mssql_python.pybind.ddbc_bindings.cpp: 66.3%
mssql_python.helpers.py: 67.5%
mssql_python.pybind.connection.connection.cpp: 73.6%
mssql_python.ddbc_bindings.py: 79.6%
mssql_python.connection.py: 83.7%
mssql_python.cursor.py: 84.3%
mssql_python.logging.py: 85.3%

🔗 Quick Links

⚙️ Build Summary 📋 Coverage Details

View Azure DevOps Build

Browse Full Coverage Report

@subrata-ms subrata-ms marked this pull request as ready for review December 11, 2025 11:26
Copilot AI review requested due to automatic review settings December 11, 2025 11:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a security issue (SEC101/037: SQLLegacyCredentials) by removing hardcoded credentials from test connection strings. The fix replaces UID and PWD parameters with Trusted_Connection=yes across multiple test files and introduces environment variable usage for server and database names in select tests.

Key changes:

  • Removed all hardcoded username/password credentials from test connection strings
  • Replaced credential parameters with Trusted_Connection=yes for Windows authentication
  • Added environment variable support (TEST_SERVER, TEST_DATABASE) in one test function to enable configurable test environments

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_002_types.py Updated three connection strings in test_invalid_surrogate_handling() to use Trusted_Connection=yes and added environment variable support for server/database names with os.getenv()
tests/test_013_sqlwchar_conversions.py Systematically replaced all hardcoded UID=user;PWD=pass with Trusted_Connection=yes across 21 connection strings in various test methods
tests/test_014_ddbc_bindings_coverage.py Replaced all hardcoded UID=u;PWD=p with Trusted_Connection=yes across 12 connection strings in various test methods

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-size: small Minimal code update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants