Skip to content

Basic logging for sql sanitizer#4708

Open
dima-zakharov wants to merge 4 commits into
mainfrom
bug-4707-logging
Open

Basic logging for sql sanitizer#4708
dima-zakharov wants to merge 4 commits into
mainfrom
bug-4707-logging

Conversation

@dima-zakharov
Copy link
Copy Markdown
Contributor

@dima-zakharov dima-zakharov commented May 11, 2026

🔗 Related Issue

Closes #4707


📝 Summary

Added debug only logging for sql sanitizer


🏷️ Type of Change

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 80% make coverage

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes (optional)

Screenshots, design decisions, or additional context.

Signed-off-by: Dmitry Zakharov <zakharov@ibm.com>
@dima-zakharov dima-zakharov changed the title basic logging for sql sanitizer Basic logging for sql sanitizer May 11, 2026
ja8zyjits
ja8zyjits previously approved these changes May 12, 2026
Copy link
Copy Markdown
Member

@ja8zyjits ja8zyjits left a comment

Choose a reason for hiding this comment

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

LGTM

@ja8zyjits ja8zyjits self-assigned this May 12, 2026
Signed-off-by: Dmitry Zakharov <zakharov@ibm.com>
Signed-off-by: Dmitry Zakharov <zakharov@ibm.com>
@dima-zakharov
Copy link
Copy Markdown
Contributor Author

I updatd workflow to make it possible to see logged messages in workflow:

{"asctime": "2026-05-12T10:16:39", "name": "plugins.sql_sanitizer.sql_sanitizer", "levelname": "DEBUG", "message": "SQL-SANITIZER payload: CopyOnWriteDict({'message': 'DROP table asdf'})", "@timestamp": "2026-05-12T10:16:39.301235Z", "hostname": "runnervmeorf1", "process_id": 2956, "request_id": "26d3f66b8a834a7d96e5deaaead954a7"}

This log entry shows that plugin method was invoked with dangrouse sql: "DROP table asdf"

Signed-off-by: Dmitry Zakharov <zakharov@ibm.com>
Copy link
Copy Markdown
Member

@ja8zyjits ja8zyjits left a comment

Choose a reason for hiding this comment

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

LGTM

@dima-zakharov dima-zakharov added wxo wxo integration bug Something isn't working labels May 12, 2026
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds debug-level logging around the SQL sanitizer plugin and updates CI workflow steps to capture and inspect server logs for sanitizer-related output.

Changes:

  • Initialize a logger for sql_sanitizer and emit debug logs for plugin config and incoming payload args.
  • Update GitHub Actions workflow to run the server with log redirection and grep for sanitizer-related logs.
  • Minor import/comment cleanup and formatting change for the @field_validator decorator.

Reviewed changes

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

File Description
plugins/sql_sanitizer/sql_sanitizer.py Adds module-level logger initialization and debug logs for config/payload.
.github/workflows/sql-sanitizer.yml Enables DEBUG logging in CI, captures gunicorn output to a file, and greps for sanitizer logs.

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

Comment on lines +38 to +42
from mcpgateway.services.logging_service import LoggingService

# Initialize logging service first
logging_service = LoggingService()
logger = logging_service.get_logger(__name__)
config: Plugin configuration.
"""
super().__init__(config)
logger.debug(f"SQL-SANITIZER config: {config}")
Returns:
Result indicating SQL issues found or sanitized.
"""
logger.debug(f"SQL-SANITIZER payload: {payload.args} config: {self._cfg}")
config: Plugin configuration.
"""
super().__init__(config)
logger.debug(f"SQL-SANITIZER config: {config}")
Returns:
Result indicating SQL issues found or sanitized.
"""
logger.debug(f"SQL-SANITIZER payload: {payload.args} config: {self._cfg}")
Returns:
Result indicating SQL issues found or sanitized.
"""
logger.debug(f"SQL-SANITIZER payload: {payload.args} config: {self._cfg}")
JWT_SECRET_KEY: ${{ env.DYNAMIC_JWT_SECRET }}
ADMIN_REQUIRE_PASSWORD_CHANGE_ON_BOOTSTRAP: false
PASSWORD_CHANGE_ENFORCEMENT_ENABLED: false
LOG_LEVEL: DEBUG
make install
make stop-serve
make serve &
make serve > gunicorn.log 2>&1 &
Comment on lines +308 to 309
cat gunicorn.log | grep sql_sanitizer

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

Labels

bug Something isn't working wxo wxo integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: No logging in SQL Sanitizer plugin

4 participants