-
Notifications
You must be signed in to change notification settings - Fork 1
Increase overall security #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 11 commits
89d8906
73e8a1f
64751e3
cef2155
84226ea
31edd36
15402e5
bd37edb
0f8dcf0
480d978
0690ac7
2af5353
120098b
5c10769
e41e3a9
ccf7938
10a182d
0a78910
266aded
6239d81
8d23f31
ce7d0f9
3db9ec7
58baa6c
a166cf6
c813edb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: pytest | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - "**.py" | ||
| - "uv.lock" | ||
| - ".python-version" | ||
| - "pyproject.toml" | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 #v5 | ||
|
|
||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 #v7.1.2 | ||
| with: | ||
| version: "latest" | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c #v6 | ||
| with: | ||
| python-version: "3.13.3" | ||
|
|
||
| - name: Install dependencies | ||
| run: uv sync --frozen --no-cache | ||
|
|
||
| - name: Run pytest | ||
| run: uv run pytest | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,56 @@ | ||||||||||||||
| from __future__ import annotations | ||||||||||||||
|
|
||||||||||||||
| import re | ||||||||||||||
| from typing import Any | ||||||||||||||
|
|
||||||||||||||
| import bleach | ||||||||||||||
|
|
||||||||||||||
| _OBJECT_ID_RE = re.compile(r"^[a-fA-F0-9]{24}$") | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| def strip_tags(text: str) -> str: | ||||||||||||||
| if text is None: | ||||||||||||||
| return "" | ||||||||||||||
|
Comment on lines
+12
to
+14
|
||||||||||||||
| def strip_tags(text: str) -> str: | |
| if text is None: | |
| return "" | |
| def strip_tags(text: str | None) -> str: | |
| if text is None: | |
| raise TypeError("strip_tags() expected a string, got None") |
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
Fixed
Show fixed
Hide fixed
RafaelCenzano marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +0,0 @@ | ||
| from typing import Any | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
|
|
||
| class ResponseModel(BaseModel): | ||
| data: Any | ||
| message: str | ||
|
|
||
|
|
||
| class BoolResponse(ResponseModel): | ||
| data: bool | ||
|
|
||
|
|
||
| class StringListResponse(ResponseModel): | ||
| data: list[str] | ||
|
|
||
|
|
||
| class IntResponse(ResponseModel): | ||
| data: int | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,26 @@ | ||||||||||
| from pydantic import BaseModel, Field | ||||||||||
| from uuid import UUID | ||||||||||
|
|
||||||||||
| from pydantic import BaseModel, Field, field_validator | ||||||||||
|
|
||||||||||
|
|
||||||||||
| class TokenRequest(BaseModel): | ||||||||||
| code: str = Field(...) | ||||||||||
|
|
||||||||||
| @field_validator("code", mode="before") | ||||||||||
| @classmethod | ||||||||||
| def v_code(cls, v: str) -> str: | ||||||||||
| # Strip whitespace | ||||||||||
| v = v.strip() if isinstance(v, str) else str(v) | ||||||||||
| try: | ||||||||||
| # Validate it's a valid UUID v4 | ||||||||||
| uuid_obj = UUID(v, version=4) | ||||||||||
|
||||||||||
| uuid_obj = UUID(v, version=4) | |
| uuid_obj = UUID(v) | |
| if uuid_obj.version != 4: | |
| raise ValueError("code must be a valid UUID v4") |
RafaelCenzano marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||
| from typing import Annotated, Any | ||||||
|
|
||||||
| from pydantic import BaseModel, BeforeValidator | ||||||
|
|
||||||
| from server.helpers.sanitize import is_valid_object_id, sanitize_text | ||||||
|
|
||||||
|
|
||||||
| def validate_name(v: str | None) -> str: | ||||||
|
||||||
| def validate_name(v: str | None) -> str: | |
| def validate_name(v: str) -> str: |
Uh oh!
There was an error while loading. Please reload this page.