Repository navigation
feat: security audit, modular deps, enhanced REST API, integration tests #22
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 |
|---|---|---|
|
|
@@ -12,9 +12,77 @@ env: | |
| PYTHON_VERSION: "3.11" | ||
|
|
||
| jobs: | ||
| # ─── Security checks ──────────────────────────────────────── | ||
| security: | ||
| name: Security Audit | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install bandit safety | ||
|
|
||
| - name: Run Bandit security linter | ||
| run: | | ||
| bandit -r package_maximizer/ -f json -o bandit-report.json || true | ||
| bandit -r package_maximizer/ -f screen --severity-level medium | ||
|
|
||
| - name: Check for known vulnerabilities | ||
| run: safety check -r requirements.txt --full-report || true | ||
|
|
||
| - name: Upload security report | ||
| if: always() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: security-report | ||
| path: bandit-report.json | ||
|
|
||
| # ─── Linting ──────────────────────────────────────────────── | ||
| lint: | ||
| name: Code Quality | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
|
|
||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 package_maximizer/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | ||
| flake8 package_maximizer/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
|
|
||
| - name: Type check with mypy | ||
| run: mypy package_maximizer/ --ignore-missing-imports || true | ||
|
|
||
| - name: Check formatting with black | ||
| run: black --check package_maximizer/ tests/ || true | ||
|
|
||
| - name: Check imports with isort | ||
| run: isort --check-only package_maximizer/ tests/ || true | ||
|
|
||
| # ─── Tests across matrix ──────────────────────────────────── | ||
| test: | ||
| name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }}) | ||
| needs: [security, lint] | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, windows-latest, macos-latest] | ||
| python-version: ["3.10", "3.11", "3.12"] | ||
|
|
@@ -45,20 +113,65 @@ jobs: | |
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements.txt | ||
| pip install -e ".[dev,all]" | ||
|
|
||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 package_maximizer/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics | ||
| flake8 package_maximizer/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
| pip install -e ".[dev]" | ||
|
|
||
| - name: Test with pytest | ||
| - name: Run tests with pytest | ||
| run: | | ||
| pytest tests/ -v --cov=package_maximizer --cov-report=xml --cov-report=term | ||
| pytest tests/ -v --cov=package_maximizer --cov-report=xml --cov-report=term -n auto --tb=short | ||
|
|
||
| - name: Upload coverage to Codecov | ||
| if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11' | ||
| uses: codecov/codecov-action@v4 | ||
| with: | ||
| file: ./coverage.xml | ||
| flags: unittests | ||
| name: codecov-${{ matrix.os }}-py${{ matrix.python-version }} | ||
| name: codecov-ubuntu-py311 | ||
|
|
||
| # ─── Build package ───────────────────────────────────────── | ||
| build: | ||
| name: Build Distribution | ||
| runs-on: ubuntu-latest | ||
| needs: [test] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install build tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install build twine | ||
|
|
||
| - name: Build package | ||
| run: python -m build | ||
|
|
||
| - name: Check package with twine | ||
| run: twine check dist/* | ||
|
|
||
| - name: Upload build artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| # ─── Publish to PyPI ──────────────────────────────────────── | ||
| publish: | ||
| name: Publish to PyPI | ||
| needs: [build] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'release' && github.event.action == 'published' | ||
|
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. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
for workflow in .github/workflows/ci.yml .github/workflows/publish.yml; do
echo "== $workflow =="
rg -n -C 5 '(^on:|release:|types:|published|pypi-publish|gh-action-pypi-publish)' "$workflow"
doneRepository: dominicusin/package-maximizer Length of output: 1578 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== ci build and publish =="
sed -n '80,190p' .github/workflows/ci.yml
echo "== publish workflow =="
sed -n '1,90p' .github/workflows/publish.yml
echo "== version and build configuration =="
for file in $(fd -t f '^(pyproject\.toml|setup\.cfg|setup\.py|__init__\.py)$' . | head -20); do
echo "--- $file"
rg -n -C 3 'version|setuptools|build|hatch|poetry|dynamic' "$file" || true
doneRepository: dominicusin/package-maximizer Length of output: 6127 Use one release publisher. Both 🧰 Tools🪛 zizmor (1.29.0)[warning] 1-178: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) 🤖 Prompt for AI Agents |
||
| environment: production | ||
| permissions: | ||
| id-token: write | ||
|
|
||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 | ||
|
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. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Expect exactly one immutable 40-character commit SHA for the PyPI publisher.
python - <<'PY'
import re
from pathlib import Path
workflow = Path(".github/workflows/ci.yml").read_text()
match = re.search(
r"uses:\s*pypa/gh-action-pypi-publish@([^\s]+)",
workflow,
)
assert match, "PyPI publishing action was not found"
assert re.fullmatch(r"[0-9a-f]{40}", match.group(1)), (
f"Expected an immutable commit SHA, got: {match.group(1)}"
)
PYRepository: dominicusin/package-maximizer Length of output: 307 Security Misconfiguration (CWE-829): Inclusion of Functionality from Untrusted Control Sphere Reachability: External · Exploitability: Difficult Pin the PyPI publishing action to an immutable commit.
🧰 Tools🪛 zizmor (1.29.0)[warning] 1-178: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block (excessive-permissions) 🤖 Prompt for AI Agents |
||
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.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: dominicusin/package-maximizer
Length of output: 4231
Security Misconfiguration (CWE-693)
Fail the job when Safety finds a vulnerable dependency.
|| trueconverts a Safety finding into success. Remove it so the security job blocks dependent jobs when Safety reports a vulnerability.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 1-178: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
[warning] 16-48: overly broad permissions (excessive-permissions): default permissions used due to no permissions: block
(excessive-permissions)
🤖 Prompt for AI Agents