-
Notifications
You must be signed in to change notification settings - Fork 0
Add repository audit/upgrade plan, web UI hardening, file previews, and CI workflow #1
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.10", "3.11", "3.12"] | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -e ".[dev]" | ||
| - name: Compile check | ||
| run: python -m compileall project_prompter | ||
| - name: Run tests | ||
| run: pytest | ||
| - name: Ruff lint | ||
| run: ruff check . | ||
| - name: Mypy (core modules) | ||
| run: mypy project_prompter/audit.py project_prompter/web_security.py | ||
| - name: Bandit security scan | ||
| run: bandit -q -r project_prompter || true | ||
| - name: Dependency audit | ||
| run: pip-audit || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # PROJECT BRIEF | ||
|
|
||
| ## Security Review Notes | ||
|
|
||
| - We must constrain user-provided Ollama base URLs to loopback-only targets unless explicit opt-in is introduced. | ||
| - Relevant implementation files: | ||
| - `project_prompter/web.py` | ||
| - `project_prompter/ollama_client.py` | ||
| - Sensitive local Ollama endpoints in scope: | ||
| - `/api/tags` | ||
| - `/api/generate` | ||
| - Threat model focus: SSRF-style misuse through analysis configuration and model endpoint routing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| """Repository quality/security audit helpers.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from dataclasses import dataclass | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| @dataclass | ||
| class AuditFinding: | ||
| category: str | ||
| severity: str | ||
| title: str | ||
| detail: str | ||
| recommendation: str | ||
|
|
||
|
|
||
| def run_repo_audit(project_path: Path) -> list[AuditFinding]: | ||
| findings: list[AuditFinding] = [] | ||
|
|
||
| if not (project_path / "tests").exists(): | ||
| findings.append( | ||
| AuditFinding( | ||
| category="quality", | ||
| severity="high", | ||
| title="Automated test suite missing", | ||
| detail="No top-level tests directory was found.", | ||
| recommendation="Add pytest-based smoke/unit tests for CLI and web API critical paths.", | ||
| ) | ||
| ) | ||
|
|
||
| if not (project_path / ".github" / "workflows").exists(): | ||
| findings.append( | ||
| AuditFinding( | ||
| category="quality", | ||
| severity="medium", | ||
| title="CI workflow missing", | ||
| detail="No GitHub Actions workflow directory detected.", | ||
| recommendation="Add CI for lint, tests, and packaging checks on pull requests.", | ||
| ) | ||
| ) | ||
|
|
||
| if not (project_path / "SECURITY.md").exists(): | ||
| findings.append( | ||
| AuditFinding( | ||
| category="security", | ||
| severity="high", | ||
| title="No security policy file", | ||
| detail="SECURITY.md file is missing.", | ||
| recommendation="Publish a security policy with disclosure contact and supported versions.", | ||
| ) | ||
| ) | ||
|
|
||
| if not (project_path / "pyproject.toml").exists(): | ||
| findings.append( | ||
| AuditFinding( | ||
| category="quality", | ||
| severity="high", | ||
| title="Missing pyproject.toml", | ||
| detail="Project metadata and tooling configuration are missing.", | ||
| recommendation="Adopt pyproject.toml and define lint/test/type/audit tool configs.", | ||
| ) | ||
| ) | ||
|
|
||
| if not any((project_path / f).exists() for f in ("poetry.lock", "requirements.txt", "requirements.lock", "uv.lock")): | ||
| findings.append( | ||
| AuditFinding( | ||
| category="security", | ||
| severity="medium", | ||
| title="Dependency lockfile/constraints missing", | ||
| detail="No dependency lockfile or pinned requirements file detected.", | ||
| recommendation="Add a lockfile or pinned requirements to improve supply-chain reproducibility.", | ||
| ) | ||
| ) | ||
|
|
||
| has_cov_config = (project_path / ".coveragerc").exists() | ||
| if (project_path / "pyproject.toml").exists(): | ||
| text = (project_path / "pyproject.toml").read_text(encoding="utf-8", errors="ignore") | ||
| has_cov_config = has_cov_config or "[tool.coverage." in text | ||
| if not has_cov_config: | ||
| findings.append( | ||
| AuditFinding( | ||
| category="quality", | ||
| severity="low", | ||
| title="Coverage policy missing", | ||
| detail="No coverage configuration found to enforce quality thresholds.", | ||
| recommendation="Configure coverage and enforce a minimum threshold in CI.", | ||
| ) | ||
| ) | ||
|
|
||
| return findings | ||
|
|
||
|
|
||
| def build_upgrade_plan(project_path: Path, findings: list[AuditFinding]) -> str: | ||
| lines = [ | ||
| f"# Project Upgrade Plan ({project_path.name})", | ||
| "", | ||
| "## Phase 1 — Trust & Security", | ||
| "1. Add API abuse tests for validation and path restrictions.", | ||
| "2. Add regression tests for secret redaction and output safety.", | ||
| "", | ||
| "## Phase 2 — Engineering Quality", | ||
| "1. Introduce CI (tests + static checks).", | ||
| "2. Add baseline test coverage for CLI/web flows.", | ||
| "", | ||
| "## Phase 3 — Star-worthy Productization", | ||
| "1. Ship polished demo assets and usage GIFs.", | ||
| "2. Publish contribution guide + issue templates.", | ||
| "", | ||
| "## Current Findings", | ||
| ] | ||
| if not findings: | ||
| lines.append("- No major structural gaps detected by baseline audit.") | ||
| else: | ||
| for item in findings: | ||
| lines.append( | ||
| f"- [{item.severity.upper()}] {item.title}: {item.detail} → {item.recommendation}" | ||
| ) | ||
| lines.append("") | ||
| return "\n".join(lines) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| """Route-level helpers for web API composition.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| HEALTH_PATH = "/api/health" | ||
| ANALYZE_PATH = "/api/analyze" | ||
| RESULTS_PATH = "/api/results/{scan_id}" | ||
| DOWNLOAD_PATH = "/api/download/{scan_id}/{filename:path}" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Move
validate_extra_ignore_dirs()into the existingtry/exceptinanalyze(), otherwise malformed entries (for example"../tmp") raiseValueErrorafter the handler and return a 500 instead of a controlled 400/422 response. This breaks the new hardening path for exactly the invalid-input case it is meant to handle.Useful? React with 👍 / 👎.