Skip to content

Commit db5d72b

Browse files
committed
chore: reduce DevSkim false positives and fix Azure SQL bulkcopy test
- Exclude tests/, **/test_*.py, and benchmarks/ from DevSkim scanning (localhost in test connection strings is not debug code) - Suppress DS176209 (TODO comments) — informational, not a security concern - DS137138 (localhost) left enabled — path exclusions handle test files, keeps coverage for accidental localhost in production code - Fix test_bulkcopy_without_database_parameter: remove USE statement which is not supported on Azure SQL Database, use fully qualified table names with the default database instead
1 parent acbe020 commit db5d72b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

.github/workflows/devskim.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727

2828
- name: Run DevSkim scanner
2929
uses: microsoft/DevSkim-Action@v1
30+
with:
31+
ignore_globs: "tests/**,**/test_*.py,benchmarks/**"
32+
# DS176209: TODO comments — not a security concern
33+
ignore_rules_list: "DS176209"
3034

3135
- name: Upload DevSkim scan results to GitHub Security tab
3236
uses: github/codeql-action/upload-sarif@v3

tests/test_019_bulkcopy.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def test_bulkcopy_without_database_parameter(conn_str):
119119
current_db = cursor.fetchone()[0]
120120
assert current_db is not None, "Should be connected to a database"
121121

122-
# If original database was specified, switch to it to ensure we have permissions
123-
if original_database:
124-
cursor.execute(f"USE [{original_database}]")
122+
# Use the original database or the default one for fully qualified names.
123+
# We do NOT issue a USE statement because Azure SQL Database does not
124+
# support switching databases on an existing connection.
125+
effective_database = original_database if original_database else current_db
125126

126127
# Create test table in the current database
127128
table_name = "mssql_python_bulkcopy_no_db_test"
@@ -138,10 +139,7 @@ def test_bulkcopy_without_database_parameter(conn_str):
138139

139140
# Perform bulkcopy - this should NOT raise ValueError about missing DATABASE
140141
# Note: bulkcopy creates its own connection, so we need to use fully qualified table name
141-
# if we had a database in the original connection string
142-
bulkcopy_table_name = (
143-
f"[{original_database}].[dbo].{table_name}" if original_database else table_name
144-
)
142+
bulkcopy_table_name = f"[{effective_database}].[dbo].{table_name}"
145143
result = cursor.bulkcopy(bulkcopy_table_name, data, timeout=60)
146144

147145
# Verify result

0 commit comments

Comments
 (0)