Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2

updates:
- package-ecosystem: uv
directory: /
schedule:
interval: weekly
day: monday
time: "09:00"
timezone: America/Vancouver
groups:
python-dependencies:
patterns:
- "*"

- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
time: "09:15"
timezone: America/Vancouver
groups:
github-actions:
patterns:
- "*"
3 changes: 3 additions & 0 deletions .github/workflows/alembic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Alembic Upgrade Head
on: pull_request

permissions:
contents: read

jobs:
alembic_upgrade_head:
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pytest_unit.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Unit Tests
on: pull_request

permissions:
contents: read

jobs:
unit_tests:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Ruff
on: pull_request

permissions:
contents: read

jobs:
ruff:
runs-on: ubuntu-latest
Expand Down
112 changes: 112 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Security

on:
pull_request:
push:
branches:
- main
schedule:
- cron: "17 9 * * 1"

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.

Kind of a random time to scan, but I guess it doesn't really matter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh it's Monday 2 minutes after Opengrep work

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah supply chain exist, but pinning commit SHA will be hard for devs?

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.

Oh it's Monday 2 minutes after Opengrep work

Wouldn't this run at at 9:17 AM UTC, not 9:00 AM America/Vancouver? Isn't this the cron job for Opengrep? I wasn't sure, because dependabot runs at 9:15AM America/Vancouver, but this runs UTC.

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.

Yeah supply chain exist, but pinning commit SHA will be hard for devs?

Yeah, I guess.

workflow_dispatch:

permissions:
contents: read
Comment on lines +12 to +13

env:
OPENGREP_VERSION: v1.27.1
TRIVY_VERSION: v0.74.0

jobs:
sast:
name: Opengrep SAST
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- name: Install Opengrep
run: |
curl --fail --location --silent --show-error \
"https://github.com/opengrep/opengrep/releases/download/${OPENGREP_VERSION}/opengrep_manylinux_x86" \
--output "$RUNNER_TEMP/opengrep"
chmod 0555 "$RUNNER_TEMP/opengrep"
"$RUNNER_TEMP/opengrep" --version
Comment on lines +33 to +37

- name: Scan source code
run: |
mkdir -p reports
"$RUNNER_TEMP/opengrep" scan \
--config auto \
--no-rewrite-rule-ids \
--disable-version-check \
--error \
--sarif-output=reports/opengrep.sarif \
src/

- name: Upload Opengrep report
if: always()
uses: actions/upload-artifact@v7.0.1
with:
name: opengrep-sarif
path: reports/opengrep.sarif
if-no-files-found: error
retention-days: 14
Comment on lines +50 to +57

sca:
name: Trivy SCA
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout repository
uses: actions/checkout@v7.0.1
with:
persist-credentials: false

- name: Install Trivy
uses: aquasecurity/setup-trivy@v0.3.1
with:
version: ${{ env.TRIVY_VERSION }}
cache: true

- name: Scan locked dependencies
run: |
mkdir -p reports

trivy fs \
--scanners vuln \
--include-dev-deps \
--format sarif \
--output reports/trivy.sarif \
uv.lock

trivy fs \
--scanners vuln \
--include-dev-deps \
--skip-db-update \
--format cyclonedx \
--output reports/sbom.cdx.json \
uv.lock

trivy fs \
--scanners vuln \
--include-dev-deps \
--skip-db-update \
--severity HIGH,CRITICAL \
--exit-code 1 \
uv.lock

- name: Upload Trivy reports
if: always()
uses: actions/upload-artifact@v7.0.1
with:
name: trivy-reports
path: |
reports/trivy.sarif
reports/sbom.cdx.json
if-no-files-found: error
retention-days: 14
Comment on lines +103 to +112
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ requires-python = "~=3.13.0"

dependencies = [
# major
"fastapi==0.135.4",
"fastapi==0.139.2",
"gunicorn==25.3.0",
"uvicorn[standard]==0.46.0",
"sqlalchemy[asyncio]==2.0.49",
"asyncpg==0.31.0",
"alembic==1.18.4",
"google-api-python-client==2.194.0",
# minor
"xmltodict==0.13.0",
"httpx==0.28.1",
Expand Down
4 changes: 1 addition & 3 deletions src/translink/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ async def get_or_fetch_realtime_feed(db_session: DBSession, client: AsyncClient)

# Transaction lock, released on commit or rollback.
# This prevents multiple requests from fetching the feed at the same time.
await db_session.execute(
sqlalchemy.text("SELECT pg_advisory_xact_lock(:lock_id)"), {"lock_id": REALTIME_CACHE_LOCK_ID}
)
await db_session.execute(sqlalchemy.select(sqlalchemy.func.pg_advisory_xact_lock(REALTIME_CACHE_LOCK_ID)))
cached_feed = await db_session.scalar(
sqlalchemy.select(TransLinkRealtimeCacheDB).where(TransLinkRealtimeCacheDB.id == REALTIME_CACHE_ID)
)
Expand Down
Loading
Loading