Skip to content

[P2] Add Security & Quality Improvements from Code Review #13

Closed

Description

@jeremyeder

Coldstart Implementation Prompt: Add Security & Quality Improvements from Code Review

Priority: P2
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

  1. Create feature branch: git checkout -b NNN-feature-name
  2. Implement changes with tests
  3. Run linters: black . && isort . && ruff check .
  4. Run tests: pytest
  5. Commit with conventional commits
  6. Create PR to main

Feature Requirements

Add Security & Quality Improvements from Code Review

Priority: P2 (Medium - Polish)

Description: Address P2 improvements from code review for better UX and robustness.

Improvements:

  1. Input Validation Warnings

    • Warn when scanning sensitive directories (/etc, /.ssh, /var)
    • Confirm before scanning large repositories (>10k files)
  2. Scorer Semantic Clarity

    • Document behavior when all attributes skipped (returns 0.0)
    • Consider returning None or special value for "not assessable"
    • Add explicit documentation of edge cases
  3. Content Security Policy Headers

    • Add CSP to HTML reports for defense-in-depth
    • Prevent inline script execution
    • Whitelist only necessary sources

Implementation:

# In CLI
sensitive_dirs = ['/etc', '/sys', '/proc', '/.ssh', '/var']
if any(str(repo_path).startswith(p) for p in sensitive_dirs):
    click.confirm(
        f"Warning: Scanning sensitive directory {repo_path}. Continue?",
        abort=True
    )

# In HTMLReporter
csp_header = (
    "<meta http-equiv='Content-Security-Policy' "
    "content=\"default-src 'self'; script-src 'unsafe-inline'; "
    "style-src 'unsafe-inline'\">"
)

Acceptance Criteria:

  • Warnings for sensitive directories
  • CSP headers in HTML reports
  • Scorer edge cases documented
  • User guide updated with best practices

Priority Justification: UX polish and defense-in-depth, not critical bugs.

Related: User experience, security hardening



Implementation Checklist

Before you begin:

  • Read CLAUDE.md for project context
  • Review existing similar features (if applicable)
  • Understand the data model (src/agentready/models/)
  • Check acceptance criteria in feature description

Implementation steps:

  • Create feature branch
  • Implement core functionality
  • Add unit tests (target >80% coverage)
  • Add integration tests (if applicable)
  • Run linters and fix any issues
  • Update documentation (README.md, CLAUDE.md if needed)
  • Self-test the feature end-to-end
  • Create PR with descriptive title and body

Code quality requirements:

  • All code formatted with black (88 char lines)
  • Imports sorted with isort
  • No ruff violations
  • All tests passing
  • Type hints where appropriate
  • Docstrings for public APIs

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:

  1. Unit tests for core logic (80%+ coverage)
  2. Integration tests for end-to-end workflows
  3. Edge case tests (empty inputs, missing files, errors)
  4. 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:

  1. Check CLAUDE.md for project patterns
  2. Review similar existing features
  3. Ask for clarification in PR comments
  4. 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 013-add-security-&-quality-improvements-from-code-revi

# 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.

Activity

  1. jeremyeder commented on Nov 22, 2025

    @jeremyeder
    ContributorAuthor

    @claude implement this.

  2. github-actions commented on Nov 22, 2025

    @github-actions
    Contributor

    Claude finished @jeremyeder's task —— View job • claude/issue-13-20251122-0607 • Create PR ➔


    Implementation Complete! ✅

    I've successfully implemented all security and quality improvements from the code review.

    Changes Implemented

    1. Input Validation Warnings ✅

    • Added warning for scanning sensitive directories (/etc, /sys, /proc, /.ssh, /var)
    • Added confirmation prompt for large repositories (>10k files)
    • Implemented in src/agentready/cli/main.py:141-175
    • Graceful fallback if file counting fails

    2. Content Security Policy Headers ✅

    • Added CSP meta tag to HTML report template
    • Policy: default-src 'self'; script-src 'unsafe-inline'; style-src 'unsafe-inline'
    • Implemented in src/agentready/templates/report.html.j2:6
    • Provides defense-in-depth against XSS attacks

    3. Scorer Semantic Clarity ✅

    • Added comprehensive documentation for edge cases
    • Documented behavior when all attributes are skipped (returns 0.0)
    • Explained how to distinguish "not assessable" from "scored 0"
    • Implemented in src/agentready/services/scorer.py:105-120

    4. Test Coverage ✅

    • Added TestContentSecurityPolicy class to tests/unit/test_security.py
    • Created new tests/unit/test_cli_validation.py with comprehensive CLI tests (173 lines)
    • Tests cover: sensitive dirs, large repos, graceful failures, combined scenarios

    5. Documentation ✅

    • Updated docs/user-guide.md with new troubleshooting sections
    • Added security best practices for sensitive directories
    • Documented large repository warnings
    • Added CSP security information in HTML report section

    Files Changed

    • src/agentready/cli/main.py - Added input validation warnings
    • src/agentready/templates/report.html.j2 - Added CSP meta tag
    • src/agentready/services/scorer.py - Enhanced documentation
    • tests/unit/test_security.py - Added CSP tests
    • tests/unit/test_cli_validation.py - New CLI validation tests
    • docs/user-guide.md - Updated with security best practices

    Next Steps

    Important: Before merging, please run:

    # Run linters
    black src/ tests/
    isort src/ tests/
    ruff check src/ tests/
    
    # Run tests
    pytest

    These commands require tool permissions I don't have in this environment, so they need to be run manually to ensure code quality.


    | Branch: claude/issue-13-20251122-0607

  3. github-actions commented on Nov 22, 2025

    @github-actions
    Contributor

    🎉 This issue has been resolved in version 1.7.0 🎉

    The release is available on GitHub release

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions