Skip to content

Security patches#17

Merged
JamesABaker merged 2 commits into
mainfrom
security-patches
Jun 13, 2026
Merged

Security patches#17
JamesABaker merged 2 commits into
mainfrom
security-patches

Conversation

@JamesABaker

Copy link
Copy Markdown
Owner

No description provided.

@JamesABaker JamesABaker requested a review from Copilot June 13, 2026 11:42
@JamesABaker JamesABaker merged commit 62f9502 into main Jun 13, 2026
4 checks passed
@JamesABaker JamesABaker deleted the security-patches branch June 13, 2026 11:43

Copilot AI left a comment

Copy link
Copy Markdown

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 applies a set of security-focused improvements across the API, auth flow, and UI, including OAuth CSRF-state validation, basic API rate limiting, and safer DOM rendering for user history.

Changes:

  • Add slowapi-based rate limiting to /api/detect and tighten request/query validation (max text length; bounded limit/offset).
  • Harden GitHub OAuth callback by generating/verifying a per-login state value stored in an HTTP-only cookie.
  • Prevent XSS in the UI history list by replacing innerHTML templating with DOM node creation (textContent).

Reviewed changes

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

Show a summary per file
File Description
uv.lock Locks new dependency set for slowapi and transitive packages (limits, deprecated, wrapt).
pyproject.toml Adds slowapi>=0.1.9 to runtime dependencies.
app/main.py Configures SlowAPI limiter/handler; adds request size limit; rate-limits /api/detect; validates results pagination params.
app/routes/auth.py Adds OAuth state generation + cookie storage and constant-time verification on callback; clears cookie after success.
app/static/index.html Reworks history rendering to avoid innerHTML injection risk.
tests/conftest.py Updates mocked detector output to include newly expected entropy metrics; adjusts import suppression.

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

Comment thread tests/conftest.py
Comment on lines 13 to +17
from fastapi.testclient import TestClient
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from app.database import Base, get_db


from app.database import Base, get_db # noqa: E402
Comment thread app/routes/auth.py
Comment on lines 68 to 74
@router.get("/callback")
async def oauth_callback(
code: str = Query(...),
state: str = Query(...),
request: Request = None,
db: Session = Depends(get_db),
):
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