attune-ai 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- attune/__init__.py +358 -0
- attune/adaptive/__init__.py +13 -0
- attune/adaptive/task_complexity.py +127 -0
- attune/agent_monitoring.py +414 -0
- attune/cache/__init__.py +117 -0
- attune/cache/base.py +166 -0
- attune/cache/dependency_manager.py +256 -0
- attune/cache/hash_only.py +251 -0
- attune/cache/hybrid.py +457 -0
- attune/cache/storage.py +285 -0
- attune/cache_monitor.py +356 -0
- attune/cache_stats.py +298 -0
- attune/cli/__init__.py +152 -0
- attune/cli/__main__.py +12 -0
- attune/cli/commands/__init__.py +1 -0
- attune/cli/commands/batch.py +264 -0
- attune/cli/commands/cache.py +248 -0
- attune/cli/commands/help.py +331 -0
- attune/cli/commands/info.py +140 -0
- attune/cli/commands/inspect.py +436 -0
- attune/cli/commands/inspection.py +57 -0
- attune/cli/commands/memory.py +48 -0
- attune/cli/commands/metrics.py +92 -0
- attune/cli/commands/orchestrate.py +184 -0
- attune/cli/commands/patterns.py +207 -0
- attune/cli/commands/profiling.py +202 -0
- attune/cli/commands/provider.py +98 -0
- attune/cli/commands/routing.py +285 -0
- attune/cli/commands/setup.py +96 -0
- attune/cli/commands/status.py +235 -0
- attune/cli/commands/sync.py +166 -0
- attune/cli/commands/tier.py +121 -0
- attune/cli/commands/utilities.py +114 -0
- attune/cli/commands/workflow.py +579 -0
- attune/cli/core.py +32 -0
- attune/cli/parsers/__init__.py +68 -0
- attune/cli/parsers/batch.py +118 -0
- attune/cli/parsers/cache.py +65 -0
- attune/cli/parsers/help.py +41 -0
- attune/cli/parsers/info.py +26 -0
- attune/cli/parsers/inspect.py +66 -0
- attune/cli/parsers/metrics.py +42 -0
- attune/cli/parsers/orchestrate.py +61 -0
- attune/cli/parsers/patterns.py +54 -0
- attune/cli/parsers/provider.py +40 -0
- attune/cli/parsers/routing.py +110 -0
- attune/cli/parsers/setup.py +42 -0
- attune/cli/parsers/status.py +47 -0
- attune/cli/parsers/sync.py +31 -0
- attune/cli/parsers/tier.py +33 -0
- attune/cli/parsers/workflow.py +77 -0
- attune/cli/utils/__init__.py +1 -0
- attune/cli/utils/data.py +242 -0
- attune/cli/utils/helpers.py +68 -0
- attune/cli_legacy.py +3957 -0
- attune/cli_minimal.py +1159 -0
- attune/cli_router.py +437 -0
- attune/cli_unified.py +814 -0
- attune/config/__init__.py +66 -0
- attune/config/xml_config.py +286 -0
- attune/config.py +545 -0
- attune/coordination.py +870 -0
- attune/core.py +1511 -0
- attune/core_modules/__init__.py +15 -0
- attune/cost_tracker.py +626 -0
- attune/dashboard/__init__.py +41 -0
- attune/dashboard/app.py +512 -0
- attune/dashboard/simple_server.py +435 -0
- attune/dashboard/standalone_server.py +547 -0
- attune/discovery.py +306 -0
- attune/emergence.py +306 -0
- attune/exceptions.py +123 -0
- attune/feedback_loops.py +373 -0
- attune/hot_reload/README.md +473 -0
- attune/hot_reload/__init__.py +62 -0
- attune/hot_reload/config.py +83 -0
- attune/hot_reload/integration.py +229 -0
- attune/hot_reload/reloader.py +298 -0
- attune/hot_reload/watcher.py +183 -0
- attune/hot_reload/websocket.py +177 -0
- attune/levels.py +577 -0
- attune/leverage_points.py +441 -0
- attune/logging_config.py +261 -0
- attune/mcp/__init__.py +10 -0
- attune/mcp/server.py +506 -0
- attune/memory/__init__.py +237 -0
- attune/memory/claude_memory.py +469 -0
- attune/memory/config.py +224 -0
- attune/memory/control_panel.py +1290 -0
- attune/memory/control_panel_support.py +145 -0
- attune/memory/cross_session.py +845 -0
- attune/memory/edges.py +179 -0
- attune/memory/encryption.py +159 -0
- attune/memory/file_session.py +770 -0
- attune/memory/graph.py +570 -0
- attune/memory/long_term.py +913 -0
- attune/memory/long_term_types.py +99 -0
- attune/memory/mixins/__init__.py +25 -0
- attune/memory/mixins/backend_init_mixin.py +249 -0
- attune/memory/mixins/capabilities_mixin.py +208 -0
- attune/memory/mixins/handoff_mixin.py +208 -0
- attune/memory/mixins/lifecycle_mixin.py +49 -0
- attune/memory/mixins/long_term_mixin.py +352 -0
- attune/memory/mixins/promotion_mixin.py +109 -0
- attune/memory/mixins/short_term_mixin.py +182 -0
- attune/memory/nodes.py +179 -0
- attune/memory/redis_bootstrap.py +540 -0
- attune/memory/security/__init__.py +31 -0
- attune/memory/security/audit_logger.py +932 -0
- attune/memory/security/pii_scrubber.py +640 -0
- attune/memory/security/secrets_detector.py +678 -0
- attune/memory/short_term.py +2192 -0
- attune/memory/simple_storage.py +302 -0
- attune/memory/storage/__init__.py +15 -0
- attune/memory/storage_backend.py +167 -0
- attune/memory/summary_index.py +583 -0
- attune/memory/types.py +446 -0
- attune/memory/unified.py +182 -0
- attune/meta_workflows/__init__.py +74 -0
- attune/meta_workflows/agent_creator.py +248 -0
- attune/meta_workflows/builtin_templates.py +567 -0
- attune/meta_workflows/cli_commands/__init__.py +56 -0
- attune/meta_workflows/cli_commands/agent_commands.py +321 -0
- attune/meta_workflows/cli_commands/analytics_commands.py +442 -0
- attune/meta_workflows/cli_commands/config_commands.py +232 -0
- attune/meta_workflows/cli_commands/memory_commands.py +182 -0
- attune/meta_workflows/cli_commands/template_commands.py +354 -0
- attune/meta_workflows/cli_commands/workflow_commands.py +382 -0
- attune/meta_workflows/cli_meta_workflows.py +59 -0
- attune/meta_workflows/form_engine.py +292 -0
- attune/meta_workflows/intent_detector.py +409 -0
- attune/meta_workflows/models.py +569 -0
- attune/meta_workflows/pattern_learner.py +738 -0
- attune/meta_workflows/plan_generator.py +384 -0
- attune/meta_workflows/session_context.py +397 -0
- attune/meta_workflows/template_registry.py +229 -0
- attune/meta_workflows/workflow.py +984 -0
- attune/metrics/__init__.py +12 -0
- attune/metrics/collector.py +31 -0
- attune/metrics/prompt_metrics.py +194 -0
- attune/models/__init__.py +172 -0
- attune/models/__main__.py +13 -0
- attune/models/adaptive_routing.py +437 -0
- attune/models/auth_cli.py +444 -0
- attune/models/auth_strategy.py +450 -0
- attune/models/cli.py +655 -0
- attune/models/empathy_executor.py +354 -0
- attune/models/executor.py +257 -0
- attune/models/fallback.py +762 -0
- attune/models/provider_config.py +282 -0
- attune/models/registry.py +472 -0
- attune/models/tasks.py +359 -0
- attune/models/telemetry/__init__.py +71 -0
- attune/models/telemetry/analytics.py +594 -0
- attune/models/telemetry/backend.py +196 -0
- attune/models/telemetry/data_models.py +431 -0
- attune/models/telemetry/storage.py +489 -0
- attune/models/token_estimator.py +420 -0
- attune/models/validation.py +280 -0
- attune/monitoring/__init__.py +52 -0
- attune/monitoring/alerts.py +946 -0
- attune/monitoring/alerts_cli.py +448 -0
- attune/monitoring/multi_backend.py +271 -0
- attune/monitoring/otel_backend.py +362 -0
- attune/optimization/__init__.py +19 -0
- attune/optimization/context_optimizer.py +272 -0
- attune/orchestration/__init__.py +67 -0
- attune/orchestration/agent_templates.py +707 -0
- attune/orchestration/config_store.py +499 -0
- attune/orchestration/execution_strategies.py +2111 -0
- attune/orchestration/meta_orchestrator.py +1168 -0
- attune/orchestration/pattern_learner.py +696 -0
- attune/orchestration/real_tools.py +931 -0
- attune/pattern_cache.py +187 -0
- attune/pattern_library.py +542 -0
- attune/patterns/debugging/all_patterns.json +81 -0
- attune/patterns/debugging/workflow_20260107_1770825e.json +77 -0
- attune/patterns/refactoring_memory.json +89 -0
- attune/persistence.py +564 -0
- attune/platform_utils.py +265 -0
- attune/plugins/__init__.py +28 -0
- attune/plugins/base.py +361 -0
- attune/plugins/registry.py +268 -0
- attune/project_index/__init__.py +32 -0
- attune/project_index/cli.py +335 -0
- attune/project_index/index.py +667 -0
- attune/project_index/models.py +504 -0
- attune/project_index/reports.py +474 -0
- attune/project_index/scanner.py +777 -0
- attune/project_index/scanner_parallel.py +291 -0
- attune/prompts/__init__.py +61 -0
- attune/prompts/config.py +77 -0
- attune/prompts/context.py +177 -0
- attune/prompts/parser.py +285 -0
- attune/prompts/registry.py +313 -0
- attune/prompts/templates.py +208 -0
- attune/redis_config.py +302 -0
- attune/redis_memory.py +799 -0
- attune/resilience/__init__.py +56 -0
- attune/resilience/circuit_breaker.py +256 -0
- attune/resilience/fallback.py +179 -0
- attune/resilience/health.py +300 -0
- attune/resilience/retry.py +209 -0
- attune/resilience/timeout.py +135 -0
- attune/routing/__init__.py +43 -0
- attune/routing/chain_executor.py +433 -0
- attune/routing/classifier.py +217 -0
- attune/routing/smart_router.py +234 -0
- attune/routing/workflow_registry.py +343 -0
- attune/scaffolding/README.md +589 -0
- attune/scaffolding/__init__.py +35 -0
- attune/scaffolding/__main__.py +14 -0
- attune/scaffolding/cli.py +240 -0
- attune/scaffolding/templates/base_wizard.py.jinja2 +121 -0
- attune/scaffolding/templates/coach_wizard.py.jinja2 +321 -0
- attune/scaffolding/templates/domain_wizard.py.jinja2 +408 -0
- attune/scaffolding/templates/linear_flow_wizard.py.jinja2 +203 -0
- attune/socratic/__init__.py +256 -0
- attune/socratic/ab_testing.py +958 -0
- attune/socratic/blueprint.py +533 -0
- attune/socratic/cli.py +703 -0
- attune/socratic/collaboration.py +1114 -0
- attune/socratic/domain_templates.py +924 -0
- attune/socratic/embeddings.py +738 -0
- attune/socratic/engine.py +794 -0
- attune/socratic/explainer.py +682 -0
- attune/socratic/feedback.py +772 -0
- attune/socratic/forms.py +629 -0
- attune/socratic/generator.py +732 -0
- attune/socratic/llm_analyzer.py +637 -0
- attune/socratic/mcp_server.py +702 -0
- attune/socratic/session.py +312 -0
- attune/socratic/storage.py +667 -0
- attune/socratic/success.py +730 -0
- attune/socratic/visual_editor.py +860 -0
- attune/socratic/web_ui.py +958 -0
- attune/telemetry/__init__.py +39 -0
- attune/telemetry/agent_coordination.py +475 -0
- attune/telemetry/agent_tracking.py +367 -0
- attune/telemetry/approval_gates.py +545 -0
- attune/telemetry/cli.py +1231 -0
- attune/telemetry/commands/__init__.py +14 -0
- attune/telemetry/commands/dashboard_commands.py +696 -0
- attune/telemetry/event_streaming.py +409 -0
- attune/telemetry/feedback_loop.py +567 -0
- attune/telemetry/usage_tracker.py +591 -0
- attune/templates.py +754 -0
- attune/test_generator/__init__.py +38 -0
- attune/test_generator/__main__.py +14 -0
- attune/test_generator/cli.py +234 -0
- attune/test_generator/generator.py +355 -0
- attune/test_generator/risk_analyzer.py +216 -0
- attune/test_generator/templates/unit_test.py.jinja2 +272 -0
- attune/tier_recommender.py +384 -0
- attune/tools.py +183 -0
- attune/trust/__init__.py +28 -0
- attune/trust/circuit_breaker.py +579 -0
- attune/trust_building.py +527 -0
- attune/validation/__init__.py +19 -0
- attune/validation/xml_validator.py +281 -0
- attune/vscode_bridge.py +173 -0
- attune/workflow_commands.py +780 -0
- attune/workflow_patterns/__init__.py +33 -0
- attune/workflow_patterns/behavior.py +249 -0
- attune/workflow_patterns/core.py +76 -0
- attune/workflow_patterns/output.py +99 -0
- attune/workflow_patterns/registry.py +255 -0
- attune/workflow_patterns/structural.py +288 -0
- attune/workflows/__init__.py +539 -0
- attune/workflows/autonomous_test_gen.py +1268 -0
- attune/workflows/base.py +2667 -0
- attune/workflows/batch_processing.py +342 -0
- attune/workflows/bug_predict.py +1084 -0
- attune/workflows/builder.py +273 -0
- attune/workflows/caching.py +253 -0
- attune/workflows/code_review.py +1048 -0
- attune/workflows/code_review_adapters.py +312 -0
- attune/workflows/code_review_pipeline.py +722 -0
- attune/workflows/config.py +645 -0
- attune/workflows/dependency_check.py +644 -0
- attune/workflows/document_gen/__init__.py +25 -0
- attune/workflows/document_gen/config.py +30 -0
- attune/workflows/document_gen/report_formatter.py +162 -0
- attune/workflows/document_gen/workflow.py +1426 -0
- attune/workflows/document_manager.py +216 -0
- attune/workflows/document_manager_README.md +134 -0
- attune/workflows/documentation_orchestrator.py +1205 -0
- attune/workflows/history.py +510 -0
- attune/workflows/keyboard_shortcuts/__init__.py +39 -0
- attune/workflows/keyboard_shortcuts/generators.py +391 -0
- attune/workflows/keyboard_shortcuts/parsers.py +416 -0
- attune/workflows/keyboard_shortcuts/prompts.py +295 -0
- attune/workflows/keyboard_shortcuts/schema.py +193 -0
- attune/workflows/keyboard_shortcuts/workflow.py +509 -0
- attune/workflows/llm_base.py +363 -0
- attune/workflows/manage_docs.py +87 -0
- attune/workflows/manage_docs_README.md +134 -0
- attune/workflows/manage_documentation.py +821 -0
- attune/workflows/new_sample_workflow1.py +149 -0
- attune/workflows/new_sample_workflow1_README.md +150 -0
- attune/workflows/orchestrated_health_check.py +849 -0
- attune/workflows/orchestrated_release_prep.py +600 -0
- attune/workflows/output.py +413 -0
- attune/workflows/perf_audit.py +863 -0
- attune/workflows/pr_review.py +762 -0
- attune/workflows/progress.py +785 -0
- attune/workflows/progress_server.py +322 -0
- attune/workflows/progressive/README 2.md +454 -0
- attune/workflows/progressive/README.md +454 -0
- attune/workflows/progressive/__init__.py +82 -0
- attune/workflows/progressive/cli.py +219 -0
- attune/workflows/progressive/core.py +488 -0
- attune/workflows/progressive/orchestrator.py +723 -0
- attune/workflows/progressive/reports.py +520 -0
- attune/workflows/progressive/telemetry.py +274 -0
- attune/workflows/progressive/test_gen.py +495 -0
- attune/workflows/progressive/workflow.py +589 -0
- attune/workflows/refactor_plan.py +694 -0
- attune/workflows/release_prep.py +895 -0
- attune/workflows/release_prep_crew.py +969 -0
- attune/workflows/research_synthesis.py +404 -0
- attune/workflows/routing.py +168 -0
- attune/workflows/secure_release.py +593 -0
- attune/workflows/security_adapters.py +297 -0
- attune/workflows/security_audit.py +1329 -0
- attune/workflows/security_audit_phase3.py +355 -0
- attune/workflows/seo_optimization.py +633 -0
- attune/workflows/step_config.py +234 -0
- attune/workflows/telemetry_mixin.py +269 -0
- attune/workflows/test5.py +125 -0
- attune/workflows/test5_README.md +158 -0
- attune/workflows/test_coverage_boost_crew.py +849 -0
- attune/workflows/test_gen/__init__.py +52 -0
- attune/workflows/test_gen/ast_analyzer.py +249 -0
- attune/workflows/test_gen/config.py +88 -0
- attune/workflows/test_gen/data_models.py +38 -0
- attune/workflows/test_gen/report_formatter.py +289 -0
- attune/workflows/test_gen/test_templates.py +381 -0
- attune/workflows/test_gen/workflow.py +655 -0
- attune/workflows/test_gen.py +54 -0
- attune/workflows/test_gen_behavioral.py +477 -0
- attune/workflows/test_gen_parallel.py +341 -0
- attune/workflows/test_lifecycle.py +526 -0
- attune/workflows/test_maintenance.py +627 -0
- attune/workflows/test_maintenance_cli.py +590 -0
- attune/workflows/test_maintenance_crew.py +840 -0
- attune/workflows/test_runner.py +622 -0
- attune/workflows/tier_tracking.py +531 -0
- attune/workflows/xml_enhanced_crew.py +285 -0
- attune_ai-2.0.0.dist-info/METADATA +1026 -0
- attune_ai-2.0.0.dist-info/RECORD +457 -0
- attune_ai-2.0.0.dist-info/WHEEL +5 -0
- attune_ai-2.0.0.dist-info/entry_points.txt +26 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE +201 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +101 -0
- attune_ai-2.0.0.dist-info/top_level.txt +5 -0
- attune_healthcare/__init__.py +13 -0
- attune_healthcare/monitors/__init__.py +9 -0
- attune_healthcare/monitors/clinical_protocol_monitor.py +315 -0
- attune_healthcare/monitors/monitoring/__init__.py +44 -0
- attune_healthcare/monitors/monitoring/protocol_checker.py +300 -0
- attune_healthcare/monitors/monitoring/protocol_loader.py +214 -0
- attune_healthcare/monitors/monitoring/sensor_parsers.py +306 -0
- attune_healthcare/monitors/monitoring/trajectory_analyzer.py +389 -0
- attune_llm/README.md +553 -0
- attune_llm/__init__.py +28 -0
- attune_llm/agent_factory/__init__.py +53 -0
- attune_llm/agent_factory/adapters/__init__.py +85 -0
- attune_llm/agent_factory/adapters/autogen_adapter.py +312 -0
- attune_llm/agent_factory/adapters/crewai_adapter.py +483 -0
- attune_llm/agent_factory/adapters/haystack_adapter.py +298 -0
- attune_llm/agent_factory/adapters/langchain_adapter.py +362 -0
- attune_llm/agent_factory/adapters/langgraph_adapter.py +333 -0
- attune_llm/agent_factory/adapters/native.py +228 -0
- attune_llm/agent_factory/adapters/wizard_adapter.py +423 -0
- attune_llm/agent_factory/base.py +305 -0
- attune_llm/agent_factory/crews/__init__.py +67 -0
- attune_llm/agent_factory/crews/code_review.py +1113 -0
- attune_llm/agent_factory/crews/health_check.py +1262 -0
- attune_llm/agent_factory/crews/refactoring.py +1128 -0
- attune_llm/agent_factory/crews/security_audit.py +1018 -0
- attune_llm/agent_factory/decorators.py +287 -0
- attune_llm/agent_factory/factory.py +558 -0
- attune_llm/agent_factory/framework.py +193 -0
- attune_llm/agent_factory/memory_integration.py +328 -0
- attune_llm/agent_factory/resilient.py +320 -0
- attune_llm/agents_md/__init__.py +22 -0
- attune_llm/agents_md/loader.py +218 -0
- attune_llm/agents_md/parser.py +271 -0
- attune_llm/agents_md/registry.py +307 -0
- attune_llm/claude_memory.py +466 -0
- attune_llm/cli/__init__.py +8 -0
- attune_llm/cli/sync_claude.py +487 -0
- attune_llm/code_health.py +1313 -0
- attune_llm/commands/__init__.py +51 -0
- attune_llm/commands/context.py +375 -0
- attune_llm/commands/loader.py +301 -0
- attune_llm/commands/models.py +231 -0
- attune_llm/commands/parser.py +371 -0
- attune_llm/commands/registry.py +429 -0
- attune_llm/config/__init__.py +29 -0
- attune_llm/config/unified.py +291 -0
- attune_llm/context/__init__.py +22 -0
- attune_llm/context/compaction.py +455 -0
- attune_llm/context/manager.py +434 -0
- attune_llm/contextual_patterns.py +361 -0
- attune_llm/core.py +907 -0
- attune_llm/git_pattern_extractor.py +435 -0
- attune_llm/hooks/__init__.py +24 -0
- attune_llm/hooks/config.py +306 -0
- attune_llm/hooks/executor.py +289 -0
- attune_llm/hooks/registry.py +302 -0
- attune_llm/hooks/scripts/__init__.py +39 -0
- attune_llm/hooks/scripts/evaluate_session.py +201 -0
- attune_llm/hooks/scripts/first_time_init.py +285 -0
- attune_llm/hooks/scripts/pre_compact.py +207 -0
- attune_llm/hooks/scripts/session_end.py +183 -0
- attune_llm/hooks/scripts/session_start.py +163 -0
- attune_llm/hooks/scripts/suggest_compact.py +225 -0
- attune_llm/learning/__init__.py +30 -0
- attune_llm/learning/evaluator.py +438 -0
- attune_llm/learning/extractor.py +514 -0
- attune_llm/learning/storage.py +560 -0
- attune_llm/levels.py +227 -0
- attune_llm/pattern_confidence.py +414 -0
- attune_llm/pattern_resolver.py +272 -0
- attune_llm/pattern_summary.py +350 -0
- attune_llm/providers.py +967 -0
- attune_llm/routing/__init__.py +32 -0
- attune_llm/routing/model_router.py +362 -0
- attune_llm/security/IMPLEMENTATION_SUMMARY.md +413 -0
- attune_llm/security/PHASE2_COMPLETE.md +384 -0
- attune_llm/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +271 -0
- attune_llm/security/QUICK_REFERENCE.md +316 -0
- attune_llm/security/README.md +262 -0
- attune_llm/security/__init__.py +62 -0
- attune_llm/security/audit_logger.py +929 -0
- attune_llm/security/audit_logger_example.py +152 -0
- attune_llm/security/pii_scrubber.py +640 -0
- attune_llm/security/secrets_detector.py +678 -0
- attune_llm/security/secrets_detector_example.py +304 -0
- attune_llm/security/secure_memdocs.py +1192 -0
- attune_llm/security/secure_memdocs_example.py +278 -0
- attune_llm/session_status.py +745 -0
- attune_llm/state.py +246 -0
- attune_llm/utils/__init__.py +5 -0
- attune_llm/utils/tokens.py +349 -0
- attune_software/SOFTWARE_PLUGIN_README.md +57 -0
- attune_software/__init__.py +13 -0
- attune_software/cli/__init__.py +120 -0
- attune_software/cli/inspect.py +362 -0
- attune_software/cli.py +574 -0
- attune_software/plugin.py +188 -0
- workflow_scaffolding/__init__.py +11 -0
- workflow_scaffolding/__main__.py +12 -0
- workflow_scaffolding/cli.py +206 -0
- workflow_scaffolding/generator.py +265 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# Audit Logger Quick Reference
|
|
2
|
+
|
|
3
|
+
## Import
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from attune_llm.security import AuditLogger
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Initialize
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
# Production
|
|
13
|
+
logger = AuditLogger(log_dir="/var/log/empathy")
|
|
14
|
+
|
|
15
|
+
# Development
|
|
16
|
+
logger = AuditLogger(log_dir="./logs", enable_console_logging=True)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Log Events
|
|
20
|
+
|
|
21
|
+
### LLM Request
|
|
22
|
+
```python
|
|
23
|
+
logger.log_llm_request(
|
|
24
|
+
user_id="user@company.com",
|
|
25
|
+
empathy_level=3,
|
|
26
|
+
provider="anthropic",
|
|
27
|
+
model="claude-sonnet-4",
|
|
28
|
+
memory_sources=["enterprise", "user", "project"],
|
|
29
|
+
pii_count=0,
|
|
30
|
+
secrets_count=0
|
|
31
|
+
)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Pattern Storage
|
|
35
|
+
```python
|
|
36
|
+
logger.log_pattern_store(
|
|
37
|
+
user_id="user@company.com",
|
|
38
|
+
pattern_id="pattern_123",
|
|
39
|
+
pattern_type="architecture",
|
|
40
|
+
classification="INTERNAL", # PUBLIC, INTERNAL, or SENSITIVE
|
|
41
|
+
pii_scrubbed=2,
|
|
42
|
+
retention_days=180
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Pattern Retrieval
|
|
47
|
+
```python
|
|
48
|
+
logger.log_pattern_retrieve(
|
|
49
|
+
user_id="user@company.com",
|
|
50
|
+
pattern_id="pattern_123",
|
|
51
|
+
classification="INTERNAL",
|
|
52
|
+
access_granted=True
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Security Violation
|
|
57
|
+
```python
|
|
58
|
+
logger.log_security_violation(
|
|
59
|
+
user_id="user@company.com",
|
|
60
|
+
violation_type="secrets_detected",
|
|
61
|
+
severity="HIGH", # LOW, MEDIUM, HIGH, or CRITICAL
|
|
62
|
+
details={"secret_type": "api_key"},
|
|
63
|
+
blocked=True
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Query Logs
|
|
68
|
+
|
|
69
|
+
### Basic Queries
|
|
70
|
+
```python
|
|
71
|
+
# By event type
|
|
72
|
+
events = logger.query(event_type="llm_request")
|
|
73
|
+
|
|
74
|
+
# By user
|
|
75
|
+
events = logger.query(user_id="user@company.com")
|
|
76
|
+
|
|
77
|
+
# By status
|
|
78
|
+
events = logger.query(status="failed")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Date Range
|
|
82
|
+
```python
|
|
83
|
+
from datetime import datetime, timedelta
|
|
84
|
+
|
|
85
|
+
events = logger.query(
|
|
86
|
+
start_date=datetime.utcnow() - timedelta(days=7),
|
|
87
|
+
end_date=datetime.utcnow()
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Nested Filters
|
|
92
|
+
```python
|
|
93
|
+
# Patterns with >5 PII items scrubbed
|
|
94
|
+
events = logger.query(
|
|
95
|
+
event_type="store_pattern",
|
|
96
|
+
security__pii_scrubbed__gt=5
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Failed requests with secrets
|
|
100
|
+
events = logger.query(
|
|
101
|
+
event_type="llm_request",
|
|
102
|
+
status="failed",
|
|
103
|
+
security__secrets_detected__gt=0
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Comparison Operators
|
|
108
|
+
- `__gt`: greater than
|
|
109
|
+
- `__gte`: greater than or equal
|
|
110
|
+
- `__lt`: less than
|
|
111
|
+
- `__lte`: less than or equal
|
|
112
|
+
- `__ne`: not equal
|
|
113
|
+
|
|
114
|
+
## Reports
|
|
115
|
+
|
|
116
|
+
### Violation Summary
|
|
117
|
+
```python
|
|
118
|
+
summary = logger.get_violation_summary(user_id="user@company.com")
|
|
119
|
+
print(f"Total: {summary['total_violations']}")
|
|
120
|
+
print(f"By type: {summary['by_type']}")
|
|
121
|
+
print(f"By severity: {summary['by_severity']}")
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Compliance Report
|
|
125
|
+
```python
|
|
126
|
+
report = logger.get_compliance_report(
|
|
127
|
+
start_date=datetime.utcnow() - timedelta(days=30)
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
print(f"LLM requests: {report['llm_requests']['total']}")
|
|
131
|
+
print(f"Pattern storage: {report['pattern_storage']['total']}")
|
|
132
|
+
print(f"GDPR compliance: {report['compliance_metrics']['gdpr_compliant_rate']:.2%}")
|
|
133
|
+
print(f"HIPAA compliance: {report['compliance_metrics']['hipaa_compliant_rate']:.2%}")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Log Format
|
|
137
|
+
|
|
138
|
+
Each line in `audit.jsonl`:
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"event_id": "evt_abc123",
|
|
142
|
+
"timestamp": "2025-11-24T19:03:08.114456Z",
|
|
143
|
+
"version": "1.0",
|
|
144
|
+
"event_type": "llm_request",
|
|
145
|
+
"user_id": "user@company.com",
|
|
146
|
+
"status": "success",
|
|
147
|
+
"llm": { "provider": "anthropic", "model": "claude-sonnet-4", "empathy_level": 3 },
|
|
148
|
+
"security": { "pii_detected": 0, "secrets_detected": 0 },
|
|
149
|
+
"compliance": { "gdpr_compliant": true, "hipaa_compliant": true }
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Configuration Options
|
|
154
|
+
|
|
155
|
+
```python
|
|
156
|
+
AuditLogger(
|
|
157
|
+
log_dir="/var/log/empathy", # Log directory
|
|
158
|
+
log_filename="audit.jsonl", # Log file name
|
|
159
|
+
max_file_size_mb=100, # Max file size before rotation
|
|
160
|
+
retention_days=365, # Days to retain logs
|
|
161
|
+
enable_rotation=True, # Enable automatic rotation
|
|
162
|
+
enable_console_logging=False # Also log to console
|
|
163
|
+
)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Common Patterns
|
|
167
|
+
|
|
168
|
+
### Integration with EmpathyLLM
|
|
169
|
+
```python
|
|
170
|
+
from attune_llm import EmpathyLLM
|
|
171
|
+
|
|
172
|
+
audit_logger = AuditLogger()
|
|
173
|
+
llm = EmpathyLLM(provider="anthropic")
|
|
174
|
+
|
|
175
|
+
async def interact_with_audit(user_id, user_input):
|
|
176
|
+
response = await llm.interact(user_id, user_input, {})
|
|
177
|
+
|
|
178
|
+
audit_logger.log_llm_request(
|
|
179
|
+
user_id=user_id,
|
|
180
|
+
empathy_level=response["empathy_level"],
|
|
181
|
+
provider="anthropic",
|
|
182
|
+
model="claude-sonnet-4",
|
|
183
|
+
memory_sources=["enterprise", "user"],
|
|
184
|
+
pii_count=0,
|
|
185
|
+
secrets_count=0
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
return response
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Daily Compliance Check
|
|
192
|
+
```python
|
|
193
|
+
from datetime import datetime, timedelta
|
|
194
|
+
|
|
195
|
+
# Generate yesterday's report
|
|
196
|
+
report = logger.get_compliance_report(
|
|
197
|
+
start_date=datetime.utcnow() - timedelta(days=1)
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
# Alert if compliance drops
|
|
201
|
+
if report['compliance_metrics']['gdpr_compliant_rate'] < 0.95:
|
|
202
|
+
send_alert("GDPR compliance below 95%")
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Monitor Security Violations
|
|
206
|
+
```python
|
|
207
|
+
# Check recent violations
|
|
208
|
+
violations = logger.query(
|
|
209
|
+
event_type="security_violation",
|
|
210
|
+
start_date=datetime.utcnow() - timedelta(hours=24)
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
# Alert on critical violations
|
|
214
|
+
for v in violations:
|
|
215
|
+
if v['violation']['severity'] == 'CRITICAL':
|
|
216
|
+
send_alert(f"Critical violation: {v['violation']['type']}")
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Event Types Reference
|
|
220
|
+
|
|
221
|
+
| Event Type | Purpose | Key Fields |
|
|
222
|
+
|------------|---------|------------|
|
|
223
|
+
| `llm_request` | LLM API calls | provider, model, empathy_level, pii_detected, secrets_detected |
|
|
224
|
+
| `store_pattern` | Pattern storage | pattern_id, classification, pii_scrubbed, encrypted |
|
|
225
|
+
| `retrieve_pattern` | Pattern access | pattern_id, classification, access_granted |
|
|
226
|
+
| `security_violation` | Policy violations | violation_type, severity, blocked |
|
|
227
|
+
|
|
228
|
+
## Classification Levels
|
|
229
|
+
|
|
230
|
+
| Level | Use Case | Encryption | Retention |
|
|
231
|
+
|-------|----------|------------|-----------|
|
|
232
|
+
| `PUBLIC` | General patterns, shareable | No | 365 days |
|
|
233
|
+
| `INTERNAL` | Company confidential | Optional | 180 days |
|
|
234
|
+
| `SENSITIVE` | HIPAA/PCI-DSS data | Required | 90 days |
|
|
235
|
+
|
|
236
|
+
## Compliance Mapping
|
|
237
|
+
|
|
238
|
+
| Standard | Requirement | Implementation |
|
|
239
|
+
|----------|-------------|----------------|
|
|
240
|
+
| **SOC2** CC7.2 | System Monitoring | Comprehensive audit logging |
|
|
241
|
+
| **HIPAA** §164.312(b) | Audit Controls | Tamper-evident logs |
|
|
242
|
+
| **GDPR** Art. 30 | Records of Processing | Complete audit trail |
|
|
243
|
+
|
|
244
|
+
## Troubleshooting
|
|
245
|
+
|
|
246
|
+
### Logs not being created
|
|
247
|
+
```python
|
|
248
|
+
# Check directory permissions
|
|
249
|
+
import os
|
|
250
|
+
print(os.access("/var/log/empathy", os.W_OK))
|
|
251
|
+
|
|
252
|
+
# Use fallback directory
|
|
253
|
+
logger = AuditLogger(log_dir="./logs")
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Query not returning results
|
|
257
|
+
```python
|
|
258
|
+
# Check log file exists
|
|
259
|
+
print(logger.log_path.exists())
|
|
260
|
+
|
|
261
|
+
# Check query filters
|
|
262
|
+
events = logger.query(limit=10) # Get first 10
|
|
263
|
+
print(f"Total events: {len(events)}")
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Performance issues
|
|
267
|
+
```python
|
|
268
|
+
# Use date ranges to limit scan
|
|
269
|
+
events = logger.query(
|
|
270
|
+
start_date=datetime.utcnow() - timedelta(days=1),
|
|
271
|
+
limit=1000
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
# Enable rotation to prevent large files
|
|
275
|
+
logger = AuditLogger(
|
|
276
|
+
max_file_size_mb=50, # Smaller files
|
|
277
|
+
enable_rotation=True
|
|
278
|
+
)
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## Testing
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Run tests
|
|
285
|
+
cd attune_llm/security
|
|
286
|
+
python3 -m pytest test_audit_logger.py -v
|
|
287
|
+
|
|
288
|
+
# Run example
|
|
289
|
+
python3 audit_logger_example.py
|
|
290
|
+
|
|
291
|
+
# View logs
|
|
292
|
+
cat logs/audit.jsonl | jq '.'
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Security Best Practices
|
|
296
|
+
|
|
297
|
+
1. **Never log actual PII or secrets** - only counts
|
|
298
|
+
2. **Use restrictive permissions** - 0700 for directory, 0600 for files
|
|
299
|
+
3. **Enable rotation** - prevent unlimited growth
|
|
300
|
+
4. **Monitor violations** - alert on CRITICAL severity
|
|
301
|
+
5. **Regular compliance reports** - daily or weekly
|
|
302
|
+
6. **Retain logs appropriately** - 365 days for compliance
|
|
303
|
+
7. **Back up logs** - store in secure, separate location
|
|
304
|
+
|
|
305
|
+
## Support
|
|
306
|
+
|
|
307
|
+
- **Documentation**: `README.md`
|
|
308
|
+
- **Implementation Summary**: `IMPLEMENTATION_SUMMARY.md`
|
|
309
|
+
- **Architecture**: `../../SECURE_MEMORY_ARCHITECTURE.md`
|
|
310
|
+
- **Tests**: `test_audit_logger.py`
|
|
311
|
+
- **Example**: `audit_logger_example.py`
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
**Version**: 1.0.0
|
|
316
|
+
**License**: Fair Source 0.9
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Security Module
|
|
2
|
+
|
|
3
|
+
Enterprise-grade security controls for the Empathy Framework, including secrets detection, PII scrubbing, audit logging, and data classification.
|
|
4
|
+
|
|
5
|
+
## Phase 2: Secrets Detection (v1.8.0-beta) ✅
|
|
6
|
+
|
|
7
|
+
### Overview
|
|
8
|
+
|
|
9
|
+
The `SecretsDetector` module provides comprehensive detection of hardcoded secrets, credentials, and sensitive data in code and configuration files. It's designed for enterprise privacy integration with:
|
|
10
|
+
|
|
11
|
+
- **20+ built-in patterns** for common secret types
|
|
12
|
+
- **Entropy analysis** for unknown high-entropy strings
|
|
13
|
+
- **Custom pattern support** for organization-specific secrets
|
|
14
|
+
- **Zero secret leakage**: Returns only metadata, never actual secret values
|
|
15
|
+
- **High performance**: Compiled regex patterns with early exit
|
|
16
|
+
|
|
17
|
+
### Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from attune_llm.security import SecretsDetector
|
|
21
|
+
|
|
22
|
+
# Initialize detector
|
|
23
|
+
detector = SecretsDetector()
|
|
24
|
+
|
|
25
|
+
# Scan content for secrets
|
|
26
|
+
code = """
|
|
27
|
+
ANTHROPIC_API_KEY = "sk-ant-api03-abc123..."
|
|
28
|
+
password = "my_secret_pass"
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
detections = detector.detect(code)
|
|
32
|
+
|
|
33
|
+
for detection in detections:
|
|
34
|
+
print(f"Found {detection.secret_type.value} at line {detection.line_number}")
|
|
35
|
+
print(f" Severity: {detection.severity.value}")
|
|
36
|
+
print(f" Context: {detection.context_snippet}")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Supported Secret Types
|
|
40
|
+
|
|
41
|
+
#### API Keys
|
|
42
|
+
- Anthropic API keys (`sk-ant-...`)
|
|
43
|
+
- OpenAI API keys (`sk-...`)
|
|
44
|
+
- AWS Access Keys (`AKIA...`)
|
|
45
|
+
- AWS Secret Keys
|
|
46
|
+
- GitHub tokens (`ghp_...`, `gho_...`, etc.)
|
|
47
|
+
- Slack tokens (`xox[abprs]-...`)
|
|
48
|
+
- Stripe keys (`sk_live_...`, `pk_live_...`)
|
|
49
|
+
- Generic API key patterns
|
|
50
|
+
|
|
51
|
+
#### Passwords
|
|
52
|
+
- Password assignments (`password = "..."`)
|
|
53
|
+
- Basic Auth credentials (base64 encoded)
|
|
54
|
+
|
|
55
|
+
#### Private Keys
|
|
56
|
+
- RSA private keys
|
|
57
|
+
- SSH private keys (OpenSSH format)
|
|
58
|
+
- EC (Elliptic Curve) private keys
|
|
59
|
+
- PGP private keys
|
|
60
|
+
- TLS/SSL certificate keys
|
|
61
|
+
|
|
62
|
+
#### Tokens
|
|
63
|
+
- JWT tokens (`eyJ...`)
|
|
64
|
+
- OAuth access tokens
|
|
65
|
+
- Bearer tokens
|
|
66
|
+
|
|
67
|
+
#### Database
|
|
68
|
+
- Database connection URLs (PostgreSQL, MySQL, MongoDB, Redis)
|
|
69
|
+
- Connection strings
|
|
70
|
+
|
|
71
|
+
#### High Entropy Strings
|
|
72
|
+
- Automatically detects random-looking strings (potential secrets)
|
|
73
|
+
- Configurable entropy threshold (default: 4.5)
|
|
74
|
+
- Minimum length requirement (default: 20 characters)
|
|
75
|
+
|
|
76
|
+
### Advanced Features
|
|
77
|
+
|
|
78
|
+
#### Custom Patterns
|
|
79
|
+
|
|
80
|
+
Add organization-specific secret patterns:
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
detector = SecretsDetector()
|
|
84
|
+
|
|
85
|
+
# Add custom pattern
|
|
86
|
+
detector.add_custom_pattern(
|
|
87
|
+
name="acme_api_key",
|
|
88
|
+
pattern=r"acme_[a-zA-Z0-9]{32}",
|
|
89
|
+
severity="high"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Detect with custom pattern
|
|
93
|
+
detections = detector.detect("acme_1234567890abcdefghijklmnopqrst")
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Entropy Analysis
|
|
97
|
+
|
|
98
|
+
Control high-entropy string detection:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
detector = SecretsDetector(
|
|
102
|
+
enable_entropy_analysis=True,
|
|
103
|
+
entropy_threshold=4.5, # Shannon entropy threshold
|
|
104
|
+
min_entropy_length=20 # Minimum string length
|
|
105
|
+
)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Detection Metadata
|
|
109
|
+
|
|
110
|
+
The `SecretDetection` object provides rich metadata without exposing secrets:
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
detection = detections[0]
|
|
114
|
+
|
|
115
|
+
print(detection.secret_type) # SecretType.ANTHROPIC_API_KEY
|
|
116
|
+
print(detection.severity) # Severity.HIGH
|
|
117
|
+
print(detection.line_number) # 3
|
|
118
|
+
print(detection.column_start) # 20
|
|
119
|
+
print(detection.column_end) # 95
|
|
120
|
+
print(detection.context_snippet) # "ANTHROPIC_API_KEY = [REDACTED]"
|
|
121
|
+
print(detection.confidence) # 1.0 (for pattern matches)
|
|
122
|
+
print(detection.metadata) # {"custom_pattern": "acme_api_key"}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### Statistics
|
|
126
|
+
|
|
127
|
+
Get detector configuration and pattern counts:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
stats = detector.get_statistics()
|
|
131
|
+
print(stats)
|
|
132
|
+
# {
|
|
133
|
+
# "builtin_patterns": 20,
|
|
134
|
+
# "custom_patterns": 2,
|
|
135
|
+
# "total_patterns": 22,
|
|
136
|
+
# "entropy_analysis_enabled": True,
|
|
137
|
+
# "entropy_threshold": 4.5,
|
|
138
|
+
# "min_entropy_length": 20
|
|
139
|
+
# }
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Security Guarantees
|
|
143
|
+
|
|
144
|
+
1. **No Secret Leakage**: The detector NEVER logs or returns actual secret values
|
|
145
|
+
2. **Redaction**: Context snippets replace secrets with `[REDACTED]`
|
|
146
|
+
3. **Metadata Only**: Detection objects contain only type, location, and severity
|
|
147
|
+
4. **Audit Safe**: All outputs are safe to log without exposing credentials
|
|
148
|
+
|
|
149
|
+
### Performance
|
|
150
|
+
|
|
151
|
+
- **Compiled Patterns**: All regex patterns are pre-compiled for speed
|
|
152
|
+
- **Early Exit**: Detection stops on first match for each pattern
|
|
153
|
+
- **Large Files**: Tested with 10,000+ line files (completes < 5 seconds)
|
|
154
|
+
- **Efficient Entropy**: Entropy analysis only runs on quoted strings
|
|
155
|
+
|
|
156
|
+
### Integration Example
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
from attune_llm.security import SecretsDetector
|
|
160
|
+
|
|
161
|
+
def scan_file(file_path: str) -> bool:
|
|
162
|
+
"""
|
|
163
|
+
Scan a file for secrets.
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
True if no secrets found, False otherwise
|
|
167
|
+
"""
|
|
168
|
+
detector = SecretsDetector()
|
|
169
|
+
|
|
170
|
+
with open(file_path, 'r') as f:
|
|
171
|
+
content = f.read()
|
|
172
|
+
|
|
173
|
+
detections = detector.detect(content)
|
|
174
|
+
|
|
175
|
+
if detections:
|
|
176
|
+
print(f"⚠️ Found {len(detections)} secrets in {file_path}")
|
|
177
|
+
|
|
178
|
+
for d in detections:
|
|
179
|
+
print(f" - {d.secret_type.value} (Line {d.line_number})")
|
|
180
|
+
print(f" Severity: {d.severity.value}")
|
|
181
|
+
print(f" Context: {d.context_snippet}")
|
|
182
|
+
|
|
183
|
+
return False
|
|
184
|
+
|
|
185
|
+
print(f"✓ No secrets found in {file_path}")
|
|
186
|
+
return True
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Testing
|
|
190
|
+
|
|
191
|
+
Comprehensive test suite with 28 tests covering:
|
|
192
|
+
- All secret type detections
|
|
193
|
+
- Custom pattern support
|
|
194
|
+
- Entropy analysis
|
|
195
|
+
- Secret redaction
|
|
196
|
+
- Edge cases and error handling
|
|
197
|
+
- Performance benchmarks
|
|
198
|
+
|
|
199
|
+
Run tests:
|
|
200
|
+
```bash
|
|
201
|
+
pytest attune_llm/security/test_secrets_detector.py -v
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Compliance
|
|
205
|
+
|
|
206
|
+
This module supports enterprise compliance requirements:
|
|
207
|
+
|
|
208
|
+
- **OWASP Top 10 A02:2021**: Cryptographic Failures (secret detection)
|
|
209
|
+
- **GDPR Article 32**: Security of processing (protect credentials)
|
|
210
|
+
- **SOC2 CC6.1**: Logical access controls (prevent hardcoded secrets)
|
|
211
|
+
- **HIPAA §164.312(a)(1)**: Access control (credential management)
|
|
212
|
+
|
|
213
|
+
### Architecture
|
|
214
|
+
|
|
215
|
+
```
|
|
216
|
+
SecretsDetector
|
|
217
|
+
├── Built-in Patterns (20+)
|
|
218
|
+
│ ├── API Keys (Anthropic, OpenAI, AWS, GitHub, Slack, Stripe)
|
|
219
|
+
│ ├── Passwords (various assignment patterns)
|
|
220
|
+
│ ├── Private Keys (RSA, SSH, EC, PGP, TLS)
|
|
221
|
+
│ ├── Tokens (JWT, OAuth, Bearer)
|
|
222
|
+
│ └── Database (connection strings, URLs)
|
|
223
|
+
├── Custom Patterns
|
|
224
|
+
│ └── Organization-specific patterns
|
|
225
|
+
├── Entropy Analysis
|
|
226
|
+
│ ├── Shannon entropy calculation
|
|
227
|
+
│ ├── Configurable threshold
|
|
228
|
+
│ └── Overlap filtering
|
|
229
|
+
└── Detection Output
|
|
230
|
+
├── SecretType enum
|
|
231
|
+
├── Severity enum (CRITICAL, HIGH, MEDIUM, LOW)
|
|
232
|
+
└── SecretDetection dataclass
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Future Enhancements
|
|
236
|
+
|
|
237
|
+
Planned for Phase 3 (v1.8.0):
|
|
238
|
+
- Integration with CI/CD pipelines (pre-commit hooks)
|
|
239
|
+
- Git history scanning
|
|
240
|
+
- Secret redaction/replacement utilities
|
|
241
|
+
- Real-time monitoring with alerting
|
|
242
|
+
- Integration with secret management systems (HashiCorp Vault, AWS Secrets Manager)
|
|
243
|
+
|
|
244
|
+
### References
|
|
245
|
+
|
|
246
|
+
- [OWASP Secrets Management](https://owasp.org/www-community/vulnerabilities/Use_of_hard-coded_password)
|
|
247
|
+
- [GitHub Secret Scanning](https://docs.github.com/en/code-security/secret-scanning)
|
|
248
|
+
- [SECURE_MEMORY_ARCHITECTURE.md](../../../SECURE_MEMORY_ARCHITECTURE.md)
|
|
249
|
+
- [Enterprise Security Policy](../../../examples/claude_memory/enterprise-CLAUDE-secure.md)
|
|
250
|
+
|
|
251
|
+
### Support
|
|
252
|
+
|
|
253
|
+
For questions or issues:
|
|
254
|
+
- File an issue on GitHub
|
|
255
|
+
- Contact the Empathy Framework team
|
|
256
|
+
- See main documentation at `attune_llm/README.md`
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
**Author**: Empathy Framework Team
|
|
261
|
+
**Version**: 1.8.0-beta
|
|
262
|
+
**License**: Fair Source 0.9
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Security Module for Empathy Framework
|
|
2
|
+
|
|
3
|
+
DEPRECATED: This module re-exports from attune.memory.security
|
|
4
|
+
Use `from attune.memory.security import ...` instead.
|
|
5
|
+
|
|
6
|
+
Provides enterprise-grade security controls including:
|
|
7
|
+
- PII scrubbing (GDPR, HIPAA, SOC2 compliant)
|
|
8
|
+
- Secrets detection (API keys, passwords, private keys)
|
|
9
|
+
- Audit logging (tamper-evident, SOC2/HIPAA compliant)
|
|
10
|
+
- Secure MemDocs integration with encryption
|
|
11
|
+
|
|
12
|
+
Author: Empathy Framework Team
|
|
13
|
+
Version: 2.0.0 (consolidated into attune.memory)
|
|
14
|
+
License: Fair Source 0.9
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
# Re-export from consolidated memory module for backwards compatibility
|
|
18
|
+
from attune.memory.long_term import (
|
|
19
|
+
Classification,
|
|
20
|
+
ClassificationRules,
|
|
21
|
+
EncryptionManager,
|
|
22
|
+
PatternMetadata,
|
|
23
|
+
SecureMemDocsIntegration,
|
|
24
|
+
SecurityError,
|
|
25
|
+
)
|
|
26
|
+
from attune.memory.security import (
|
|
27
|
+
AuditEvent,
|
|
28
|
+
AuditLogger,
|
|
29
|
+
PIIDetection,
|
|
30
|
+
PIIPattern,
|
|
31
|
+
PIIScrubber,
|
|
32
|
+
SecretDetection,
|
|
33
|
+
SecretsDetector,
|
|
34
|
+
SecretType,
|
|
35
|
+
SecurityViolation,
|
|
36
|
+
Severity,
|
|
37
|
+
detect_secrets,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
__all__ = [
|
|
41
|
+
"AuditEvent",
|
|
42
|
+
# Audit Logging
|
|
43
|
+
"AuditLogger",
|
|
44
|
+
"Classification",
|
|
45
|
+
"ClassificationRules",
|
|
46
|
+
"EncryptionManager",
|
|
47
|
+
"PIIDetection",
|
|
48
|
+
"PIIPattern",
|
|
49
|
+
# PII Scrubbing
|
|
50
|
+
"PIIScrubber",
|
|
51
|
+
"PatternMetadata",
|
|
52
|
+
"SecretDetection",
|
|
53
|
+
"SecretType",
|
|
54
|
+
# Secrets Detection
|
|
55
|
+
"SecretsDetector",
|
|
56
|
+
# Secure MemDocs Integration
|
|
57
|
+
"SecureMemDocsIntegration",
|
|
58
|
+
"SecurityError",
|
|
59
|
+
"SecurityViolation",
|
|
60
|
+
"Severity",
|
|
61
|
+
"detect_secrets",
|
|
62
|
+
]
|