Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/data-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Mask the connection details
run: >
uv run python -c "import os;
from hackproof.db_utils.connection import Connection;
from trawl.schema.connection import Connection;
print('\n'.join(Connection.from_url(os.environ['DATABASE_URL']).mask_lines()))"
- name: Restore the scan data the database does not hold
run: uv run hackproof import --remote
Expand Down
4 changes: 1 addition & 3 deletions apps/api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ dependencies = [
"pydantic-settings>=2.16.1",
"pyyaml>=6.0.3",
"stellar-sdk>=16.1.1",
"trawl @ https://github.com/devodii/trawl/releases/download/v0.1.0/trawl-0.1.0-py3-none-any.whl",
]

[project.scripts]
hackproof = "hackproof.cli:main"

[project.entry-points."sqlfluff"]
hackproof = "hackproof.db_utils.sqlfluff.plugin"

[build-system]
requires = ["uv_build>=0.12.5,<0.13.0"]
build-backend = "uv_build"
Expand Down
3 changes: 2 additions & 1 deletion apps/api/src/hackproof/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import os
from pathlib import Path

from trawl.schema.connection import Connection

from hackproof.config import get_settings
from hackproof.db_utils import pgschema
from hackproof.db_utils.connection import Connection
from hackproof.export.jobs import run_check, run_export, run_import
from hackproof.github.jobs import run_discover, run_scan
from hackproof.indexer.sync import run_sync
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/hackproof/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from pydantic import AliasChoices, Field, field_validator
from pydantic_settings import BaseSettings, NoDecode, SettingsConfigDict
from trawl.github.client import parse_tokens

ROOT = Path(__file__).resolve().parents[4]
ROOT_ENV = ROOT / ".env"
Expand Down Expand Up @@ -42,9 +43,7 @@ class Settings(BaseSettings):
@field_validator("github_tokens", mode="before")
@classmethod
def split_tokens(cls, value: object) -> object:
if isinstance(value, str):
return [token.strip() for token in value.split(",") if token.strip()]
return value
return parse_tokens(value) if isinstance(value, str) else value


@lru_cache
Expand Down
13 changes: 2 additions & 11 deletions apps/api/src/hackproof/db.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import json

import asyncpg
from trawl.db.pool import open_pool as connect

from hackproof.config import get_settings

_pool: asyncpg.Pool | None = None


async def _init_connection(connection: asyncpg.Connection) -> None:
await connection.set_type_codec(
"jsonb", encoder=json.dumps, decoder=json.loads, schema="pg_catalog"
)


async def open_pool() -> asyncpg.Pool:
global _pool
_pool = await asyncpg.create_pool(
get_settings().database_url, min_size=1, max_size=10, init=_init_connection
)
_pool = await connect(get_settings().database_url)
return _pool


Expand Down
55 changes: 0 additions & 55 deletions apps/api/src/hackproof/db_utils/connection.py

This file was deleted.

43 changes: 0 additions & 43 deletions apps/api/src/hackproof/db_utils/guard.py

This file was deleted.

90 changes: 0 additions & 90 deletions apps/api/src/hackproof/db_utils/manifest.py

This file was deleted.

Loading
Loading