# Cursor Rules for the security_audit Module

## 0. Preamble
These rules are specific to the `security_audit` module and supplement `general.cursorrules`. Always adhere to `general.cursorrules` unless explicitly overridden here for a specific reason pertinent to this module.

## 1. Module Purpose & Context
-   **Core Functionality**: This module provides security analysis, vulnerability scanning, compliance checking, and monitoring across the Codomyrmex ecosystem.
-   **Key Technologies/Tools**: Python, security scanners (bandit, semgrep), encryption libraries, certificate validation, compliance frameworks (OWASP, NIST, ISO).
-   Refer to the module's main `README.md` for an overview.

## 2. Key Files & Structure in `security_audit` Module
When working within this module, pay close attention to:
-   `README.md`: High-level overview, setup, and usage of the Security Audit module.
-   `API_SPECIFICATION.md`: Details for programmatic interfaces (functions, classes) provided by this module.
-   `CHANGELOG.md`: All notable changes to this module must be logged here.
-   `SECURITY.md`: Specific security considerations for audit implementation and vulnerability management.
-   `pyproject.toml`: Python dependencies (managed centrally via uv).
-   `docs/`: In-depth documentation, technical overviews, and tutorials specific to Security Audit.
-   `src/` (or primary Python package folders, e.g., `security_audit/` itself if it contains Python sources directly): Core logic of the module.
-   `tests/`: Unit and integration tests for this module.
-   `.gitignore`: Module-specific ignored files.
-   `vulnerability_scanner.py`: Core vulnerability scanning functionality.
-   `encryption_manager.py`: Encryption and key management capabilities.
-   `certificate_validator.py`: Certificate validation and SSL/TLS assessment.
-   `security_monitor.py`: Security monitoring and alerting.
-   `security_reports.py`: Security reporting and risk assessment.

## 3. Coding Standards & Practices for `security_audit`
-   **Consistency**: Adhere to existing coding styles, naming conventions, and architectural patterns found within the `security_audit` module.
-   **Language Specifics**: Primarily Python. Follow PEP 8. Use type hinting extensively for security configurations and results.
-   **Security First**: Every change must prioritize security, encryption standards, and vulnerability management.
-   **Compliance**: Ensure all security measures comply with industry standards and best practices.
-   **Accuracy**: Maintain high accuracy in vulnerability detection with minimal false positives.

## 4. Testing in `security_audit`
-   New features (e.g., new scanning capabilities, compliance checks) or bug fixes MUST be accompanied by relevant tests in `tests/unit/` and/or `tests/integration/`.
-   Tests should cover vulnerability scanning, encryption operations, certificate validation, and security monitoring.
-   Include security-specific tests to validate detection accuracy and compliance.
-   Run existing tests to ensure no regressions. Refer to `security_audit/tests/README.md`.

## 5. Documentation for `security_audit`
-   Keep this module's `README.md`, `API_SPECIFICATION.md`, `SECURITY.md`, `docs/` directory, and other relevant documentation files meticulously up-to-date.
-   Document security scanning procedures, encryption standards, and compliance requirements clearly.
-   Include examples of security reports and vulnerability assessments.

## 6. Specific Considerations for `security_audit`
-   **Security Critical**: This module handles sensitive security operations and must maintain the highest security standards.
-   **Encryption Standards**: Use only approved cryptographic algorithms and maintain proper key management.
-   **Compliance**: Ensure all functionality supports industry compliance requirements (OWASP, NIST, ISO).
-   **Accuracy**: Maintain comprehensive coverage while minimizing false positives in vulnerability detection.

## 7. Final Check for `security_audit`
-   Before finalizing changes, ensure all module-specific documentation is updated.
-   Verify that all tests for this module pass, especially security-related tests.
-   Confirm that security scanning produces accurate results and encryption operations are secure.
-   Test integration with related modules like `static_analysis` and `config_management`.
