Coldstart Implementation Prompt: Fix Critical Security & Logic Bugs from Code Review
Priority: P0
Repository: agentready (https://github.com/redhat/agentready)
Branch Strategy: Create feature branch from main
Context
You are implementing a feature for AgentReady, a repository quality assessment tool for AI-assisted development.
Repository Structure
agentready/
├── src/agentready/ # Source code
│ ├── models/ # Data models
│ ├── services/ # Scanner orchestration
│ ├── assessors/ # Attribute assessments
│ ├── reporters/ # Report generation (HTML, Markdown, JSON)
│ ├── templates/ # Jinja2 templates
│ └── cli/ # Click-based CLI
├── tests/ # Test suite (unit + integration)
├── examples/ # Example reports
└── specs/ # Feature specifications
Key Technologies
- Python 3.11+
- Click (CLI framework)
- Jinja2 (templating)
- Pytest (testing)
- Black, isort, ruff (code quality)
Development Workflow
- Create feature branch:
git checkout -b NNN-feature-name
- Implement changes with tests
- Run linters:
black . && isort . && ruff check .
- Run tests:
pytest
- Commit with conventional commits
- Create PR to main
Feature Requirements
Fix Critical Security & Logic Bugs from Code Review
Priority: P0 (Critical - Security & Correctness)
Description: Address critical bugs discovered in code review that affect security and assessment accuracy.
Issues to Fix:
-
XSS Vulnerability in HTML Reports (CRITICAL - Security)
- Location:
src/agentready/templates/report.html.j2:579
- Problem:
assessment_json|safe disables autoescaping for JSON embedded in JavaScript
- Risk: Repository names, commit messages, file paths from git could contain malicious content
- Fix: Replace with
JSON.parse({{ assessment_json|tojson }})
- Add: Content Security Policy headers to HTML reports
-
StandardLayoutAssessor Logic Bug (CRITICAL - Incorrect Scoring)
- Location:
src/agentready/assessors/structure.py:48
- Problem:
(repository.path / "tests") or (repository.path / "test") always evaluates to first path
- Impact: Projects with
test/ instead of tests/ scored incorrectly
- Fix: Check both paths properly:
tests_path = repository.path / "tests"
if not tests_path.exists():
tests_path = repository.path / "test"
has_tests = tests_path.exists()
Implementation:
File 1: src/agentready/templates/report.html.j2
<!-- BEFORE (VULNERABLE): -->
const ASSESSMENT = {{ assessment_json|safe }};
<!-- AFTER (SECURE): -->
const ASSESSMENT = JSON.parse({{ assessment_json|tojson }});
File 2: src/agentready/assessors/structure.py
# BEFORE (BUGGY):
standard_dirs = {
"src": repository.path / "src",
"tests": (repository.path / "tests") or (repository.path / "test"), # BUG!
}
# AFTER (CORRECT):
standard_dirs = {
"src": repository.path / "src",
}
# Check for tests directory (either tests/ or test/)
tests_path = repository.path / "tests"
if not tests_path.exists():
tests_path = repository.path / "test"
standard_dirs["tests"] = tests_path
Test Cases to Add:
def test_xss_in_repository_name():
"""Test that malicious repo names are escaped in HTML."""
repo = Repository(
name="<script>alert('xss')</script>",
# ...
)
html = HTMLReporter().generate(assessment, output)
assert "<script>" not in html # Should be escaped
def test_standard_layout_with_test_dir():
"""Test that 'test/' directory is recognized (not just 'tests/')."""
# Create repo with test/ directory only
repo_path = tmp_path / "repo"
(repo_path / "test").mkdir(parents=True)
assessor = StandardLayoutAssessor()
finding = assessor.assess(Repository(...))
assert finding.status == "pass" # Should recognize test/ dir
Acceptance Criteria:
Priority Justification:
- Security: XSS is a P0 vulnerability
- Correctness: Incorrect scoring undermines tool credibility
- Quick fixes: Both are 5-10 minute changes
Related: Issue #2 (Report improvements), Bootstrap (#1 - needs secure reports)
Implementation Checklist
Before you begin:
Implementation steps:
Code quality requirements:
Key Files to Review
Based on this feature, you should review:
src/agentready/models/ - Understand Assessment, Finding, Attribute models
src/agentready/services/scanner.py - Scanner orchestration
src/agentready/assessors/base.py - BaseAssessor pattern
src/agentready/reporters/ - Report generation
CLAUDE.md - Project overview and guidelines
BACKLOG.md - Full context of this feature
Testing Strategy
For this feature, ensure:
- Unit tests for core logic (80%+ coverage)
- Integration tests for end-to-end workflows
- Edge case tests (empty inputs, missing files, errors)
- Error handling tests (graceful degradation)
Run tests:
# All tests
pytest
# With coverage
pytest --cov=src/agentready --cov-report=html
# Specific test file
pytest tests/unit/test_feature.py -v
Success Criteria
This feature is complete when:
- ✅ All acceptance criteria from feature description are met
- ✅ Tests passing with >80% coverage for new code
- ✅ All linters passing (black, isort, ruff)
- ✅ Documentation updated
- ✅ PR created with clear description
- ✅ Self-tested end-to-end
Questions to Clarify (if needed)
If anything is unclear during implementation:
- Check CLAUDE.md for project patterns
- Review similar existing features
- Ask for clarification in PR comments
- Reference the original backlog item
Getting Started
# Clone and setup
git clone https://github.com/redhat/agentready.git
cd agentready
# Create virtual environment
uv venv && source .venv/bin/activate
# Install dependencies
uv pip install -e .
uv pip install pytest black isort ruff
# Create feature branch
git checkout -b 002-fix-critical-security-&-logic-bugs-from-code-revie
# Start implementing!
Note: This is a coldstart prompt. You have all context needed to implement this feature independently. Read the linked files, follow the patterns, and deliver high-quality code with tests.
Coldstart Implementation Prompt: Fix Critical Security & Logic Bugs from Code Review
Priority: P0
Repository: agentready (https://github.com/redhat/agentready)
Branch Strategy: Create feature branch from main
Context
You are implementing a feature for AgentReady, a repository quality assessment tool for AI-assisted development.
Repository Structure
Key Technologies
Development Workflow
git checkout -b NNN-feature-nameblack . && isort . && ruff check .pytestFeature Requirements
Fix Critical Security & Logic Bugs from Code Review
Priority: P0 (Critical - Security & Correctness)
Description: Address critical bugs discovered in code review that affect security and assessment accuracy.
Issues to Fix:
XSS Vulnerability in HTML Reports (CRITICAL - Security)
src/agentready/templates/report.html.j2:579assessment_json|safedisables autoescaping for JSON embedded in JavaScriptJSON.parse({{ assessment_json|tojson }})StandardLayoutAssessor Logic Bug (CRITICAL - Incorrect Scoring)
src/agentready/assessors/structure.py:48(repository.path / "tests") or (repository.path / "test")always evaluates to first pathtest/instead oftests/scored incorrectlyImplementation:
File 1:
src/agentready/templates/report.html.j2File 2:
src/agentready/assessors/structure.pyTest Cases to Add:
Acceptance Criteria:
tojsonfiltertests/andtest/Priority Justification:
Related: Issue #2 (Report improvements), Bootstrap (#1 - needs secure reports)
Implementation Checklist
Before you begin:
Implementation steps:
Code quality requirements:
Key Files to Review
Based on this feature, you should review:
src/agentready/models/- Understand Assessment, Finding, Attribute modelssrc/agentready/services/scanner.py- Scanner orchestrationsrc/agentready/assessors/base.py- BaseAssessor patternsrc/agentready/reporters/- Report generationCLAUDE.md- Project overview and guidelinesBACKLOG.md- Full context of this featureTesting Strategy
For this feature, ensure:
Run tests:
Success Criteria
This feature is complete when:
Questions to Clarify (if needed)
If anything is unclear during implementation:
Getting Started
Note: This is a coldstart prompt. You have all context needed to implement this feature independently. Read the linked files, follow the patterns, and deliver high-quality code with tests.