django_agents.auditors
Django Agents Auditor Module.
This module provides comprehensive auditing capabilities for Django projects, including code quality analysis, security checks, and best practices validation.
The auditor system consists of:
- AuditReport: Report generation and formatting
- BaseAuditor: Base class for all auditors
- Various specialized auditors for different aspects of Django projects
Example
Basic usage of the auditor system:
from django_agents.auditors import AuditReport, CodebaseAuditor
report = AuditReport(output_format='markdown')
auditor = CodebaseAuditor()
result = auditor.audit()
report.add_section('Codebase Analysis', result)
print(report.generate())
Classes
Auditor for analyzing Django app structure and organization. |
|
|
Manages audit report generation and formatting. |
Base class for all auditor implementations. |
|
Auditor for analyzing project codebase structure and quality. |
|
Auditor for database models and migrations. |
|
Auditor for production deployment readiness. |
|
Auditor for server and deployment configuration. |
|
Auditor for analyzing Django settings and security configuration. |
|
Auditor for analyzing test coverage and quality. |
- class django_agents.auditors.AuditReport(output_format='text')[source]
Manages audit report generation and formatting.
This class collects audit results from multiple auditors and generates formatted reports in various output formats (text, markdown, JSON, HTML).
- Parameters:
output_format (str) – Output format for the report. Options: ‘text’, ‘markdown’, ‘json’, ‘html’. Defaults to ‘text’.
Example
>>> report = AuditReport(output_format='markdown') >>> report.add_section('Security', {'critical': ['Issue 1']}) >>> print(report.generate())
- __init__(output_format='text')[source]
Initialize the audit report.
- Parameters:
output_format (str, optional) – Format for output generation. Defaults to ‘text’.
- class django_agents.auditors.BaseAuditor[source]
Base class for all auditor implementations.
This abstract class provides the foundation for creating specialized auditors that analyze different aspects of Django projects.
Note
Subclasses must implement the
audit()method to perform specific audit operations.- audit()[source]
Perform the audit operation.
This method must be implemented by subclasses to perform specific audit checks.
- Returns:
Audit results from
get_result().- Return type:
- Raises:
NotImplementedError – If not implemented by subclass.
- class django_agents.auditors.CodebaseAuditor[source]
Auditor for analyzing project codebase structure and quality.
Performs comprehensive analysis of Python files, project structure, dependencies, and documentation.
- Checks include:
Project structure validation
Python file analysis (docstrings, function complexity)
Dependency management
Documentation presence
- class django_agents.auditors.TestsAuditor[source]
Auditor for analyzing test coverage and quality.
Examines test files, test functions, and testing frameworks to ensure adequate test coverage.
- Checks include:
Presence of test files
Number of test functions
Testing framework configuration (pytest, unittest)
Coverage tool installation
- class django_agents.auditors.AppsAuditor[source]
Auditor for analyzing Django app structure and organization.
Validates Django app configurations and checks for proper modular organization.
- Checks include:
Installed apps analysis
App structure validation
Required files in apps
Agent integration
- class django_agents.auditors.SettingsAuditor[source]
Auditor for analyzing Django settings and security configuration.
Performs security-focused analysis of Django settings including DEBUG mode, SECRET_KEY, security middleware, and database configuration.
- Checks include:
DEBUG mode status
SECRET_KEY security
ALLOWED_HOSTS configuration
Security middleware presence
Database configuration
Static/media files setup
- class django_agents.auditors.ProductionAuditor[source]
Auditor for production deployment readiness.
Analyzes the project for production deployment requirements including HTTPS configuration, deployment files, and security settings.
- Checks include:
DEBUG mode verification
Deployment configuration files
HTTPS/SSL settings
HSTS configuration
Logging configuration
Environment variable templates
- class django_agents.auditors.DatabaseAuditor[source]
Auditor for database models and migrations.
Analyzes Django models, migrations, and database optimization.
- Checks include:
Model count and structure
__str__ method presence
Migrations existence
Database indexes
- class django_agents.auditors.ServerAuditor[source]
Auditor for server and deployment configuration.
Analyzes server setup including WSGI/ASGI, web servers, and caching configuration.
- Checks include:
WSGI/ASGI file presence
Gunicorn installation
Static file serving (WhiteNoise)
Server configuration files
Cache configuration