Skip to content

feat: Security Improvements (CodeQL, DAST, Log Redaction)#84

Merged
Miyamura80 merged 15 commits into
mainfrom
feat/security-improvements
Jan 26, 2026
Merged

feat: Security Improvements (CodeQL, DAST, Log Redaction)#84
Miyamura80 merged 15 commits into
mainfrom
feat/security-improvements

Conversation

@Miyamura80

Copy link
Copy Markdown
Owner

Summary

This PR implements several security enhancements identified in the Agent Readiness Report:

  1. Log Scrubbing: Implemented PII redaction (email, API keys) in src/utils/logging_config.py using loguru's patcher.
  2. Static Analysis: Added a CodeQL workflow (.github/workflows/codeql.yml) scanning Python and TypeScript.
  3. Dynamic Analysis: Added a DAST workflow (.github/workflows/dast.yml) using OWASP ZAP (manual trigger).

@github-advanced-security

Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@greptile-apps

greptile-apps Bot commented Jan 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR implements comprehensive security improvements including log scrubbing for PII redaction, CodeQL static analysis, and infrastructure for DAST scanning.

Key Changes:

  • Implemented PII redaction in logging that scrubs emails, API keys (OpenAI, Anthropic, Stripe), Bearer tokens, and generic API keys from both log messages and exception messages
  • Pre-compiled regex patterns for performance optimization
  • Exception handling properly re-instantiates exceptions with redacted messages to preserve loguru's formatting expectations
  • Added CodeQL workflow for automated security scanning of Python and TypeScript code
  • Comprehensive test coverage verifies all PII patterns are correctly redacted

Code Quality:
The implementation addresses all previously raised concerns including exception scrubbing, pattern pre-compilation, and comprehensive test coverage. The exception handling correctly preserves the exception instance structure expected by loguru by re-instantiating exceptions rather than storing strings.

Confidence Score: 5/5

  • This PR is safe to merge with comprehensive security improvements and thorough testing
  • All previously identified issues have been properly addressed: PII patterns are pre-compiled for performance, exception handling correctly re-instantiates exception objects to preserve loguru formatting, comprehensive test coverage validates all redaction patterns, and the implementation follows project coding standards
  • No files require special attention

Important Files Changed

Filename Overview
.github/workflows/codeql.yml Added CodeQL static analysis workflow scanning Python and TypeScript on push, PR, and weekly schedule
pyproject.toml Updated vulture exclusions to explicitly list test files instead of using wildcard pattern
src/utils/logging_config.py Implemented comprehensive PII redaction for logs including emails, API keys (OpenAI, Anthropic, Stripe), Bearer tokens, and generic keys - scrubs both messages and exceptions
tests/test_logging_security.py Added comprehensive test coverage for PII redaction functionality covering all supported patterns and exception handling

@greptile-apps greptile-apps 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.

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment thread .github/workflows/dast.yml Outdated
Comment thread src/utils/logging_config.py
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps 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.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated
Comment thread src/utils/logging_config.py
Comment thread src/utils/logging_config.py

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated
@gitguardian

gitguardian Bot commented Jan 26, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 4 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
26449490 Triggered Bearer Token cd71987 tests/test_logging_security.py View secret
26449491 Triggered Generic High Entropy Secret cd71987 tests/test_logging_security.py View secret
26449492 Triggered Generic High Entropy Secret cd71987 tests/test_logging_security.py View secret
26448353 Triggered Generic High Entropy Secret 451e5b0 tests/test_logging_security.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py Outdated

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread tests/test_logging_security.py

@greptile-apps greptile-apps 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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/utils/logging_config.py
Miyamura80 and others added 2 commits January 26, 2026 20:05
Add patterns for Anthropic API keys, Stripe keys, Bearer tokens,
and generic api_key/project_key/secret_key formats per code review.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove errant `|` from email TLD character class
- Move Anthropic pattern before OpenAI for correct matching
- Add rk_ prefix to Stripe key tests

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Miyamura80 Miyamura80 merged commit 3983b96 into main Jan 26, 2026
11 checks passed
@github-actions github-actions Bot deleted the feat/security-improvements branch January 26, 2026 20:20
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