-
Notifications
You must be signed in to change notification settings - Fork 4
Harden security, reliability, and CI from adversarial review #2
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
Changes from all commits
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,14 @@ | ||
| version: 2 | ||
| updates: | ||
| # Keep requirements.lock / pyproject deps patched (security + routine). | ||
| - package-ecosystem: "pip" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| open-pull-requests-limit: 5 | ||
|
|
||
| # Keep SHA-pinned GitHub Actions fresh. | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,35 +14,30 @@ jobs: | |
| python-version: ["3.12", "3.13"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| # Actions pinned by commit SHA (not mutable tags) so a compromised tag | ||
| # can't inject code into CI. | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This step no longer passes Useful? React with 👍 / 👎. |
||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install dependencies | ||
| # requirements.lock pins the runtime deps; -e . adds the package | ||
| # itself; test tooling is pinned so CI is deterministic. | ||
| run: | | ||
| pip install -e . | ||
| pip install pytest ruff | ||
| pip install -r requirements.lock | ||
| pip install -e . --no-deps | ||
| pip install pytest==9.1.1 pytest-asyncio==1.4.0 ruff==0.15.20 pip-audit==2.10.1 | ||
|
|
||
| - name: Lint | ||
| # Non-blocking for now: the repo has pre-existing ruff debt (mostly | ||
| # E501/I001/F401) unrelated to current work. Tests below are the real | ||
| # gate. TODO: clean lint in a focused PR, then drop continue-on-error. | ||
| continue-on-error: true | ||
| run: ruff check src/ | ||
| run: ruff check src/ tests/ | ||
|
|
||
| - name: Syntax check all Python files | ||
| run: | | ||
| find src/ -name "*.py" -exec python -c " | ||
| import ast, sys | ||
| try: | ||
| ast.parse(open(sys.argv[1]).read()) | ||
| except SyntaxError as e: | ||
| print(f'FAIL: {sys.argv[1]}: {e}') | ||
| sys.exit(1) | ||
| " {} \; | ||
| - name: Dependency vulnerability audit | ||
| # Blocking: a known CVE in a pinned runtime dep fails CI. Dependabot | ||
| # (.github/dependabot.yml) keeps the lockfile and action SHAs fresh. | ||
| run: pip-audit -r requirements.lock | ||
|
|
||
| - name: Test imports | ||
| run: | | ||
|
|
@@ -52,5 +47,6 @@ jobs: | |
| python -c "from src.dashboards.liquidation_heatmap import LiquidationHeatmapDashboard; print('heatmap: OK')" | ||
|
|
||
| - name: Run tests | ||
| # test_position_scanner.py needs a live exchange connection — skip in CI. | ||
| run: python -m pytest tests/ -q --ignore=tests/test_position_scanner.py | ||
| # The full suite, position scanner included — its network calls are | ||
| # mocked; only tests marked `live` need real exchange connections. | ||
| run: python -m pytest tests/ -q | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,11 @@ target-version = "py312" | |
| [tool.ruff.lint] | ||
| select = ["E", "F", "W", "I"] | ||
|
|
||
| [tool.ruff.lint.per-file-ignores] | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Packaging Security - Medium]: Packaging of raw (Reviewer note: Commenting here on the ruff addition since the setuptools section is unchanged in this diff) Line 20 of Analogy: Packing your private notes and house diagrams into a box of free books that you leave on the sidewalk. Fix: Restrict finding to include = ["src*"] |
||
| # Presentation layer: ASCII-art boot screens and Rich table markup read | ||
| # better unwrapped; everything else must respect the line limit. | ||
| "src/dashboards/*" = ["E501"] | ||
|
|
||
| [tool.pytest.ini_options] | ||
| testpaths = ["tests"] | ||
| asyncio_mode = "auto" | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 P1 (High): The
setup-pythonaction is invoked without awith:block specifyingpython-version: ${{ matrix.python-version }}, so the Python version matrix is not applied. This means all jobs will use the runner's default Python and cross-version testing is lost. Addwith: python-version: ${{ matrix.python-version }}to restore matrix testing.