icdev 1.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.
- icdev/__init__.py +18 -0
- icdev/_paths.py +85 -0
- icdev/_version.py +3 -0
- icdev/data/__init__.py +1 -0
- icdev/data/args/__init__.py +1 -0
- icdev/data/args/agent_authority.yaml +61 -0
- icdev/data/args/agent_config.yaml +355 -0
- icdev/data/args/agentic_fitness.yaml +31 -0
- icdev/data/args/ai_governance_config.yaml +137 -0
- icdev/data/args/atlas_critique_config.yaml +66 -0
- icdev/data/args/bedrock_models.yaml +63 -0
- icdev/data/args/cicd_config.yaml +82 -0
- icdev/data/args/classification_config.yaml +232 -0
- icdev/data/args/cli_config.yaml +154 -0
- icdev/data/args/cloud_config.yaml +63 -0
- icdev/data/args/code_pattern_config.yaml +151 -0
- icdev/data/args/code_quality_config.yaml +47 -0
- icdev/data/args/companion_registry.yaml +202 -0
- icdev/data/args/context_config.yaml +82 -0
- icdev/data/args/csp_monitor_config.yaml +268 -0
- icdev/data/args/cui_markings.yaml +35 -0
- icdev/data/args/db_config.yaml +40 -0
- icdev/data/args/deployment_profiles.yaml +248 -0
- icdev/data/args/dev_profile_config.yaml +144 -0
- icdev/data/args/devsecops_config.yaml +286 -0
- icdev/data/args/endpoint_security_config.yaml +137 -0
- icdev/data/args/extension_config.yaml +79 -0
- icdev/data/args/file_access_tiers.yaml +88 -0
- icdev/data/args/framework_registry.yaml +415 -0
- icdev/data/args/innovation_config.yaml +431 -0
- icdev/data/args/installation_manifest.yaml +1087 -0
- icdev/data/args/llm_config.yaml +495 -0
- icdev/data/args/maintenance_config.yaml +55 -0
- icdev/data/args/memory_config.yaml +83 -0
- icdev/data/args/monitoring_config.yaml +127 -0
- icdev/data/args/mosa_config.yaml +190 -0
- icdev/data/args/nlq_config.yaml +35 -0
- icdev/data/args/observability_config.yaml +39 -0
- icdev/data/args/observability_tracing_config.yaml +170 -0
- icdev/data/args/oscal_tools_config.yaml +43 -0
- icdev/data/args/owasp_agentic_config.yaml +171 -0
- icdev/data/args/phase_registry.yaml +618 -0
- icdev/data/args/project_defaults.yaml +235 -0
- icdev/data/args/prompt_chains.yaml +163 -0
- icdev/data/args/resilience_config.yaml +50 -0
- icdev/data/args/ricoas_config.yaml +191 -0
- icdev/data/args/role_personas.yaml +362 -0
- icdev/data/args/scaling_config.yaml +176 -0
- icdev/data/args/security_gates.yaml +685 -0
- icdev/data/args/skill_injection_config.yaml +322 -0
- icdev/data/args/spec_config.yaml +53 -0
- icdev/data/args/supply_chain_config.yaml +76 -0
- icdev/data/args/translation_config.yaml +228 -0
- icdev/data/args/workflow_templates/ato_acceleration.yaml +54 -0
- icdev/data/args/workflow_templates/build_deploy.yaml +63 -0
- icdev/data/args/workflow_templates/full_compliance.yaml +43 -0
- icdev/data/args/workflow_templates/security_hardening.yaml +55 -0
- icdev/data/args/worktree_config.yaml +34 -0
- icdev/data/args/zta_config.yaml +247 -0
- icdev/data/context/__init__.py +1 -0
- icdev/data/context/agent/__init__.py +1 -0
- icdev/data/context/agent/response_schemas/__init__.py +1 -0
- icdev/data/context/agent/response_schemas/debate_position.json +46 -0
- icdev/data/context/agent/response_schemas/fitness_scorecard.json +74 -0
- icdev/data/context/agent/response_schemas/review_decision.json +39 -0
- icdev/data/context/agent/response_schemas/task_decomposition.json +82 -0
- icdev/data/context/agent/response_schemas/veto_decision.json +40 -0
- icdev/data/context/agentic/__init__.py +1 -0
- icdev/data/context/agentic/architecture_patterns.md +269 -0
- icdev/data/context/agentic/capability_registry.yaml +202 -0
- icdev/data/context/agentic/csp_mcp_registry.yaml +280 -0
- icdev/data/context/agentic/fitness_rubric.md +56 -0
- icdev/data/context/agentic/governance_baseline.md +205 -0
- icdev/data/context/ci/__init__.py +1 -0
- icdev/data/context/ci/worktree_templates.json +44 -0
- icdev/data/context/cloud/__init__.py +1 -0
- icdev/data/context/cloud/csp_service_registry.json +739 -0
- icdev/data/context/compliance/__init__.py +1 -0
- icdev/data/context/compliance/atlas_mitigations.json +293 -0
- icdev/data/context/compliance/atlas_techniques.json +833 -0
- icdev/data/context/compliance/cisa_sbd_requirements.json +432 -0
- icdev/data/context/compliance/cjis_security_policy.json +522 -0
- icdev/data/context/compliance/cmmc_practices.json +2494 -0
- icdev/data/context/compliance/cmmc_report_template.md +142 -0
- icdev/data/context/compliance/cnssi_1253_overlay.json +109 -0
- icdev/data/context/compliance/control_crosswalk.json +1914 -0
- icdev/data/context/compliance/control_families/__init__.py +1 -0
- icdev/data/context/compliance/csp_certifications.json +251 -0
- icdev/data/context/compliance/cssp_report_template.md +193 -0
- icdev/data/context/compliance/cui_templates/__init__.py +1 -0
- icdev/data/context/compliance/cui_templates/banner_block.txt +4 -0
- icdev/data/context/compliance/cui_templates/code_header.txt +8 -0
- icdev/data/context/compliance/cui_templates/document_template.md +35 -0
- icdev/data/context/compliance/data_type_framework_map.json +321 -0
- icdev/data/context/compliance/data_type_registry.json +147 -0
- icdev/data/context/compliance/dod_cssp_8530.json +463 -0
- icdev/data/context/compliance/eu_ai_act_annex_iii.json +108 -0
- icdev/data/context/compliance/export_templates/__init__.py +1 -0
- icdev/data/context/compliance/export_templates/emass_controls.csv.j2 +4 -0
- icdev/data/context/compliance/export_templates/evidence_package.md.j2 +39 -0
- icdev/data/context/compliance/export_templates/executive_summary.md.j2 +55 -0
- icdev/data/context/compliance/export_templates/poam_tracking.csv.j2 +4 -0
- icdev/data/context/compliance/fedramp_20x_ksi_schemas.json +133 -0
- icdev/data/context/compliance/fedramp_high_baseline.json +4370 -0
- icdev/data/context/compliance/fedramp_moderate_baseline.json +2183 -0
- icdev/data/context/compliance/fedramp_report_template.md +181 -0
- icdev/data/context/compliance/fips_200_areas.json +362 -0
- icdev/data/context/compliance/gao_ai_accountability.json +262 -0
- icdev/data/context/compliance/hipaa_security_rule.json +720 -0
- icdev/data/context/compliance/hitrust_csf_v11.json +930 -0
- icdev/data/context/compliance/impact_level_profiles.json +251 -0
- icdev/data/context/compliance/incident_response_template.md +1110 -0
- icdev/data/context/compliance/iso27001_2022_controls.json +750 -0
- icdev/data/context/compliance/iso27001_nist_bridge.json +382 -0
- icdev/data/context/compliance/iso42001_controls.json +254 -0
- icdev/data/context/compliance/ivv_checklist_template.md +80 -0
- icdev/data/context/compliance/ivv_report_template.md +116 -0
- icdev/data/context/compliance/ivv_requirements.json +372 -0
- icdev/data/context/compliance/mosa_crosswalk.json +327 -0
- icdev/data/context/compliance/mosa_framework.json +250 -0
- icdev/data/context/compliance/narrative_templates/AC.md.j2 +101 -0
- icdev/data/context/compliance/narrative_templates/AU.md.j2 +106 -0
- icdev/data/context/compliance/narrative_templates/IA.md.j2 +104 -0
- icdev/data/context/compliance/narrative_templates/SC.md.j2 +102 -0
- icdev/data/context/compliance/narrative_templates/SI.md.j2 +111 -0
- icdev/data/context/compliance/narrative_templates/__init__.py +1 -0
- icdev/data/context/compliance/narrative_templates/default.md.j2 +50 -0
- icdev/data/context/compliance/narrative_templates/executive_summary.j2 +27 -0
- icdev/data/context/compliance/narrative_templates/poam_milestone.j2 +19 -0
- icdev/data/context/compliance/narrative_templates/ssp_section.j2 +11 -0
- icdev/data/context/compliance/nist_800_171_controls.json +1552 -0
- icdev/data/context/compliance/nist_800_207_crosswalk.json +399 -0
- icdev/data/context/compliance/nist_800_207_zta.json +258 -0
- icdev/data/context/compliance/nist_800_53.json +324 -0
- icdev/data/context/compliance/nist_ai_600_1_genai.json +326 -0
- icdev/data/context/compliance/nist_ai_rmf.json +206 -0
- icdev/data/context/compliance/nist_sp_800_60_types.json +1667 -0
- icdev/data/context/compliance/omb_m25_21_high_impact_ai.json +248 -0
- icdev/data/context/compliance/omb_m26_04_unbiased_ai.json +262 -0
- icdev/data/context/compliance/owasp_agentic_asi.json +133 -0
- icdev/data/context/compliance/owasp_agentic_threats.json +285 -0
- icdev/data/context/compliance/owasp_llm_top10.json +274 -0
- icdev/data/context/compliance/pci_dss_v4.json +510 -0
- icdev/data/context/compliance/poam_template.md +117 -0
- icdev/data/context/compliance/safeai_controls.json +512 -0
- icdev/data/context/compliance/sbd_report_template.md +77 -0
- icdev/data/context/compliance/siem_config_templates/__init__.py +1 -0
- icdev/data/context/compliance/siem_config_templates/filebeat.yml +213 -0
- icdev/data/context/compliance/siem_config_templates/log_sources.json +208 -0
- icdev/data/context/compliance/soc2_trust_criteria.json +661 -0
- icdev/data/context/compliance/ssp_template.md +432 -0
- icdev/data/context/compliance/stig_templates/__init__.py +1 -0
- icdev/data/context/compliance/stig_templates/webapp_stig.json +139 -0
- icdev/data/context/compliance/xai_requirements.json +108 -0
- icdev/data/context/dashboard/__init__.py +1 -0
- icdev/data/context/dashboard/nlq_examples.json +50 -0
- icdev/data/context/dashboard/schema_descriptions.json +23 -0
- icdev/data/context/integration/__init__.py +1 -0
- icdev/data/context/integration/approval_workflows.json +32 -0
- icdev/data/context/integration/gitlab_field_mappings.json +33 -0
- icdev/data/context/integration/jira_field_mappings.json +32 -0
- icdev/data/context/integration/reqif_export_schema.json +23 -0
- icdev/data/context/integration/servicenow_field_mappings.json +22 -0
- icdev/data/context/languages/__init__.py +1 -0
- icdev/data/context/languages/framework_patterns.json +205 -0
- icdev/data/context/languages/language_registry.json +279 -0
- icdev/data/context/llm/__init__.py +1 -0
- icdev/data/context/llm/example_provider.py +86 -0
- icdev/data/context/mbse/__init__.py +1 -0
- icdev/data/context/mbse/des_report_template.md +162 -0
- icdev/data/context/mbse/des_requirements.json +411 -0
- icdev/data/context/mbse/digital_thread_patterns.json +403 -0
- icdev/data/context/mbse/reqif_schema.json +280 -0
- icdev/data/context/mbse/sysml_element_types.json +432 -0
- icdev/data/context/modernization/__init__.py +1 -0
- icdev/data/context/modernization/db_type_mappings.json +148 -0
- icdev/data/context/modernization/decomposition_patterns.json +284 -0
- icdev/data/context/modernization/framework_migration_patterns.json +359 -0
- icdev/data/context/modernization/migration_report_template.md +168 -0
- icdev/data/context/modernization/seven_rs_catalog.json +369 -0
- icdev/data/context/modernization/version_upgrade_rules.json +279 -0
- icdev/data/context/oscal/NIST_SP-800-53_rev5_catalog.json +254987 -0
- icdev/data/context/oscal/README.md +43 -0
- icdev/data/context/patterns/__init__.py +1 -0
- icdev/data/context/profiles/__init__.py +1 -0
- icdev/data/context/profiles/dod_baseline_v1.yaml +145 -0
- icdev/data/context/profiles/fedramp_baseline_v1.yaml +143 -0
- icdev/data/context/profiles/financial_baseline_v1.yaml +142 -0
- icdev/data/context/profiles/healthcare_baseline_v1.yaml +135 -0
- icdev/data/context/profiles/law_enforcement_v1.yaml +129 -0
- icdev/data/context/profiles/startup_v1.yaml +134 -0
- icdev/data/context/requirements/__init__.py +1 -0
- icdev/data/context/requirements/ambiguity_patterns.json +97 -0
- icdev/data/context/requirements/boundary_impact_rules.json +123 -0
- icdev/data/context/requirements/default_constitutions.json +67 -0
- icdev/data/context/requirements/document_extraction_rules.json +58 -0
- icdev/data/context/requirements/gap_patterns.json +108 -0
- icdev/data/context/requirements/readiness_rubric.json +78 -0
- icdev/data/context/requirements/red_alternative_patterns.json +210 -0
- icdev/data/context/requirements/safe_templates.json +72 -0
- icdev/data/context/requirements/spec_quality_checklist.json +122 -0
- icdev/data/context/simulation/__init__.py +1 -0
- icdev/data/context/simulation/architecture_patterns.json +36 -0
- icdev/data/context/simulation/coa_templates.json +38 -0
- icdev/data/context/simulation/cost_models.json +23 -0
- icdev/data/context/simulation/risk_categories.json +46 -0
- icdev/data/context/supply_chain/__init__.py +1 -0
- icdev/data/context/supply_chain/isa_templates.json +129 -0
- icdev/data/context/supply_chain/nist_800_161_controls.json +247 -0
- icdev/data/context/supply_chain/scrm_risk_matrix.json +147 -0
- icdev/data/context/templates/__init__.py +1 -0
- icdev/data/context/templates/ansible/__init__.py +1 -0
- icdev/data/context/templates/ansible/playbooks/__init__.py +1 -0
- icdev/data/context/templates/ansible/roles/__init__.py +1 -0
- icdev/data/context/templates/gitlab_ci/__init__.py +1 -0
- icdev/data/context/templates/grafana/__init__.py +1 -0
- icdev/data/context/templates/kubernetes/__init__.py +1 -0
- icdev/data/context/templates/project/__init__.py +1 -0
- icdev/data/context/templates/project/api/__init__.py +1 -0
- icdev/data/context/templates/project/cli/__init__.py +1 -0
- icdev/data/context/templates/project/data_pipeline/__init__.py +1 -0
- icdev/data/context/templates/project/iac/__init__.py +1 -0
- icdev/data/context/templates/project/javascript_frontend/__init__.py +1 -0
- icdev/data/context/templates/project/javascript_frontend/src/__init__.py +1 -0
- icdev/data/context/templates/project/javascript_frontend/tests/__init__.py +1 -0
- icdev/data/context/templates/project/microservice/__init__.py +1 -0
- icdev/data/context/templates/project/python_backend/__init__.py +1 -0
- icdev/data/context/templates/project/python_backend/src/__init__.py +1 -0
- icdev/data/context/templates/project/python_backend/tests/__init__.py +1 -0
- icdev/data/context/templates/project/python_backend/tests/features/__init__.py +1 -0
- icdev/data/context/templates/project/python_backend/tests/steps/__init__.py +1 -0
- icdev/data/context/templates/terraform/__init__.py +1 -0
- icdev/data/context/templates/terraform/govcloud_base/__init__.py +1 -0
- icdev/data/context/templates/terraform/modules/__init__.py +1 -0
- icdev/data/context/tone/__init__.py +1 -0
- icdev/data/context/translation/dependency_mappings.json +186 -0
- icdev/data/context/translation/type_mappings.json +149 -0
- icdev/data/docs/README.md +187 -0
- icdev/data/docs/__init__.py +1 -0
- icdev/data/docs/admin/gateway-guide.md +338 -0
- icdev/data/docs/admin/marketplace-guide.md +396 -0
- icdev/data/docs/admin/monitoring-guide.md +509 -0
- icdev/data/docs/architecture/compliance-framework.md +764 -0
- icdev/data/docs/architecture/database-schema.md +689 -0
- icdev/data/docs/architecture/gotcha-framework.md +518 -0
- icdev/data/docs/architecture/multi-agent-system.md +603 -0
- icdev/data/docs/dx/README.md +106 -0
- icdev/data/docs/dx/__init__.py +1 -0
- icdev/data/docs/dx/ci-cd-integration.md +378 -0
- icdev/data/docs/dx/claude-code-guide.md +213 -0
- icdev/data/docs/dx/companion-guide.md +232 -0
- icdev/data/docs/dx/dev-profiles.md +309 -0
- icdev/data/docs/dx/icdev-yaml-spec.md +219 -0
- icdev/data/docs/dx/integration-tiers.md +279 -0
- icdev/data/docs/dx/llm-routing-guide.md +456 -0
- icdev/data/docs/dx/quickstart.md +192 -0
- icdev/data/docs/dx/sdk-reference.md +356 -0
- icdev/data/docs/dx/unified-mcp-setup.md +525 -0
- icdev/data/docs/features/__init__.py +1 -0
- icdev/data/docs/features/phase-01-gotcha-framework.md +249 -0
- icdev/data/docs/features/phase-02-atlas-build-workflow.md +223 -0
- icdev/data/docs/features/phase-03-tdd-bdd-testing.md +261 -0
- icdev/data/docs/features/phase-04-nist-compliance.md +255 -0
- icdev/data/docs/features/phase-05-security-scanning.md +229 -0
- icdev/data/docs/features/phase-06-infrastructure-deployment.md +288 -0
- icdev/data/docs/features/phase-07-code-review-gates.md +276 -0
- icdev/data/docs/features/phase-08-self-healing.md +223 -0
- icdev/data/docs/features/phase-09-monitoring-observability.md +230 -0
- icdev/data/docs/features/phase-10-dashboard-web-ui.md +218 -0
- icdev/data/docs/features/phase-11-multi-agent-architecture.md +272 -0
- icdev/data/docs/features/phase-12-integration-testing.md +228 -0
- icdev/data/docs/features/phase-13-cicd-integration.md +257 -0
- icdev/data/docs/features/phase-14-secure-by-design-ivv.md +240 -0
- icdev/data/docs/features/phase-15-maintenance-audit.md +192 -0
- icdev/data/docs/features/phase-16-ato-acceleration.md +228 -0
- icdev/data/docs/features/phase-17-multi-framework-compliance.md +223 -0
- icdev/data/docs/features/phase-18-mbse-integration.md +242 -0
- icdev/data/docs/features/phase-19-agentic-generation.md +202 -0
- icdev/data/docs/features/phase-20-fips-security-categorization.md +198 -0
- icdev/data/docs/features/phase-21-saas-multi-tenancy.md +273 -0
- icdev/data/docs/features/phase-22-federated-gotcha-marketplace.md +242 -0
- icdev/data/docs/features/phase-23-universal-compliance-platform.md +238 -0
- icdev/data/docs/features/phase-24-devsecops-pipeline-security.md +198 -0
- icdev/data/docs/features/phase-25-zero-trust-architecture.md +220 -0
- icdev/data/docs/features/phase-26-dod-mosa.md +205 -0
- icdev/data/docs/features/phase-27-cli-capabilities.md +222 -0
- icdev/data/docs/features/phase-28-remote-command-gateway.md +235 -0
- icdev/data/docs/features/phase-29-proactive-monitoring.md +212 -0
- icdev/data/docs/features/phase-30-dashboard-auth.md +215 -0
- icdev/data/docs/features/phase-31-dashboard-ux-low-impact.md +188 -0
- icdev/data/docs/features/phase-32-dashboard-ux-medium-impact.md +223 -0
- icdev/data/docs/features/phase-33-modular-installation.md +218 -0
- icdev/data/docs/features/phase-34-dev-profiles.md +239 -0
- icdev/data/docs/features/phase-35-innovation-engine.md +257 -0
- icdev/data/docs/features/phase-36-evolutionary-intelligence.md +351 -0
- icdev/data/docs/features/phase-37-mitre-atlas-integration.md +485 -0
- icdev/data/docs/features/phase-38-cloud-agnostic-architecture.md +1033 -0
- icdev/data/docs/features/phase-39-observability-operations.md +178 -0
- icdev/data/docs/features/phase-40-nlq-compliance-queries.md +176 -0
- icdev/data/docs/features/phase-41-parallel-cicd.md +169 -0
- icdev/data/docs/features/phase-42-framework-planning.md +177 -0
- icdev/data/docs/features/phase-43-cross-language-translation.md +225 -0
- icdev/data/docs/features/phase-44-innovation-adaptation.md +227 -0
- icdev/data/docs/features/phase-45-owasp-agentic-security.md +239 -0
- icdev/data/docs/features/phase-46-observability-traceability-xai.md +240 -0
- icdev/data/docs/features/phase-47-unified-mcp-gateway.md +257 -0
- icdev/data/docs/features/phase-48-ai-transparency.md +203 -0
- icdev/data/docs/features/phase-49-ai-accountability.md +243 -0
- icdev/data/docs/features/phase-50-ai-governance-intake-chat.md +195 -0
- icdev/data/docs/features/phase-51-unified-chat-dashboard.md +240 -0
- icdev/data/docs/features/phase-52-code-intelligence.md +244 -0
- icdev/data/docs/features/phase-53-fedramp-20x-owasp-asi.md +359 -0
- icdev/data/docs/features/phase-54-slsa-swft-orchestration.md +379 -0
- icdev/data/docs/features/phase-55-a2a-v03-mcp-oauth.md +322 -0
- icdev/data/docs/features/phase-56-evidence-lineage.md +352 -0
- icdev/data/docs/features/phase-57-eu-ai-act-iron-bank.md +319 -0
- icdev/data/docs/features/phase-58-creative-engine.md +370 -0
- icdev/data/docs/features/phase-59-govcon-intelligence.md +535 -0
- icdev/data/docs/features/phase-60-cpmp.md +528 -0
- icdev/data/docs/features/phase-61-orchestration-improvements.md +534 -0
- icdev/data/docs/operations/dashboard-guide.md +354 -0
- icdev/data/docs/operations/deployment-guide.md +556 -0
- icdev/data/docs/operations/saas-admin-guide.md +439 -0
- icdev/data/docs/operations/security-operations-guide.md +733 -0
- icdev/data/docs/runbooks/backup-restore.md +412 -0
- icdev/data/docs/runbooks/troubleshooting.md +499 -0
- icdev/data/features/__init__.py +1 -0
- icdev/data/features/cicd_integration.feature +41 -0
- icdev/data/features/compliance_gates.feature +46 -0
- icdev/data/features/dashboard.feature +72 -0
- icdev/data/features/environment.py +25 -0
- icdev/data/features/project_management.feature +32 -0
- icdev/data/features/requirements_intake.feature +42 -0
- icdev/data/features/saas_platform.feature +53 -0
- icdev/data/features/security_scanning.feature +36 -0
- icdev/data/features/steps/__init__.py +1 -0
- icdev/data/features/steps/cicd_steps.py +465 -0
- icdev/data/features/steps/compliance_steps.py +308 -0
- icdev/data/features/steps/dashboard_steps.py +88 -0
- icdev/data/features/steps/project_steps.py +126 -0
- icdev/data/features/steps/requirements_intake_steps.py +689 -0
- icdev/data/features/steps/saas_platform_steps.py +572 -0
- icdev/data/features/steps/security_steps.py +236 -0
- icdev/data/features/steps/testing_steps.py +226 -0
- icdev/data/features/testing_pipeline.feature +42 -0
- icdev/data/goals/__init__.py +1 -0
- icdev/data/goals/agent_management.md +144 -0
- icdev/data/goals/agentic_generation.md +345 -0
- icdev/data/goals/agentic_threat_model.md +309 -0
- icdev/data/goals/ai_accountability.md +90 -0
- icdev/data/goals/ai_governance_intake.md +132 -0
- icdev/data/goals/ai_transparency.md +76 -0
- icdev/data/goals/atlas_integration.md +405 -0
- icdev/data/goals/ato_acceleration.md +139 -0
- icdev/data/goals/boundary_supply_chain.md +206 -0
- icdev/data/goals/build_app.md +544 -0
- icdev/data/goals/cicd_integration.md +86 -0
- icdev/data/goals/claude_dir_maintenance.md +77 -0
- icdev/data/goals/cli_capabilities.md +340 -0
- icdev/data/goals/cloud_agnostic.md +312 -0
- icdev/data/goals/code_intelligence.md +197 -0
- icdev/data/goals/code_review.md +94 -0
- icdev/data/goals/compliance_workflow.md +858 -0
- icdev/data/goals/continuous_harmonization.md +140 -0
- icdev/data/goals/cross_language_translation.md +171 -0
- icdev/data/goals/dashboard.md +142 -0
- icdev/data/goals/deploy_workflow.md +390 -0
- icdev/data/goals/devsecops_workflow.md +408 -0
- icdev/data/goals/evolutionary_intelligence.md +305 -0
- icdev/data/goals/external_integration.md +113 -0
- icdev/data/goals/framework_planning.md +63 -0
- icdev/data/goals/init_project.md +235 -0
- icdev/data/goals/innovation_engine.md +199 -0
- icdev/data/goals/integration_testing.md +189 -0
- icdev/data/goals/maintenance_audit.md +196 -0
- icdev/data/goals/manifest.md +56 -0
- icdev/data/goals/mbse_integration.md +504 -0
- icdev/data/goals/modernization_workflow.md +618 -0
- icdev/data/goals/monitoring.md +126 -0
- icdev/data/goals/mosa_workflow.md +463 -0
- icdev/data/goals/multi_agent_orchestration.md +68 -0
- icdev/data/goals/nlq_compliance.md +63 -0
- icdev/data/goals/observability.md +64 -0
- icdev/data/goals/observability_traceability_xai.md +154 -0
- icdev/data/goals/owasp_agentic_security.md +395 -0
- icdev/data/goals/parallel_cicd.md +61 -0
- icdev/data/goals/requirements_intake.md +213 -0
- icdev/data/goals/sbd_ivv_workflow.md +195 -0
- icdev/data/goals/security_categorization.md +133 -0
- icdev/data/goals/security_scan.md +381 -0
- icdev/data/goals/self_healing.md +120 -0
- icdev/data/goals/simulation_engine.md +111 -0
- icdev/data/goals/tdd_workflow.md +403 -0
- icdev/data/goals/zero_trust_architecture.md +403 -0
- icdev/data/hardprompts/__init__.py +1 -0
- icdev/data/hardprompts/agent/__init__.py +1 -0
- icdev/data/hardprompts/agent/agentic_architect.md +100 -0
- icdev/data/hardprompts/agent/debate_prompt.md +32 -0
- icdev/data/hardprompts/agent/fitness_evaluation.md +48 -0
- icdev/data/hardprompts/agent/governance_review.md +214 -0
- icdev/data/hardprompts/agent/reviewer_prompt.md +34 -0
- icdev/data/hardprompts/agent/skill_design.md +172 -0
- icdev/data/hardprompts/agent/task_decomposition.md +275 -0
- icdev/data/hardprompts/agent/veto_check_prompt.md +33 -0
- icdev/data/hardprompts/architect/__init__.py +1 -0
- icdev/data/hardprompts/architect/api_design.md +283 -0
- icdev/data/hardprompts/architect/data_model.md +277 -0
- icdev/data/hardprompts/architect/system_design.md +180 -0
- icdev/data/hardprompts/builder/__init__.py +1 -0
- icdev/data/hardprompts/builder/code_generation.md +59 -0
- icdev/data/hardprompts/builder/refactor.md +58 -0
- icdev/data/hardprompts/builder/scaffold_project.md +69 -0
- icdev/data/hardprompts/builder/test_generation.md +87 -0
- icdev/data/hardprompts/ci/__init__.py +1 -0
- icdev/data/hardprompts/ci/worktree_setup.md +35 -0
- icdev/data/hardprompts/compliance/__init__.py +1 -0
- icdev/data/hardprompts/compliance/cmmc_assessment.md +63 -0
- icdev/data/hardprompts/compliance/cssp_assessment.md +75 -0
- icdev/data/hardprompts/compliance/cui_marking.md +86 -0
- icdev/data/hardprompts/compliance/fedramp_assessment.md +55 -0
- icdev/data/hardprompts/compliance/ivv_assessment.md +96 -0
- icdev/data/hardprompts/compliance/poam_generation.md +57 -0
- icdev/data/hardprompts/compliance/sbd_assessment.md +101 -0
- icdev/data/hardprompts/compliance/security_categorization.md +74 -0
- icdev/data/hardprompts/compliance/ssp_generation.md +56 -0
- icdev/data/hardprompts/compliance/stig_evaluation.md +63 -0
- icdev/data/hardprompts/dashboard/__init__.py +1 -0
- icdev/data/hardprompts/dashboard/nlq_system_prompt.md +26 -0
- icdev/data/hardprompts/infra/__init__.py +1 -0
- icdev/data/hardprompts/infra/k8s_manifests.md +118 -0
- icdev/data/hardprompts/infra/pipeline_generation.md +160 -0
- icdev/data/hardprompts/infra/terraform_generation.md +92 -0
- icdev/data/hardprompts/integration/__init__.py +1 -0
- icdev/data/hardprompts/integration/approval_review.md +17 -0
- icdev/data/hardprompts/integration/jira_mapping.md +25 -0
- icdev/data/hardprompts/integration/servicenow_mapping.md +14 -0
- icdev/data/hardprompts/knowledge/__init__.py +1 -0
- icdev/data/hardprompts/knowledge/pattern_detection.md +73 -0
- icdev/data/hardprompts/knowledge/recommendation_engine.md +90 -0
- icdev/data/hardprompts/knowledge/root_cause_analysis.md +91 -0
- icdev/data/hardprompts/maintenance/__init__.py +1 -0
- icdev/data/hardprompts/maintenance/maintenance_assessment.md +82 -0
- icdev/data/hardprompts/mbse/__init__.py +1 -0
- icdev/data/hardprompts/mbse/digital_thread.md +67 -0
- icdev/data/hardprompts/mbse/model_import.md +62 -0
- icdev/data/hardprompts/mbse/model_to_code.md +65 -0
- icdev/data/hardprompts/modernization/__init__.py +1 -0
- icdev/data/hardprompts/modernization/legacy_analysis.md +93 -0
- icdev/data/hardprompts/modernization/migration_planning.md +150 -0
- icdev/data/hardprompts/modernization/seven_r_assessment.md +107 -0
- icdev/data/hardprompts/requirements/__init__.py +1 -0
- icdev/data/hardprompts/requirements/bdd_generation.md +35 -0
- icdev/data/hardprompts/requirements/clarification_prioritization.md +29 -0
- icdev/data/hardprompts/requirements/decomposition.md +60 -0
- icdev/data/hardprompts/requirements/document_extraction.md +45 -0
- icdev/data/hardprompts/requirements/gap_detection.md +70 -0
- icdev/data/hardprompts/requirements/intake_conversation.md +101 -0
- icdev/data/hardprompts/requirements/readiness_assessment.md +39 -0
- icdev/data/hardprompts/requirements/spec_quality.md +33 -0
- icdev/data/hardprompts/requirements/traceability_analysis.md +23 -0
- icdev/data/hardprompts/security/__init__.py +1 -0
- icdev/data/hardprompts/security/endpoint_security.md +78 -0
- icdev/data/hardprompts/security/threat_model.md +70 -0
- icdev/data/hardprompts/security/vulnerability_assessment.md +81 -0
- icdev/data/hardprompts/simulation/__init__.py +1 -0
- icdev/data/hardprompts/simulation/architecture_impact.md +27 -0
- icdev/data/hardprompts/simulation/coa_alternative.md +27 -0
- icdev/data/hardprompts/simulation/coa_generation.md +25 -0
- icdev/data/hardprompts/simulation/compliance_impact.md +28 -0
- icdev/data/hardprompts/simulation/cost_estimation.md +33 -0
- icdev/data/hardprompts/simulation/risk_assessment.md +28 -0
- icdev/data/hardprompts/translation/code_translation.md +68 -0
- icdev/data/hardprompts/translation/dependency_suggestion.md +44 -0
- icdev/data/hardprompts/translation/test_translation.md +64 -0
- icdev/data/hardprompts/translation/translation_repair.md +59 -0
- icdev/py.typed +0 -0
- icdev/tools/__init__.py +1 -0
- icdev/tools/_gen_formatter.py +12 -0
- icdev/tools/a2a/__init__.py +1 -0
- icdev/tools/a2a/agent_cards/architect.json +43 -0
- icdev/tools/a2a/agent_cards/builder.json +50 -0
- icdev/tools/a2a/agent_cards/compliance.json +57 -0
- icdev/tools/a2a/agent_cards/devsecops.json +71 -0
- icdev/tools/a2a/agent_cards/infra.json +57 -0
- icdev/tools/a2a/agent_cards/integration.json +57 -0
- icdev/tools/a2a/agent_cards/knowledge.json +43 -0
- icdev/tools/a2a/agent_cards/mbse.json +57 -0
- icdev/tools/a2a/agent_cards/modernization.json +50 -0
- icdev/tools/a2a/agent_cards/monitor.json +43 -0
- icdev/tools/a2a/agent_cards/orchestrator.json +36 -0
- icdev/tools/a2a/agent_cards/requirements_analyst.json +64 -0
- icdev/tools/a2a/agent_cards/security.json +50 -0
- icdev/tools/a2a/agent_cards/simulation.json +57 -0
- icdev/tools/a2a/agent_cards/supply_chain.json +50 -0
- icdev/tools/a2a/agent_client.py +349 -0
- icdev/tools/a2a/agent_registry.py +412 -0
- icdev/tools/a2a/agent_server.py +579 -0
- icdev/tools/a2a/task.py +200 -0
- icdev/tools/agent/__init__.py +2 -0
- icdev/tools/agent/a2a_agent_card_generator.py +285 -0
- icdev/tools/agent/a2a_discovery_server.py +250 -0
- icdev/tools/agent/agent_executor.py +529 -0
- icdev/tools/agent/agent_memory.py +557 -0
- icdev/tools/agent/agent_models.py +51 -0
- icdev/tools/agent/atlas_critique.py +908 -0
- icdev/tools/agent/authority.py +443 -0
- icdev/tools/agent/bedrock_client.py +1075 -0
- icdev/tools/agent/collaboration.py +871 -0
- icdev/tools/agent/dispatcher_mode.py +665 -0
- icdev/tools/agent/mailbox.py +575 -0
- icdev/tools/agent/prompt_chain_executor.py +1064 -0
- icdev/tools/agent/session_purpose.py +350 -0
- icdev/tools/agent/skill_router.py +638 -0
- icdev/tools/agent/skill_selector.py +486 -0
- icdev/tools/agent/team_orchestrator.py +1108 -0
- icdev/tools/agent/token_tracker.py +290 -0
- icdev/tools/analysis/__init__.py +1 -0
- icdev/tools/analysis/code_analyzer.py +780 -0
- icdev/tools/analysis/runtime_feedback.py +389 -0
- icdev/tools/audit/__init__.py +1 -0
- icdev/tools/audit/audit_logger.py +196 -0
- icdev/tools/audit/audit_query.py +157 -0
- icdev/tools/audit/decision_recorder.py +72 -0
- icdev/tools/builder/__init__.py +1 -0
- icdev/tools/builder/agentic_fitness.py +534 -0
- icdev/tools/builder/agentic_test_templates/test_a2a_callback.py +117 -0
- icdev/tools/builder/agentic_test_templates/test_a2a_lifecycle.feature +52 -0
- icdev/tools/builder/agentic_test_templates/test_agent_card.feature +37 -0
- icdev/tools/builder/agentic_test_templates/test_agent_health.py +128 -0
- icdev/tools/builder/agentic_test_templates/test_memory_system.feature +50 -0
- icdev/tools/builder/agentic_test_templates/test_skill_execution.feature +40 -0
- icdev/tools/builder/app_blueprint.py +1583 -0
- icdev/tools/builder/child_app_generator.py +2852 -0
- icdev/tools/builder/claude_md_generator.py +1734 -0
- icdev/tools/builder/code_generator.py +3703 -0
- icdev/tools/builder/db_init_generator.py +1709 -0
- icdev/tools/builder/dev_profile_manager.py +954 -0
- icdev/tools/builder/formatter.py +768 -0
- icdev/tools/builder/goal_adapter.py +592 -0
- icdev/tools/builder/gotcha_validator.py +812 -0
- icdev/tools/builder/language_support.py +441 -0
- icdev/tools/builder/linter.py +976 -0
- icdev/tools/builder/profile_detector.py +657 -0
- icdev/tools/builder/profile_md_generator.py +723 -0
- icdev/tools/builder/scaffolder.py +1590 -0
- icdev/tools/builder/scaffolder_extended.py +1771 -0
- icdev/tools/builder/test_writer.py +950 -0
- icdev/tools/ci/__init__.py +2 -0
- icdev/tools/ci/connectors/__init__.py +2 -0
- icdev/tools/ci/connectors/base_connector.py +80 -0
- icdev/tools/ci/connectors/connector_registry.py +188 -0
- icdev/tools/ci/connectors/mattermost_connector.py +159 -0
- icdev/tools/ci/connectors/slack_connector.py +197 -0
- icdev/tools/ci/core/__init__.py +2 -0
- icdev/tools/ci/core/air_gap_detector.py +115 -0
- icdev/tools/ci/core/comment_handler.py +192 -0
- icdev/tools/ci/core/conversation_manager.py +479 -0
- icdev/tools/ci/core/event_envelope.py +500 -0
- icdev/tools/ci/core/event_router.py +443 -0
- icdev/tools/ci/core/failure_parser.py +397 -0
- icdev/tools/ci/core/recovery_engine.py +527 -0
- icdev/tools/ci/modules/__init__.py +2 -0
- icdev/tools/ci/modules/agent.py +271 -0
- icdev/tools/ci/modules/git_ops.py +175 -0
- icdev/tools/ci/modules/state.py +117 -0
- icdev/tools/ci/modules/vcs.py +303 -0
- icdev/tools/ci/modules/workflow_ops.py +295 -0
- icdev/tools/ci/modules/worktree.py +340 -0
- icdev/tools/ci/pipeline_config_generator.py +558 -0
- icdev/tools/ci/triggers/__init__.py +2 -0
- icdev/tools/ci/triggers/gitlab_task_monitor.py +330 -0
- icdev/tools/ci/triggers/poll_trigger.py +237 -0
- icdev/tools/ci/triggers/webhook_server.py +356 -0
- icdev/tools/ci/workflows/__init__.py +2 -0
- icdev/tools/ci/workflows/icdev_build.py +140 -0
- icdev/tools/ci/workflows/icdev_comply.py +284 -0
- icdev/tools/ci/workflows/icdev_document.py +152 -0
- icdev/tools/ci/workflows/icdev_e2e.py +188 -0
- icdev/tools/ci/workflows/icdev_patch.py +186 -0
- icdev/tools/ci/workflows/icdev_plan.py +202 -0
- icdev/tools/ci/workflows/icdev_plan_build.py +41 -0
- icdev/tools/ci/workflows/icdev_plan_build_test.py +46 -0
- icdev/tools/ci/workflows/icdev_plan_build_test_review.py +47 -0
- icdev/tools/ci/workflows/icdev_review.py +126 -0
- icdev/tools/ci/workflows/icdev_sdlc.py +261 -0
- icdev/tools/ci/workflows/icdev_test.py +240 -0
- icdev/tools/cli/__init__.py +1 -0
- icdev/tools/cli/output_formatter.py +756 -0
- icdev/tools/cli_formatter.py +42 -0
- icdev/tools/cloud/__init__.py +11 -0
- icdev/tools/cloud/cloud_mode_manager.py +364 -0
- icdev/tools/cloud/csp_changelog.py +383 -0
- icdev/tools/cloud/csp_health_checker.py +268 -0
- icdev/tools/cloud/csp_monitor.py +951 -0
- icdev/tools/cloud/iam_provider.py +593 -0
- icdev/tools/cloud/kms_provider.py +346 -0
- icdev/tools/cloud/monitoring_provider.py +628 -0
- icdev/tools/cloud/provider_factory.py +376 -0
- icdev/tools/cloud/region_validator.py +345 -0
- icdev/tools/cloud/registry_provider.py +563 -0
- icdev/tools/cloud/secrets_provider.py +486 -0
- icdev/tools/cloud/storage_provider.py +446 -0
- icdev/tools/compat/__init__.py +21 -0
- icdev/tools/compat/cli_harmonizer.py +251 -0
- icdev/tools/compat/datetime_utils.py +18 -0
- icdev/tools/compat/db_utils.py +160 -0
- icdev/tools/compat/platform_utils.py +123 -0
- icdev/tools/compliance/__init__.py +1 -0
- icdev/tools/compliance/accountability_manager.py +397 -0
- icdev/tools/compliance/ai_accountability_audit.py +294 -0
- icdev/tools/compliance/ai_impact_assessor.py +273 -0
- icdev/tools/compliance/ai_incident_response.py +301 -0
- icdev/tools/compliance/ai_inventory_manager.py +239 -0
- icdev/tools/compliance/ai_reassessment_scheduler.py +256 -0
- icdev/tools/compliance/ai_transparency_audit.py +248 -0
- icdev/tools/compliance/atlas_assessor.py +278 -0
- icdev/tools/compliance/atlas_report_generator.py +1211 -0
- icdev/tools/compliance/base_assessor.py +597 -0
- icdev/tools/compliance/cato_monitor.py +1385 -0
- icdev/tools/compliance/cato_scheduler.py +699 -0
- icdev/tools/compliance/cjis_assessor.py +76 -0
- icdev/tools/compliance/classification_manager.py +1353 -0
- icdev/tools/compliance/cmmc_assessor.py +1491 -0
- icdev/tools/compliance/cmmc_report_generator.py +1100 -0
- icdev/tools/compliance/compliance_detector.py +463 -0
- icdev/tools/compliance/compliance_exporter.py +427 -0
- icdev/tools/compliance/compliance_status.py +825 -0
- icdev/tools/compliance/control_mapper.py +505 -0
- icdev/tools/compliance/crosswalk_engine.py +1203 -0
- icdev/tools/compliance/cssp_assessor.py +1045 -0
- icdev/tools/compliance/cssp_evidence_collector.py +729 -0
- icdev/tools/compliance/cssp_report_generator.py +1116 -0
- icdev/tools/compliance/cui_marker.py +388 -0
- icdev/tools/compliance/diagram_validator.py +600 -0
- icdev/tools/compliance/emass/__init__.py +2 -0
- icdev/tools/compliance/emass/emass_client.py +840 -0
- icdev/tools/compliance/emass/emass_export.py +777 -0
- icdev/tools/compliance/emass/emass_sync.py +826 -0
- icdev/tools/compliance/eu_ai_act_classifier.py +194 -0
- icdev/tools/compliance/evidence_collector.py +468 -0
- icdev/tools/compliance/fairness_assessor.py +316 -0
- icdev/tools/compliance/fedramp_assessor.py +1808 -0
- icdev/tools/compliance/fedramp_authorization_packager.py +137 -0
- icdev/tools/compliance/fedramp_ksi_generator.py +355 -0
- icdev/tools/compliance/fedramp_report_generator.py +1128 -0
- icdev/tools/compliance/fips199_categorizer.py +881 -0
- icdev/tools/compliance/fips200_validator.py +315 -0
- icdev/tools/compliance/gao_ai_assessor.py +231 -0
- icdev/tools/compliance/gao_evidence_builder.py +308 -0
- icdev/tools/compliance/hipaa_assessor.py +78 -0
- icdev/tools/compliance/hitrust_assessor.py +49 -0
- icdev/tools/compliance/incident_response_plan.py +718 -0
- icdev/tools/compliance/iso27001_assessor.py +92 -0
- icdev/tools/compliance/iso42001_assessor.py +114 -0
- icdev/tools/compliance/ivv_assessor.py +2327 -0
- icdev/tools/compliance/ivv_report_generator.py +1662 -0
- icdev/tools/compliance/model_card_generator.py +297 -0
- icdev/tools/compliance/mosa_assessor.py +117 -0
- icdev/tools/compliance/multi_regime_assessor.py +451 -0
- icdev/tools/compliance/narrative_generator.py +1013 -0
- icdev/tools/compliance/nist_800_207_assessor.py +191 -0
- icdev/tools/compliance/nist_ai_600_1_assessor.py +188 -0
- icdev/tools/compliance/nist_ai_rmf_assessor.py +110 -0
- icdev/tools/compliance/nist_lookup.py +245 -0
- icdev/tools/compliance/omb_m25_21_assessor.py +228 -0
- icdev/tools/compliance/omb_m26_04_assessor.py +188 -0
- icdev/tools/compliance/oscal_catalog_adapter.py +395 -0
- icdev/tools/compliance/oscal_generator.py +2170 -0
- icdev/tools/compliance/oscal_tools.py +1182 -0
- icdev/tools/compliance/owasp_agentic_assessor.py +226 -0
- icdev/tools/compliance/owasp_asi_assessor.py +200 -0
- icdev/tools/compliance/owasp_llm_assessor.py +244 -0
- icdev/tools/compliance/pci_dss_assessor.py +80 -0
- icdev/tools/compliance/pi_compliance_tracker.py +1461 -0
- icdev/tools/compliance/poam_generator.py +405 -0
- icdev/tools/compliance/resolve_marking.py +283 -0
- icdev/tools/compliance/sbd_assessor.py +2068 -0
- icdev/tools/compliance/sbd_report_generator.py +1236 -0
- icdev/tools/compliance/sbom_generator.py +1008 -0
- icdev/tools/compliance/siem_config_generator.py +674 -0
- icdev/tools/compliance/slsa_attestation_generator.py +490 -0
- icdev/tools/compliance/soc2_assessor.py +77 -0
- icdev/tools/compliance/ssp_generator.py +573 -0
- icdev/tools/compliance/stig_checker.py +727 -0
- icdev/tools/compliance/swft_evidence_bundler.py +337 -0
- icdev/tools/compliance/system_card_generator.py +309 -0
- icdev/tools/compliance/traceability_matrix.py +1281 -0
- icdev/tools/compliance/universal_classification_manager.py +1172 -0
- icdev/tools/compliance/xacta/__init__.py +2 -0
- icdev/tools/compliance/xacta/xacta_client.py +449 -0
- icdev/tools/compliance/xacta/xacta_export.py +557 -0
- icdev/tools/compliance/xacta/xacta_sync.py +333 -0
- icdev/tools/compliance/xai_assessor.py +231 -0
- icdev/tools/dashboard/__init__.py +1 -0
- icdev/tools/dashboard/api/__init__.py +1 -0
- icdev/tools/dashboard/api/_pipeline_state.py +17 -0
- icdev/tools/dashboard/api/activity.py +206 -0
- icdev/tools/dashboard/api/admin.py +176 -0
- icdev/tools/dashboard/api/agents.py +53 -0
- icdev/tools/dashboard/api/ai_accountability.py +163 -0
- icdev/tools/dashboard/api/ai_transparency.py +198 -0
- icdev/tools/dashboard/api/audit.py +58 -0
- icdev/tools/dashboard/api/batch.py +666 -0
- icdev/tools/dashboard/api/chat.py +241 -0
- icdev/tools/dashboard/api/cicd.py +219 -0
- icdev/tools/dashboard/api/code_quality.py +223 -0
- icdev/tools/dashboard/api/compliance.py +171 -0
- icdev/tools/dashboard/api/cpmp.py +915 -0
- icdev/tools/dashboard/api/diagrams.py +65 -0
- icdev/tools/dashboard/api/events.py +250 -0
- icdev/tools/dashboard/api/evidence.py +99 -0
- icdev/tools/dashboard/api/fedramp_20x.py +77 -0
- icdev/tools/dashboard/api/govcon.py +1095 -0
- icdev/tools/dashboard/api/intake.py +1171 -0
- icdev/tools/dashboard/api/lineage.py +163 -0
- icdev/tools/dashboard/api/metrics.py +155 -0
- icdev/tools/dashboard/api/nlq.py +72 -0
- icdev/tools/dashboard/api/orchestration.py +472 -0
- icdev/tools/dashboard/api/oscal.py +183 -0
- icdev/tools/dashboard/api/prod_audit.py +183 -0
- icdev/tools/dashboard/api/projects.py +191 -0
- icdev/tools/dashboard/api/proposals.py +1084 -0
- icdev/tools/dashboard/api/traces.py +363 -0
- icdev/tools/dashboard/api/usage.py +234 -0
- icdev/tools/dashboard/app.py +1986 -0
- icdev/tools/dashboard/auth.py +500 -0
- icdev/tools/dashboard/byok.py +245 -0
- icdev/tools/dashboard/chat_manager.py +675 -0
- icdev/tools/dashboard/config.py +116 -0
- icdev/tools/dashboard/diagram_definitions.py +642 -0
- icdev/tools/dashboard/nlq_processor.py +323 -0
- icdev/tools/dashboard/phase_loader.py +136 -0
- icdev/tools/dashboard/sse_manager.py +89 -0
- icdev/tools/dashboard/state_tracker.py +267 -0
- icdev/tools/dashboard/static/css/style.css +706 -0
- icdev/tools/dashboard/static/css/ux.css +2047 -0
- icdev/tools/dashboard/static/js/activity.js +322 -0
- icdev/tools/dashboard/static/js/api.js +161 -0
- icdev/tools/dashboard/static/js/batch.js +814 -0
- icdev/tools/dashboard/static/js/charts.js +618 -0
- icdev/tools/dashboard/static/js/chat.js +1514 -0
- icdev/tools/dashboard/static/js/kanban.js +113 -0
- icdev/tools/dashboard/static/js/live.js +569 -0
- icdev/tools/dashboard/static/js/mermaid-icdev.js +332 -0
- icdev/tools/dashboard/static/js/proposals.js +588 -0
- icdev/tools/dashboard/static/js/shortcuts.js +544 -0
- icdev/tools/dashboard/static/js/tables.js +652 -0
- icdev/tools/dashboard/static/js/tour.js +524 -0
- icdev/tools/dashboard/static/js/ux.js +942 -0
- icdev/tools/dashboard/templates/404.html +10 -0
- icdev/tools/dashboard/templates/activity.html +80 -0
- icdev/tools/dashboard/templates/admin/users.html +144 -0
- icdev/tools/dashboard/templates/ai_accountability.html +235 -0
- icdev/tools/dashboard/templates/ai_transparency.html +263 -0
- icdev/tools/dashboard/templates/base.html +104 -0
- icdev/tools/dashboard/templates/batch.html +23 -0
- icdev/tools/dashboard/templates/chat.html +332 -0
- icdev/tools/dashboard/templates/children.html +149 -0
- icdev/tools/dashboard/templates/cicd.html +253 -0
- icdev/tools/dashboard/templates/code_quality.html +214 -0
- icdev/tools/dashboard/templates/cpmp/cor_detail.html +220 -0
- icdev/tools/dashboard/templates/cpmp/cor_portal.html +91 -0
- icdev/tools/dashboard/templates/cpmp/deliverable_detail.html +197 -0
- icdev/tools/dashboard/templates/cpmp/detail.html +578 -0
- icdev/tools/dashboard/templates/cpmp/portfolio.html +202 -0
- icdev/tools/dashboard/templates/dev_profiles.html +304 -0
- icdev/tools/dashboard/templates/diagrams.html +224 -0
- icdev/tools/dashboard/templates/events/timeline.html +232 -0
- icdev/tools/dashboard/templates/evidence.html +134 -0
- icdev/tools/dashboard/templates/fedramp_20x.html +207 -0
- icdev/tools/dashboard/templates/gateway.html +244 -0
- icdev/tools/dashboard/templates/govcon/capabilities.html +135 -0
- icdev/tools/dashboard/templates/govcon/pipeline.html +214 -0
- icdev/tools/dashboard/templates/govcon/requirements.html +120 -0
- icdev/tools/dashboard/templates/index.html +254 -0
- icdev/tools/dashboard/templates/lineage.html +141 -0
- icdev/tools/dashboard/templates/login.html +51 -0
- icdev/tools/dashboard/templates/monitoring/overview.html +193 -0
- icdev/tools/dashboard/templates/orchestration/dashboard.html +545 -0
- icdev/tools/dashboard/templates/oscal.html +263 -0
- icdev/tools/dashboard/templates/phases.html +150 -0
- icdev/tools/dashboard/templates/prod_audit.html +280 -0
- icdev/tools/dashboard/templates/profile.html +183 -0
- icdev/tools/dashboard/templates/projects/detail.html +583 -0
- icdev/tools/dashboard/templates/projects/list.html +47 -0
- icdev/tools/dashboard/templates/proposals/detail.html +1253 -0
- icdev/tools/dashboard/templates/proposals/list.html +179 -0
- icdev/tools/dashboard/templates/proposals/section_detail.html +193 -0
- icdev/tools/dashboard/templates/provenance.html +181 -0
- icdev/tools/dashboard/templates/query/nlq.html +234 -0
- icdev/tools/dashboard/templates/quick_paths.html +69 -0
- icdev/tools/dashboard/templates/traces.html +155 -0
- icdev/tools/dashboard/templates/translation_detail.html +199 -0
- icdev/tools/dashboard/templates/translations.html +162 -0
- icdev/tools/dashboard/templates/usage.html +225 -0
- icdev/tools/dashboard/templates/wizard.html +539 -0
- icdev/tools/dashboard/templates/xai.html +208 -0
- icdev/tools/dashboard/ux_helpers.py +962 -0
- icdev/tools/dashboard/websocket.py +81 -0
- icdev/tools/db/__init__.py +1 -0
- icdev/tools/db/backup.py +312 -0
- icdev/tools/db/backup_manager.py +832 -0
- icdev/tools/db/init_icdev_db.py +5900 -0
- icdev/tools/db/migrate.py +178 -0
- icdev/tools/db/migration_runner.py +549 -0
- icdev/tools/db/migrations/001_baseline/meta.json +9 -0
- icdev/tools/db/migrations/001_baseline/up.py +68 -0
- icdev/tools/db/migrations/002_memory_enhancements/down.sql +8 -0
- icdev/tools/db/migrations/002_memory_enhancements/meta.json +9 -0
- icdev/tools/db/migrations/002_memory_enhancements/up.py +118 -0
- icdev/tools/db/migrations/003_dev_profiles/meta.json +8 -0
- icdev/tools/db/migrations/003_dev_profiles/up.py +93 -0
- icdev/tools/db/migrations/004_innovation_engine/down.py +19 -0
- icdev/tools/db/migrations/004_innovation_engine/up.py +227 -0
- icdev/tools/db/migrations/005_phase_37_ai_security/down.py +19 -0
- icdev/tools/db/migrations/005_phase_37_ai_security/up.py +258 -0
- icdev/tools/db/migrations/006_phase_36_evolution/down.py +21 -0
- icdev/tools/db/migrations/006_phase_36_evolution/up.py +323 -0
- icdev/tools/db/migrations/007_phase_38_cloud/down.py +14 -0
- icdev/tools/db/migrations/007_phase_38_cloud/up.py +110 -0
- icdev/tools/db/migrations/008_phase36_37_integration/up.py +55 -0
- icdev/tools/db/migrations/__init__.py +2 -0
- icdev/tools/devsecops/__init__.py +2 -0
- icdev/tools/devsecops/attestation_manager.py +458 -0
- icdev/tools/devsecops/network_segmentation_generator.py +614 -0
- icdev/tools/devsecops/pdp_config_generator.py +1256 -0
- icdev/tools/devsecops/pipeline_security_generator.py +484 -0
- icdev/tools/devsecops/policy_generator.py +653 -0
- icdev/tools/devsecops/profile_manager.py +388 -0
- icdev/tools/devsecops/service_mesh_generator.py +1073 -0
- icdev/tools/devsecops/zta_maturity_scorer.py +368 -0
- icdev/tools/devsecops/zta_terraform_generator.py +1303 -0
- icdev/tools/dx/__init__.py +3 -0
- icdev/tools/dx/companion.py +266 -0
- icdev/tools/dx/instruction_generator.py +753 -0
- icdev/tools/dx/mcp_config_generator.py +282 -0
- icdev/tools/dx/skill_translator.py +425 -0
- icdev/tools/dx/tool_detector.py +144 -0
- icdev/tools/extensions/__init__.py +21 -0
- icdev/tools/extensions/builtins/010_ai_governance_chat.py +277 -0
- icdev/tools/extensions/builtins/__init__.py +2 -0
- icdev/tools/extensions/extension_manager.py +455 -0
- icdev/tools/infra/__init__.py +1 -0
- icdev/tools/infra/ansible_generator.py +869 -0
- icdev/tools/infra/dockerfile_generator.py +361 -0
- icdev/tools/infra/infra_status.py +393 -0
- icdev/tools/infra/ironbank_metadata_generator.py +411 -0
- icdev/tools/infra/k8s_generator.py +1002 -0
- icdev/tools/infra/pipeline_generator.py +832 -0
- icdev/tools/infra/rollback.py +400 -0
- icdev/tools/infra/terraform_generator.py +1142 -0
- icdev/tools/infra/terraform_generator_azure.py +1254 -0
- icdev/tools/infra/terraform_generator_gcp.py +953 -0
- icdev/tools/infra/terraform_generator_ibm.py +360 -0
- icdev/tools/infra/terraform_generator_oci.py +919 -0
- icdev/tools/infra/terraform_generator_onprem.py +319 -0
- icdev/tools/innovation/__init__.py +8 -0
- icdev/tools/innovation/competitive_intel.py +492 -0
- icdev/tools/innovation/innovation_manager.py +681 -0
- icdev/tools/innovation/introspective_analyzer.py +774 -0
- icdev/tools/innovation/register_external_patterns.py +440 -0
- icdev/tools/innovation/signal_ranker.py +1038 -0
- icdev/tools/innovation/solution_generator.py +697 -0
- icdev/tools/innovation/standards_monitor.py +466 -0
- icdev/tools/innovation/trend_detector.py +1046 -0
- icdev/tools/innovation/triage_engine.py +1149 -0
- icdev/tools/innovation/web_scanner.py +894 -0
- icdev/tools/installer/__init__.py +1 -0
- icdev/tools/installer/compliance_configurator.py +637 -0
- icdev/tools/installer/installer.py +1711 -0
- icdev/tools/installer/module_registry.py +805 -0
- icdev/tools/installer/platform_setup.py +961 -0
- icdev/tools/integration/__init__.py +2 -0
- icdev/tools/integration/approval_manager.py +561 -0
- icdev/tools/integration/doors_exporter.py +627 -0
- icdev/tools/integration/gitlab_connector.py +784 -0
- icdev/tools/integration/jira_connector.py +774 -0
- icdev/tools/integration/servicenow_connector.py +693 -0
- icdev/tools/knowledge/__init__.py +1 -0
- icdev/tools/knowledge/knowledge_ingest.py +293 -0
- icdev/tools/knowledge/pattern_detector.py +693 -0
- icdev/tools/knowledge/recommendation_engine.py +461 -0
- icdev/tools/knowledge/self_heal_analyzer.py +504 -0
- icdev/tools/llm/__init__.py +72 -0
- icdev/tools/llm/anthropic_provider.py +170 -0
- icdev/tools/llm/azure_openai_provider.py +338 -0
- icdev/tools/llm/bedrock_provider.py +315 -0
- icdev/tools/llm/embedding_provider.py +438 -0
- icdev/tools/llm/gemini_provider.py +381 -0
- icdev/tools/llm/ibm_watsonx_provider.py +232 -0
- icdev/tools/llm/oci_genai_provider.py +462 -0
- icdev/tools/llm/ollama_provider.py +340 -0
- icdev/tools/llm/openai_provider.py +225 -0
- icdev/tools/llm/provider.py +355 -0
- icdev/tools/llm/provider_sdk.py +175 -0
- icdev/tools/llm/router.py +780 -0
- icdev/tools/llm/vertex_ai_provider.py +374 -0
- icdev/tools/maintenance/__init__.py +2 -0
- icdev/tools/maintenance/dependency_scanner.py +1030 -0
- icdev/tools/maintenance/maintenance_auditor.py +815 -0
- icdev/tools/maintenance/remediation_engine.py +966 -0
- icdev/tools/maintenance/vulnerability_checker.py +987 -0
- icdev/tools/mbse/__init__.py +3 -0
- icdev/tools/mbse/des_assessor.py +1186 -0
- icdev/tools/mbse/des_report_generator.py +800 -0
- icdev/tools/mbse/diagram_extractor.py +811 -0
- icdev/tools/mbse/digital_thread.py +1665 -0
- icdev/tools/mbse/model_code_generator.py +1122 -0
- icdev/tools/mbse/model_control_mapper.py +420 -0
- icdev/tools/mbse/pi_model_tracker.py +1093 -0
- icdev/tools/mbse/reqif_parser.py +1483 -0
- icdev/tools/mbse/sync_engine.py +1805 -0
- icdev/tools/mbse/xmi_parser.py +1573 -0
- icdev/tools/mcp/__init__.py +1 -0
- icdev/tools/mcp/base_server.py +535 -0
- icdev/tools/mcp/builder_server.py +725 -0
- icdev/tools/mcp/compliance_server.py +1407 -0
- icdev/tools/mcp/context_indexer.py +199 -0
- icdev/tools/mcp/context_server.py +305 -0
- icdev/tools/mcp/core_server.py +679 -0
- icdev/tools/mcp/devsecops_server.py +432 -0
- icdev/tools/mcp/gap_handlers.py +1079 -0
- icdev/tools/mcp/gateway_server.py +339 -0
- icdev/tools/mcp/generate_registry.py +623 -0
- icdev/tools/mcp/infra_server.py +264 -0
- icdev/tools/mcp/innovation_server.py +316 -0
- icdev/tools/mcp/integration_server.py +527 -0
- icdev/tools/mcp/knowledge_server.py +429 -0
- icdev/tools/mcp/maintenance_server.py +248 -0
- icdev/tools/mcp/marketplace_server.py +499 -0
- icdev/tools/mcp/mbse_server.py +398 -0
- icdev/tools/mcp/modernization_server.py +496 -0
- icdev/tools/mcp/observability_server.py +354 -0
- icdev/tools/mcp/requirements_server.py +415 -0
- icdev/tools/mcp/simulation_server.py +468 -0
- icdev/tools/mcp/standalone/__init__.py +2 -0
- icdev/tools/mcp/standalone/builder.py +59 -0
- icdev/tools/mcp/standalone/compliance.py +59 -0
- icdev/tools/mcp/standalone/core.py +59 -0
- icdev/tools/mcp/standalone/knowledge.py +59 -0
- icdev/tools/mcp/standalone/maintenance.py +59 -0
- icdev/tools/mcp/supply_chain_server.py +476 -0
- icdev/tools/mcp/tool_registry.py +2008 -0
- icdev/tools/mcp/unified_server.py +158 -0
- icdev/tools/memory/__init__.py +2 -0
- icdev/tools/memory/auto_capture.py +347 -0
- icdev/tools/memory/embed_memory.py +158 -0
- icdev/tools/memory/history_compressor.py +334 -0
- icdev/tools/memory/hybrid_search.py +236 -0
- icdev/tools/memory/maintenance_cron.py +289 -0
- icdev/tools/memory/memory_consolidation.py +444 -0
- icdev/tools/memory/memory_db.py +133 -0
- icdev/tools/memory/memory_read.py +102 -0
- icdev/tools/memory/memory_write.py +222 -0
- icdev/tools/memory/semantic_search.py +139 -0
- icdev/tools/memory/time_decay.py +435 -0
- icdev/tools/modernization/__init__.py +3 -0
- icdev/tools/modernization/architecture_extractor.py +734 -0
- icdev/tools/modernization/compliance_bridge.py +1499 -0
- icdev/tools/modernization/db_migration_planner.py +1385 -0
- icdev/tools/modernization/doc_generator.py +1428 -0
- icdev/tools/modernization/framework_migrator.py +1525 -0
- icdev/tools/modernization/legacy_analyzer.py +1948 -0
- icdev/tools/modernization/migration_code_generator.py +1639 -0
- icdev/tools/modernization/migration_report_generator.py +1653 -0
- icdev/tools/modernization/migration_tracker.py +1726 -0
- icdev/tools/modernization/monolith_decomposer.py +1508 -0
- icdev/tools/modernization/seven_r_assessor.py +1658 -0
- icdev/tools/modernization/strangler_fig_manager.py +1705 -0
- icdev/tools/modernization/ui_analyzer.py +771 -0
- icdev/tools/modernization/version_migrator.py +1392 -0
- icdev/tools/monitor/__init__.py +1 -0
- icdev/tools/monitor/alert_correlator.py +495 -0
- icdev/tools/monitor/auto_resolver.py +612 -0
- icdev/tools/monitor/health_checker.py +509 -0
- icdev/tools/monitor/heartbeat_daemon.py +792 -0
- icdev/tools/monitor/log_analyzer.py +516 -0
- icdev/tools/monitor/metric_collector.py +496 -0
- icdev/tools/mosa/__init__.py +10 -0
- icdev/tools/mosa/icd_generator.py +370 -0
- icdev/tools/mosa/modular_design_analyzer.py +683 -0
- icdev/tools/mosa/mosa_code_enforcer.py +349 -0
- icdev/tools/mosa/tsp_generator.py +265 -0
- icdev/tools/observability/__init__.py +100 -0
- icdev/tools/observability/genai_attributes.py +88 -0
- icdev/tools/observability/instrumentation.py +140 -0
- icdev/tools/observability/mlflow_exporter.py +194 -0
- icdev/tools/observability/otel_tracer.py +168 -0
- icdev/tools/observability/provenance/__init__.py +3 -0
- icdev/tools/observability/provenance/prov_recorder.py +324 -0
- icdev/tools/observability/shap/__init__.py +3 -0
- icdev/tools/observability/shap/agent_shap.py +275 -0
- icdev/tools/observability/sqlite_tracer.py +361 -0
- icdev/tools/observability/trace_context.py +205 -0
- icdev/tools/observability/tracer.py +230 -0
- icdev/tools/orchestration/__init__.py +2 -0
- icdev/tools/orchestration/workflow_composer.py +361 -0
- icdev/tools/project/__init__.py +1 -0
- icdev/tools/project/manifest_loader.py +418 -0
- icdev/tools/project/project_create.py +350 -0
- icdev/tools/project/project_list.py +174 -0
- icdev/tools/project/project_scaffold.py +1715 -0
- icdev/tools/project/project_status.py +479 -0
- icdev/tools/project/session_context_builder.py +757 -0
- icdev/tools/project/validate_manifest.py +55 -0
- icdev/tools/registry/__init__.py +10 -0
- icdev/tools/registry/absorption_engine.py +832 -0
- icdev/tools/registry/capability_evaluator.py +668 -0
- icdev/tools/registry/child_registry.py +617 -0
- icdev/tools/registry/cross_pollinator.py +1065 -0
- icdev/tools/registry/genome_manager.py +671 -0
- icdev/tools/registry/learning_collector.py +912 -0
- icdev/tools/registry/propagation_manager.py +942 -0
- icdev/tools/registry/staging_manager.py +742 -0
- icdev/tools/registry/telemetry_collector.py +423 -0
- icdev/tools/requirements/__init__.py +1 -0
- icdev/tools/requirements/ai_governance_scorer.py +208 -0
- icdev/tools/requirements/boundary_analyzer.py +1293 -0
- icdev/tools/requirements/clarification_engine.py +618 -0
- icdev/tools/requirements/complexity_scorer.py +387 -0
- icdev/tools/requirements/consistency_analyzer.py +803 -0
- icdev/tools/requirements/constitution_manager.py +605 -0
- icdev/tools/requirements/decomposition_engine.py +778 -0
- icdev/tools/requirements/document_extractor.py +1016 -0
- icdev/tools/requirements/elicitation_techniques.py +519 -0
- icdev/tools/requirements/gap_detector.py +271 -0
- icdev/tools/requirements/intake_engine.py +2188 -0
- icdev/tools/requirements/prd_generator.py +847 -0
- icdev/tools/requirements/prd_validator.py +595 -0
- icdev/tools/requirements/readiness_scorer.py +313 -0
- icdev/tools/requirements/spec_organizer.py +1029 -0
- icdev/tools/requirements/spec_quality_checker.py +1097 -0
- icdev/tools/requirements/traceability_builder.py +579 -0
- icdev/tools/resilience/__init__.py +34 -0
- icdev/tools/resilience/circuit_breaker.py +340 -0
- icdev/tools/resilience/correlation.py +150 -0
- icdev/tools/resilience/errors.py +81 -0
- icdev/tools/resilience/retry.py +95 -0
- icdev/tools/schemas/__init__.py +27 -0
- icdev/tools/schemas/chat.py +61 -0
- icdev/tools/schemas/compliance.py +56 -0
- icdev/tools/schemas/core.py +85 -0
- icdev/tools/schemas/innovation.py +37 -0
- icdev/tools/schemas/validation.py +109 -0
- icdev/tools/sdk/__init__.py +3 -0
- icdev/tools/sdk/icdev_client.py +218 -0
- icdev/tools/security/__init__.py +1 -0
- icdev/tools/security/agent_output_validator.py +330 -0
- icdev/tools/security/agent_trust_scorer.py +466 -0
- icdev/tools/security/ai_bom_generator.py +725 -0
- icdev/tools/security/ai_telemetry_logger.py +469 -0
- icdev/tools/security/atlas_red_team.py +543 -0
- icdev/tools/security/code_pattern_scanner.py +378 -0
- icdev/tools/security/confabulation_detector.py +271 -0
- icdev/tools/security/container_scanner.py +491 -0
- icdev/tools/security/dependency_auditor.py +944 -0
- icdev/tools/security/endpoint_security_scanner.py +579 -0
- icdev/tools/security/mcp_tool_authorizer.py +243 -0
- icdev/tools/security/prompt_injection_detector.py +737 -0
- icdev/tools/security/sast_runner.py +948 -0
- icdev/tools/security/secret_detector.py +378 -0
- icdev/tools/security/tool_chain_validator.py +357 -0
- icdev/tools/security/vuln_scanner.py +539 -0
- icdev/tools/simulation/__init__.py +2 -0
- icdev/tools/simulation/coa_generator.py +1552 -0
- icdev/tools/simulation/monte_carlo.py +758 -0
- icdev/tools/simulation/scenario_manager.py +1073 -0
- icdev/tools/simulation/simulation_engine.py +1104 -0
- icdev/tools/supply_chain/__init__.py +2 -0
- icdev/tools/supply_chain/cve_triager.py +705 -0
- icdev/tools/supply_chain/dependency_graph.py +645 -0
- icdev/tools/supply_chain/isa_manager.py +540 -0
- icdev/tools/supply_chain/scrm_assessor.py +546 -0
- icdev/tools/testing/__init__.py +2 -0
- icdev/tools/testing/acceptance_validator.py +411 -0
- icdev/tools/testing/claude_dir_validator.py +831 -0
- icdev/tools/testing/data_types.py +199 -0
- icdev/tools/testing/e2e_runner.py +715 -0
- icdev/tools/testing/fuzz_cli.py +306 -0
- icdev/tools/testing/health_check.py +483 -0
- icdev/tools/testing/platform_check.py +143 -0
- icdev/tools/testing/production_audit.py +1862 -0
- icdev/tools/testing/production_remediate.py +804 -0
- icdev/tools/testing/screenshot_validator.py +539 -0
- icdev/tools/testing/smoke_test.py +283 -0
- icdev/tools/testing/test_agent_models.py +117 -0
- icdev/tools/testing/test_orchestrator.py +957 -0
- icdev/tools/testing/utils.py +229 -0
- icdev/tools/translation/__init__.py +17 -0
- icdev/tools/translation/code_translator.py +550 -0
- icdev/tools/translation/dependency_mapper.py +277 -0
- icdev/tools/translation/feature_map.py +395 -0
- icdev/tools/translation/project_assembler.py +439 -0
- icdev/tools/translation/source_extractor.py +609 -0
- icdev/tools/translation/test_translator.py +333 -0
- icdev/tools/translation/translation_manager.py +582 -0
- icdev/tools/translation/translation_validator.py +662 -0
- icdev/tools/translation/type_checker.py +371 -0
- icdev-1.0.0.dist-info/METADATA +868 -0
- icdev-1.0.0.dist-info/RECORD +1105 -0
- icdev-1.0.0.dist-info/WHEEL +5 -0
- icdev-1.0.0.dist-info/entry_points.txt +9 -0
- icdev-1.0.0.dist-info/licenses/LICENSE +254 -0
- icdev-1.0.0.dist-info/licenses/NOTICE +268 -0
- icdev-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1948 @@
|
|
|
1
|
+
# [TEMPLATE: CUI // SP-CTI]
|
|
2
|
+
#!/usr/bin/env python3
|
|
3
|
+
"""Legacy Code Static Analysis Engine for ICDEV DoD Modernization.
|
|
4
|
+
|
|
5
|
+
Performs comprehensive static analysis of legacy applications written in Python,
|
|
6
|
+
Java, and C#. Extracts components (classes, modules, functions), dependencies
|
|
7
|
+
(imports, inheritance, injection), API endpoints, and computes software quality
|
|
8
|
+
metrics (cyclomatic complexity, tech debt, maintainability index).
|
|
9
|
+
|
|
10
|
+
Results are stored in the ICDEV operational database for downstream migration
|
|
11
|
+
assessment by the 7Rs strategy scorer.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
# Register a legacy application
|
|
15
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
16
|
+
--register --project-id proj-123 --name "my-app" --source-path /path/to/src
|
|
17
|
+
|
|
18
|
+
# Run full analysis
|
|
19
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
20
|
+
--analyze --project-id proj-123 --app-id lapp-xxxx
|
|
21
|
+
|
|
22
|
+
# JSON output
|
|
23
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
24
|
+
--analyze --project-id proj-123 --app-id lapp-xxxx --json
|
|
25
|
+
|
|
26
|
+
Classification: CUI // SP-CTI
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
import argparse
|
|
30
|
+
import ast
|
|
31
|
+
import collections
|
|
32
|
+
import hashlib
|
|
33
|
+
import json
|
|
34
|
+
import math
|
|
35
|
+
import os
|
|
36
|
+
import re
|
|
37
|
+
import sqlite3
|
|
38
|
+
import uuid
|
|
39
|
+
from datetime import datetime, timezone
|
|
40
|
+
from pathlib import Path
|
|
41
|
+
from icdev._paths import get_project_root
|
|
42
|
+
|
|
43
|
+
# ---------------------------------------------------------------------------
|
|
44
|
+
# Configuration
|
|
45
|
+
# ---------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
BASE_DIR = get_project_root()
|
|
48
|
+
DB_PATH = BASE_DIR / "data" / "icdev.db"
|
|
49
|
+
|
|
50
|
+
# File extensions mapped to language identifiers
|
|
51
|
+
LANGUAGE_EXTENSIONS = {
|
|
52
|
+
".py": "python",
|
|
53
|
+
".java": "java",
|
|
54
|
+
".cs": "csharp",
|
|
55
|
+
".js": "javascript",
|
|
56
|
+
".ts": "typescript",
|
|
57
|
+
".rb": "ruby",
|
|
58
|
+
".go": "golang",
|
|
59
|
+
".cpp": "cpp",
|
|
60
|
+
".c": "c",
|
|
61
|
+
".h": "c",
|
|
62
|
+
".hpp": "cpp",
|
|
63
|
+
".vb": "vbnet",
|
|
64
|
+
".sql": "sql",
|
|
65
|
+
".xml": "xml",
|
|
66
|
+
".json": "json",
|
|
67
|
+
".yaml": "yaml",
|
|
68
|
+
".yml": "yaml",
|
|
69
|
+
".properties": "properties",
|
|
70
|
+
".jsp": "java",
|
|
71
|
+
".aspx": "csharp",
|
|
72
|
+
".cshtml": "csharp",
|
|
73
|
+
".xaml": "csharp",
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# Comment patterns per language family
|
|
77
|
+
COMMENT_PATTERNS = {
|
|
78
|
+
"hash": {"line": "#"}, # Python, Ruby, YAML
|
|
79
|
+
"slash": {"line": "//", "block_start": "/*", "block_end": "*/"}, # Java, C#, JS, TS, C/C++, Go
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
LANGUAGE_COMMENT_STYLE = {
|
|
83
|
+
"python": "hash",
|
|
84
|
+
"ruby": "hash",
|
|
85
|
+
"yaml": "hash",
|
|
86
|
+
"java": "slash",
|
|
87
|
+
"csharp": "slash",
|
|
88
|
+
"javascript": "slash",
|
|
89
|
+
"typescript": "slash",
|
|
90
|
+
"golang": "slash",
|
|
91
|
+
"cpp": "slash",
|
|
92
|
+
"c": "slash",
|
|
93
|
+
"vbnet": "hash", # simplified — VB uses ' but close enough
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
# Productivity rate for tech debt estimation (LOC per hour)
|
|
97
|
+
PRODUCTIVITY_RATE = 20.0
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# ---------------------------------------------------------------------------
|
|
101
|
+
# Database helper
|
|
102
|
+
# ---------------------------------------------------------------------------
|
|
103
|
+
|
|
104
|
+
def _get_db():
|
|
105
|
+
"""Return a sqlite3 connection to the ICDEV operational database.
|
|
106
|
+
|
|
107
|
+
The database file must already exist (created by tools/db/init_icdev_db.py).
|
|
108
|
+
Uses row_factory = sqlite3.Row for dict-like access.
|
|
109
|
+
"""
|
|
110
|
+
if not DB_PATH.exists():
|
|
111
|
+
raise FileNotFoundError(
|
|
112
|
+
f"ICDEV database not found at {DB_PATH}. "
|
|
113
|
+
"Run 'python tools/db/init_icdev_db.py' first."
|
|
114
|
+
)
|
|
115
|
+
conn = sqlite3.connect(str(DB_PATH))
|
|
116
|
+
conn.row_factory = sqlite3.Row
|
|
117
|
+
conn.execute("PRAGMA journal_mode=WAL")
|
|
118
|
+
conn.execute("PRAGMA foreign_keys=ON")
|
|
119
|
+
return conn
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# ---------------------------------------------------------------------------
|
|
123
|
+
# Line counting
|
|
124
|
+
# ---------------------------------------------------------------------------
|
|
125
|
+
|
|
126
|
+
def _count_lines(file_path):
|
|
127
|
+
"""Count total, code, comment, and blank lines in a source file.
|
|
128
|
+
|
|
129
|
+
Handles:
|
|
130
|
+
- '#' line comments for Python/Ruby/shell
|
|
131
|
+
- '//' line comments for Java/C#/JS/TS/Go/C++
|
|
132
|
+
- '/* ... */' block comments for Java/C#/JS/TS/Go/C++
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
file_path: Path object or string to the source file.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
dict with keys: total, code, comment, blank
|
|
139
|
+
"""
|
|
140
|
+
file_path = Path(file_path)
|
|
141
|
+
ext = file_path.suffix.lower()
|
|
142
|
+
lang = LANGUAGE_EXTENSIONS.get(ext)
|
|
143
|
+
style = LANGUAGE_COMMENT_STYLE.get(lang)
|
|
144
|
+
|
|
145
|
+
total = 0
|
|
146
|
+
code = 0
|
|
147
|
+
comment = 0
|
|
148
|
+
blank = 0
|
|
149
|
+
in_block_comment = False
|
|
150
|
+
|
|
151
|
+
try:
|
|
152
|
+
with open(str(file_path), "r", encoding="utf-8", errors="replace") as f:
|
|
153
|
+
for raw_line in f:
|
|
154
|
+
total += 1
|
|
155
|
+
stripped = raw_line.strip()
|
|
156
|
+
|
|
157
|
+
if not stripped:
|
|
158
|
+
blank += 1
|
|
159
|
+
continue
|
|
160
|
+
|
|
161
|
+
# Block comment handling (slash-style languages)
|
|
162
|
+
if style == "slash":
|
|
163
|
+
if in_block_comment:
|
|
164
|
+
comment += 1
|
|
165
|
+
if "*/" in stripped:
|
|
166
|
+
in_block_comment = False
|
|
167
|
+
continue
|
|
168
|
+
|
|
169
|
+
if stripped.startswith("/*"):
|
|
170
|
+
comment += 1
|
|
171
|
+
if "*/" not in stripped or stripped.endswith("/*"):
|
|
172
|
+
in_block_comment = True
|
|
173
|
+
continue
|
|
174
|
+
|
|
175
|
+
if stripped.startswith("//"):
|
|
176
|
+
comment += 1
|
|
177
|
+
continue
|
|
178
|
+
|
|
179
|
+
elif style == "hash":
|
|
180
|
+
if stripped.startswith("#"):
|
|
181
|
+
comment += 1
|
|
182
|
+
continue
|
|
183
|
+
|
|
184
|
+
# If we reach here it is a code line (may contain inline comment)
|
|
185
|
+
code += 1
|
|
186
|
+
|
|
187
|
+
except (OSError, IOError) as exc:
|
|
188
|
+
print(f"[WARN] Could not read {file_path}: {exc}")
|
|
189
|
+
return {"total": 0, "code": 0, "comment": 0, "blank": 0}
|
|
190
|
+
|
|
191
|
+
return {"total": total, "code": code, "comment": comment, "blank": blank}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
# ---------------------------------------------------------------------------
|
|
195
|
+
# Application registration
|
|
196
|
+
# ---------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
def register_application(project_id, name, source_path, description=None):
|
|
199
|
+
"""Register a legacy application in the ICDEV database.
|
|
200
|
+
|
|
201
|
+
Walks the source_path directory tree, counts files by extension, computes
|
|
202
|
+
aggregate LOC metrics, detects the primary language, and generates a
|
|
203
|
+
source hash (SHA-256 of all file paths + sizes for change detection).
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
project_id: Parent ICDEV project ID (must exist in projects table).
|
|
207
|
+
name: Human-readable name for the legacy application.
|
|
208
|
+
source_path: Absolute path to the application source root.
|
|
209
|
+
description: Optional description text.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
dict with the registered application record.
|
|
213
|
+
"""
|
|
214
|
+
source_path = Path(source_path).resolve()
|
|
215
|
+
if not source_path.is_dir():
|
|
216
|
+
raise FileNotFoundError(f"Source path does not exist or is not a directory: {source_path}")
|
|
217
|
+
|
|
218
|
+
app_id = f"lapp-{uuid.uuid4().hex[:12]}"
|
|
219
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
220
|
+
|
|
221
|
+
# Walk source tree and aggregate stats
|
|
222
|
+
ext_counts = collections.Counter()
|
|
223
|
+
loc_total = 0
|
|
224
|
+
loc_code = 0
|
|
225
|
+
loc_comment = 0
|
|
226
|
+
loc_blank = 0
|
|
227
|
+
file_count = 0
|
|
228
|
+
hash_material = hashlib.sha256()
|
|
229
|
+
|
|
230
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
231
|
+
for fname in files:
|
|
232
|
+
fpath = Path(root) / fname
|
|
233
|
+
ext = fpath.suffix.lower()
|
|
234
|
+
|
|
235
|
+
if ext not in LANGUAGE_EXTENSIONS:
|
|
236
|
+
continue
|
|
237
|
+
|
|
238
|
+
file_count += 1
|
|
239
|
+
ext_counts[ext] += 1
|
|
240
|
+
|
|
241
|
+
# Hash: path relative to source root + file size
|
|
242
|
+
try:
|
|
243
|
+
rel = str(fpath.relative_to(source_path))
|
|
244
|
+
fsize = fpath.stat().st_size
|
|
245
|
+
hash_material.update(f"{rel}:{fsize}\n".encode("utf-8"))
|
|
246
|
+
except (OSError, ValueError):
|
|
247
|
+
pass
|
|
248
|
+
|
|
249
|
+
counts = _count_lines(fpath)
|
|
250
|
+
loc_total += counts["total"]
|
|
251
|
+
loc_code += counts["code"]
|
|
252
|
+
loc_comment += counts["comment"]
|
|
253
|
+
loc_blank += counts["blank"]
|
|
254
|
+
|
|
255
|
+
# Determine primary language from extension counts
|
|
256
|
+
lang_counts = collections.Counter()
|
|
257
|
+
for ext, cnt in ext_counts.items():
|
|
258
|
+
lang = LANGUAGE_EXTENSIONS.get(ext, "unknown")
|
|
259
|
+
lang_counts[lang] += cnt
|
|
260
|
+
|
|
261
|
+
primary_language = "unknown"
|
|
262
|
+
if lang_counts:
|
|
263
|
+
primary_language = lang_counts.most_common(1)[0][0]
|
|
264
|
+
|
|
265
|
+
source_hash = hash_material.hexdigest()
|
|
266
|
+
|
|
267
|
+
# Insert into database
|
|
268
|
+
conn = _get_db()
|
|
269
|
+
try:
|
|
270
|
+
conn.execute(
|
|
271
|
+
"""INSERT INTO legacy_applications
|
|
272
|
+
(id, project_id, name, description, source_path, primary_language,
|
|
273
|
+
analysis_status, loc_total, loc_code, loc_comment, loc_blank,
|
|
274
|
+
file_count, source_hash, registered_at)
|
|
275
|
+
VALUES (?, ?, ?, ?, ?, ?, 'registered', ?, ?, ?, ?, ?, ?, ?)""",
|
|
276
|
+
(
|
|
277
|
+
app_id, project_id, name, description, str(source_path),
|
|
278
|
+
primary_language, loc_total, loc_code, loc_comment, loc_blank,
|
|
279
|
+
file_count, source_hash, now,
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
conn.commit()
|
|
283
|
+
finally:
|
|
284
|
+
conn.close()
|
|
285
|
+
|
|
286
|
+
result = {
|
|
287
|
+
"id": app_id,
|
|
288
|
+
"project_id": project_id,
|
|
289
|
+
"name": name,
|
|
290
|
+
"description": description,
|
|
291
|
+
"source_path": str(source_path),
|
|
292
|
+
"primary_language": primary_language,
|
|
293
|
+
"analysis_status": "registered",
|
|
294
|
+
"loc_total": loc_total,
|
|
295
|
+
"loc_code": loc_code,
|
|
296
|
+
"loc_comment": loc_comment,
|
|
297
|
+
"loc_blank": loc_blank,
|
|
298
|
+
"file_count": file_count,
|
|
299
|
+
"source_hash": source_hash,
|
|
300
|
+
"extension_breakdown": dict(ext_counts),
|
|
301
|
+
"language_breakdown": dict(lang_counts),
|
|
302
|
+
"registered_at": now,
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
print(f"[INFO] Registered legacy application '{name}' as {app_id}")
|
|
306
|
+
print(f" Language: {primary_language} | Files: {file_count} | LOC: {loc_total}")
|
|
307
|
+
return result
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
# ---------------------------------------------------------------------------
|
|
311
|
+
# Python analysis (AST-based)
|
|
312
|
+
# ---------------------------------------------------------------------------
|
|
313
|
+
|
|
314
|
+
class _PythonComplexityVisitor(ast.NodeVisitor):
|
|
315
|
+
"""Count branching nodes for cyclomatic complexity estimation."""
|
|
316
|
+
|
|
317
|
+
def __init__(self):
|
|
318
|
+
self.complexity = 1 # Base complexity
|
|
319
|
+
|
|
320
|
+
def visit_If(self, node):
|
|
321
|
+
self.complexity += 1
|
|
322
|
+
self.generic_visit(node)
|
|
323
|
+
|
|
324
|
+
def visit_For(self, node):
|
|
325
|
+
self.complexity += 1
|
|
326
|
+
self.generic_visit(node)
|
|
327
|
+
|
|
328
|
+
def visit_While(self, node):
|
|
329
|
+
self.complexity += 1
|
|
330
|
+
self.generic_visit(node)
|
|
331
|
+
|
|
332
|
+
def visit_ExceptHandler(self, node):
|
|
333
|
+
self.complexity += 1
|
|
334
|
+
self.generic_visit(node)
|
|
335
|
+
|
|
336
|
+
def visit_With(self, node):
|
|
337
|
+
self.complexity += 1
|
|
338
|
+
self.generic_visit(node)
|
|
339
|
+
|
|
340
|
+
def visit_Assert(self, node):
|
|
341
|
+
self.complexity += 1
|
|
342
|
+
self.generic_visit(node)
|
|
343
|
+
|
|
344
|
+
def visit_BoolOp(self, node):
|
|
345
|
+
# Each 'and'/'or' adds a branch
|
|
346
|
+
self.complexity += len(node.values) - 1
|
|
347
|
+
self.generic_visit(node)
|
|
348
|
+
|
|
349
|
+
def visit_comprehension(self, node):
|
|
350
|
+
self.complexity += 1
|
|
351
|
+
self.generic_visit(node)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _compute_python_complexity(node):
|
|
355
|
+
"""Compute cyclomatic complexity for an AST node (function or class body)."""
|
|
356
|
+
visitor = _PythonComplexityVisitor()
|
|
357
|
+
visitor.visit(node)
|
|
358
|
+
return visitor.complexity
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def analyze_python(app_id, source_path):
|
|
362
|
+
"""Analyze Python source files using the ast module.
|
|
363
|
+
|
|
364
|
+
Extracts:
|
|
365
|
+
- Classes and their methods, decorators, inheritance
|
|
366
|
+
- Top-level functions
|
|
367
|
+
- Import dependencies
|
|
368
|
+
- Flask/Django API endpoints
|
|
369
|
+
- Cyclomatic complexity per component
|
|
370
|
+
|
|
371
|
+
Args:
|
|
372
|
+
app_id: Legacy application ID (lapp-xxx).
|
|
373
|
+
source_path: Path to the source root.
|
|
374
|
+
|
|
375
|
+
Returns:
|
|
376
|
+
dict with counts of extracted components, dependencies, and APIs.
|
|
377
|
+
"""
|
|
378
|
+
source_path = Path(source_path)
|
|
379
|
+
conn = _get_db()
|
|
380
|
+
|
|
381
|
+
components_added = 0
|
|
382
|
+
dependencies_added = 0
|
|
383
|
+
apis_added = 0
|
|
384
|
+
|
|
385
|
+
try:
|
|
386
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
387
|
+
for fname in files:
|
|
388
|
+
if not fname.endswith(".py"):
|
|
389
|
+
continue
|
|
390
|
+
|
|
391
|
+
fpath = Path(root) / fname
|
|
392
|
+
rel_path = str(fpath.relative_to(source_path))
|
|
393
|
+
|
|
394
|
+
try:
|
|
395
|
+
source_code = fpath.read_text(encoding="utf-8", errors="replace")
|
|
396
|
+
tree = ast.parse(source_code, filename=str(fpath))
|
|
397
|
+
except SyntaxError as exc:
|
|
398
|
+
print(f"[WARN] Syntax error in {rel_path}: {exc}")
|
|
399
|
+
continue
|
|
400
|
+
except Exception as exc:
|
|
401
|
+
print(f"[WARN] Cannot parse {rel_path}: {exc}")
|
|
402
|
+
continue
|
|
403
|
+
|
|
404
|
+
module_name = rel_path.replace(os.sep, ".").replace("/", ".").rstrip(".py")
|
|
405
|
+
if module_name.endswith(".__init__"):
|
|
406
|
+
module_name = module_name[:-9]
|
|
407
|
+
|
|
408
|
+
line_counts = _count_lines(fpath)
|
|
409
|
+
|
|
410
|
+
# ----- Module-level component -----
|
|
411
|
+
module_comp_id = f"lcomp-{uuid.uuid4().hex[:12]}"
|
|
412
|
+
conn.execute(
|
|
413
|
+
"""INSERT OR IGNORE INTO legacy_components
|
|
414
|
+
(id, legacy_app_id, name, component_type, file_path,
|
|
415
|
+
qualified_name, loc, cyclomatic_complexity, properties)
|
|
416
|
+
VALUES (?, ?, ?, 'module', ?, ?, ?, ?, ?)""",
|
|
417
|
+
(
|
|
418
|
+
module_comp_id, app_id, fname, rel_path,
|
|
419
|
+
module_name, line_counts["code"],
|
|
420
|
+
_compute_python_complexity(tree),
|
|
421
|
+
json.dumps({"total_lines": line_counts["total"]}),
|
|
422
|
+
),
|
|
423
|
+
)
|
|
424
|
+
components_added += 1
|
|
425
|
+
|
|
426
|
+
# ----- Imports -----
|
|
427
|
+
for node in ast.walk(tree):
|
|
428
|
+
if isinstance(node, ast.Import):
|
|
429
|
+
for alias in node.names:
|
|
430
|
+
_insert_dependency(
|
|
431
|
+
conn, app_id, module_comp_id, None,
|
|
432
|
+
"import", evidence=f"import {alias.name}"
|
|
433
|
+
)
|
|
434
|
+
dependencies_added += 1
|
|
435
|
+
|
|
436
|
+
elif isinstance(node, ast.ImportFrom):
|
|
437
|
+
mod = node.module or ""
|
|
438
|
+
names = ", ".join(a.name for a in node.names) if node.names else "*"
|
|
439
|
+
_insert_dependency(
|
|
440
|
+
conn, app_id, module_comp_id, None,
|
|
441
|
+
"import", evidence=f"from {mod} import {names}"
|
|
442
|
+
)
|
|
443
|
+
dependencies_added += 1
|
|
444
|
+
|
|
445
|
+
# ----- Classes -----
|
|
446
|
+
for node in ast.iter_child_nodes(tree):
|
|
447
|
+
if isinstance(node, ast.ClassDef):
|
|
448
|
+
class_id = f"lcomp-{uuid.uuid4().hex[:12]}"
|
|
449
|
+
bases = [_get_name(b) for b in node.bases]
|
|
450
|
+
decorators = [_get_decorator_name(d) for d in node.decorator_list]
|
|
451
|
+
|
|
452
|
+
class_complexity = _compute_python_complexity(node)
|
|
453
|
+
class_loc = (node.end_lineno or node.lineno) - node.lineno + 1
|
|
454
|
+
|
|
455
|
+
# Determine component type from decorators
|
|
456
|
+
comp_type = "class"
|
|
457
|
+
for dec in decorators:
|
|
458
|
+
if dec and ("Controller" in dec or "controller" in dec):
|
|
459
|
+
comp_type = "controller"
|
|
460
|
+
break
|
|
461
|
+
|
|
462
|
+
props = {
|
|
463
|
+
"bases": bases,
|
|
464
|
+
"decorators": decorators,
|
|
465
|
+
"method_count": sum(
|
|
466
|
+
1 for n in ast.iter_child_nodes(node)
|
|
467
|
+
if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef))
|
|
468
|
+
),
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
conn.execute(
|
|
472
|
+
"""INSERT OR IGNORE INTO legacy_components
|
|
473
|
+
(id, legacy_app_id, name, component_type, file_path,
|
|
474
|
+
qualified_name, parent_component_id, loc,
|
|
475
|
+
cyclomatic_complexity, properties)
|
|
476
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
477
|
+
(
|
|
478
|
+
class_id, app_id, node.name, comp_type, rel_path,
|
|
479
|
+
f"{module_name}.{node.name}", module_comp_id,
|
|
480
|
+
class_loc, class_complexity, json.dumps(props),
|
|
481
|
+
),
|
|
482
|
+
)
|
|
483
|
+
components_added += 1
|
|
484
|
+
|
|
485
|
+
# Inheritance dependencies
|
|
486
|
+
for base_name in bases:
|
|
487
|
+
if base_name and base_name not in ("object",):
|
|
488
|
+
_insert_dependency(
|
|
489
|
+
conn, app_id, class_id, None,
|
|
490
|
+
"inheritance", evidence=f"extends {base_name}"
|
|
491
|
+
)
|
|
492
|
+
dependencies_added += 1
|
|
493
|
+
|
|
494
|
+
# Extract methods inside the class
|
|
495
|
+
for child in ast.iter_child_nodes(node):
|
|
496
|
+
if isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
497
|
+
[_get_decorator_name(d) for d in child.decorator_list]
|
|
498
|
+
|
|
499
|
+
# Detect Flask/Blueprint route decorators
|
|
500
|
+
for dec in child.decorator_list:
|
|
501
|
+
route_info = _extract_flask_route(dec)
|
|
502
|
+
if route_info:
|
|
503
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
504
|
+
conn.execute(
|
|
505
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
506
|
+
(id, legacy_app_id, component_id, method,
|
|
507
|
+
path, handler_function, parameters)
|
|
508
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)""",
|
|
509
|
+
(
|
|
510
|
+
api_id, app_id, class_id,
|
|
511
|
+
route_info["method"], route_info["path"],
|
|
512
|
+
f"{node.name}.{child.name}",
|
|
513
|
+
json.dumps(route_info.get("params", [])),
|
|
514
|
+
),
|
|
515
|
+
)
|
|
516
|
+
apis_added += 1
|
|
517
|
+
|
|
518
|
+
# ----- Top-level functions -----
|
|
519
|
+
elif isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)):
|
|
520
|
+
func_id = f"lcomp-{uuid.uuid4().hex[:12]}"
|
|
521
|
+
func_complexity = _compute_python_complexity(node)
|
|
522
|
+
func_loc = (node.end_lineno or node.lineno) - node.lineno + 1
|
|
523
|
+
decorators = [_get_decorator_name(d) for d in node.decorator_list]
|
|
524
|
+
|
|
525
|
+
conn.execute(
|
|
526
|
+
"""INSERT OR IGNORE INTO legacy_components
|
|
527
|
+
(id, legacy_app_id, name, component_type, file_path,
|
|
528
|
+
qualified_name, parent_component_id, loc,
|
|
529
|
+
cyclomatic_complexity, properties)
|
|
530
|
+
VALUES (?, ?, ?, 'function', ?, ?, ?, ?, ?, ?)""",
|
|
531
|
+
(
|
|
532
|
+
func_id, app_id, node.name, rel_path,
|
|
533
|
+
f"{module_name}.{node.name}", module_comp_id,
|
|
534
|
+
func_loc, func_complexity,
|
|
535
|
+
json.dumps({"decorators": decorators}),
|
|
536
|
+
),
|
|
537
|
+
)
|
|
538
|
+
components_added += 1
|
|
539
|
+
|
|
540
|
+
# Flask route on top-level function
|
|
541
|
+
for dec in node.decorator_list:
|
|
542
|
+
route_info = _extract_flask_route(dec)
|
|
543
|
+
if route_info:
|
|
544
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
545
|
+
conn.execute(
|
|
546
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
547
|
+
(id, legacy_app_id, component_id, method,
|
|
548
|
+
path, handler_function, parameters)
|
|
549
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)""",
|
|
550
|
+
(
|
|
551
|
+
api_id, app_id, func_id,
|
|
552
|
+
route_info["method"], route_info["path"],
|
|
553
|
+
node.name,
|
|
554
|
+
json.dumps(route_info.get("params", [])),
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
apis_added += 1
|
|
558
|
+
|
|
559
|
+
# ----- Django URL patterns -----
|
|
560
|
+
django_urls = _extract_django_urls(source_code, rel_path)
|
|
561
|
+
for url_info in django_urls:
|
|
562
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
563
|
+
conn.execute(
|
|
564
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
565
|
+
(id, legacy_app_id, component_id, method, path,
|
|
566
|
+
handler_function)
|
|
567
|
+
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
568
|
+
(
|
|
569
|
+
api_id, app_id, module_comp_id,
|
|
570
|
+
url_info.get("method", "ALL"),
|
|
571
|
+
url_info["path"],
|
|
572
|
+
url_info.get("handler", ""),
|
|
573
|
+
),
|
|
574
|
+
)
|
|
575
|
+
apis_added += 1
|
|
576
|
+
|
|
577
|
+
conn.commit()
|
|
578
|
+
finally:
|
|
579
|
+
conn.close()
|
|
580
|
+
|
|
581
|
+
print(f"[INFO] Python analysis complete for {app_id}")
|
|
582
|
+
print(f" Components: {components_added} | Dependencies: {dependencies_added} | APIs: {apis_added}")
|
|
583
|
+
return {
|
|
584
|
+
"components": components_added,
|
|
585
|
+
"dependencies": dependencies_added,
|
|
586
|
+
"apis": apis_added,
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
def _get_name(node):
|
|
591
|
+
"""Extract a name string from an AST node (Name, Attribute, or Constant)."""
|
|
592
|
+
if isinstance(node, ast.Name):
|
|
593
|
+
return node.id
|
|
594
|
+
elif isinstance(node, ast.Attribute):
|
|
595
|
+
value = _get_name(node.value)
|
|
596
|
+
return f"{value}.{node.attr}" if value else node.attr
|
|
597
|
+
elif isinstance(node, ast.Constant):
|
|
598
|
+
return str(node.value)
|
|
599
|
+
return None
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
def _get_decorator_name(node):
|
|
603
|
+
"""Extract the decorator name from an AST decorator node."""
|
|
604
|
+
if isinstance(node, ast.Name):
|
|
605
|
+
return node.id
|
|
606
|
+
elif isinstance(node, ast.Attribute):
|
|
607
|
+
return _get_name(node)
|
|
608
|
+
elif isinstance(node, ast.Call):
|
|
609
|
+
return _get_decorator_name(node.func)
|
|
610
|
+
return None
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
def _extract_flask_route(decorator_node):
|
|
614
|
+
"""Extract Flask/Blueprint route info from a decorator AST node.
|
|
615
|
+
|
|
616
|
+
Handles patterns like:
|
|
617
|
+
@app.route('/path', methods=['GET', 'POST'])
|
|
618
|
+
@blueprint.route('/path')
|
|
619
|
+
@app.get('/path')
|
|
620
|
+
@app.post('/path')
|
|
621
|
+
|
|
622
|
+
Returns:
|
|
623
|
+
dict with 'method' and 'path' keys, or None if not a route.
|
|
624
|
+
"""
|
|
625
|
+
if not isinstance(decorator_node, ast.Call):
|
|
626
|
+
return None
|
|
627
|
+
|
|
628
|
+
func = decorator_node.func
|
|
629
|
+
func_name = _get_name(func)
|
|
630
|
+
if not func_name:
|
|
631
|
+
return None
|
|
632
|
+
|
|
633
|
+
# Detect @app.route(...) or @bp.route(...)
|
|
634
|
+
parts = func_name.split(".")
|
|
635
|
+
if len(parts) < 2:
|
|
636
|
+
return None
|
|
637
|
+
|
|
638
|
+
method_name = parts[-1]
|
|
639
|
+
|
|
640
|
+
# Simple HTTP method shortcuts: @app.get, @app.post, etc.
|
|
641
|
+
shortcut_methods = {"get": "GET", "post": "POST", "put": "PUT", "delete": "DELETE", "patch": "PATCH"}
|
|
642
|
+
if method_name in shortcut_methods:
|
|
643
|
+
path = None
|
|
644
|
+
if decorator_node.args:
|
|
645
|
+
path = _get_name(decorator_node.args[0])
|
|
646
|
+
return {"method": shortcut_methods[method_name], "path": path or "/"}
|
|
647
|
+
|
|
648
|
+
if method_name != "route":
|
|
649
|
+
return None
|
|
650
|
+
|
|
651
|
+
# Extract path (first positional arg)
|
|
652
|
+
path = "/"
|
|
653
|
+
if decorator_node.args:
|
|
654
|
+
path_val = _get_name(decorator_node.args[0])
|
|
655
|
+
if path_val:
|
|
656
|
+
path = path_val
|
|
657
|
+
|
|
658
|
+
# Extract methods keyword argument
|
|
659
|
+
methods = ["ALL"]
|
|
660
|
+
for kw in decorator_node.keywords:
|
|
661
|
+
if kw.arg == "methods" and isinstance(kw.value, (ast.List, ast.Tuple)):
|
|
662
|
+
methods = []
|
|
663
|
+
for elt in kw.value.elts:
|
|
664
|
+
m = _get_name(elt)
|
|
665
|
+
if m:
|
|
666
|
+
methods.append(m.upper())
|
|
667
|
+
|
|
668
|
+
# Return one entry per HTTP method
|
|
669
|
+
return {"method": methods[0] if len(methods) == 1 else "ALL", "path": path, "params": methods}
|
|
670
|
+
|
|
671
|
+
|
|
672
|
+
def _extract_django_urls(source_code, rel_path):
|
|
673
|
+
"""Extract Django URL patterns from source code using regex.
|
|
674
|
+
|
|
675
|
+
Looks for urlpatterns list entries like:
|
|
676
|
+
path('api/v1/users/', views.user_list, name='user-list')
|
|
677
|
+
url(r'^users/$', views.user_list)
|
|
678
|
+
|
|
679
|
+
Returns:
|
|
680
|
+
list of dicts with 'path' and 'handler' keys.
|
|
681
|
+
"""
|
|
682
|
+
if "urlpatterns" not in source_code:
|
|
683
|
+
return []
|
|
684
|
+
|
|
685
|
+
results = []
|
|
686
|
+
|
|
687
|
+
# Match path(...) and url(...) calls
|
|
688
|
+
pattern = re.compile(
|
|
689
|
+
r"""(?:path|url)\s*\(\s*['"]([^'"]+)['"]"""
|
|
690
|
+
r"""\s*,\s*([\w.]+)""",
|
|
691
|
+
re.MULTILINE,
|
|
692
|
+
)
|
|
693
|
+
for match in pattern.finditer(source_code):
|
|
694
|
+
url_path = match.group(1)
|
|
695
|
+
handler = match.group(2)
|
|
696
|
+
results.append({"path": url_path, "handler": handler, "method": "ALL"})
|
|
697
|
+
|
|
698
|
+
return results
|
|
699
|
+
|
|
700
|
+
|
|
701
|
+
# ---------------------------------------------------------------------------
|
|
702
|
+
# Java analysis (regex-based)
|
|
703
|
+
# ---------------------------------------------------------------------------
|
|
704
|
+
|
|
705
|
+
def analyze_java(app_id, source_path):
|
|
706
|
+
"""Analyze Java source files using regex pattern matching.
|
|
707
|
+
|
|
708
|
+
Extracts:
|
|
709
|
+
- Package declarations and imports
|
|
710
|
+
- Classes, interfaces, enums with modifiers
|
|
711
|
+
- Methods with visibility modifiers
|
|
712
|
+
- Annotations (@Controller, @Service, @Repository, @Entity, etc.)
|
|
713
|
+
- Spring MVC/Boot API endpoints from @RequestMapping, @GetMapping, etc.
|
|
714
|
+
- Struts Actions from struts-config.xml
|
|
715
|
+
- Spring beans from applicationContext.xml
|
|
716
|
+
|
|
717
|
+
Args:
|
|
718
|
+
app_id: Legacy application ID.
|
|
719
|
+
source_path: Path to the source root.
|
|
720
|
+
|
|
721
|
+
Returns:
|
|
722
|
+
dict with counts of extracted components, dependencies, and APIs.
|
|
723
|
+
"""
|
|
724
|
+
source_path = Path(source_path)
|
|
725
|
+
conn = _get_db()
|
|
726
|
+
|
|
727
|
+
components_added = 0
|
|
728
|
+
dependencies_added = 0
|
|
729
|
+
apis_added = 0
|
|
730
|
+
|
|
731
|
+
# Regex patterns
|
|
732
|
+
re_package = re.compile(r"^\s*package\s+([\w.]+)\s*;", re.MULTILINE)
|
|
733
|
+
re_import = re.compile(r"^\s*import\s+(static\s+)?([\w.*]+)\s*;", re.MULTILINE)
|
|
734
|
+
re_class = re.compile(
|
|
735
|
+
r"(?:public|private|protected)?\s*(?:abstract\s+|final\s+|static\s+)*"
|
|
736
|
+
r"(class|interface|enum)\s+(\w+)"
|
|
737
|
+
r"(?:\s+extends\s+(\w+))?"
|
|
738
|
+
r"(?:\s+implements\s+([\w,\s]+))?",
|
|
739
|
+
re.MULTILINE,
|
|
740
|
+
)
|
|
741
|
+
re.compile(
|
|
742
|
+
r"(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)?(?:synchronized\s+)?"
|
|
743
|
+
r"(?:abstract\s+)?[\w<>\[\],\s?]+\s+(\w+)\s*\(",
|
|
744
|
+
re.MULTILINE,
|
|
745
|
+
)
|
|
746
|
+
re_annotation = re.compile(r"@(\w+)(?:\(([^)]*)\))?", re.MULTILINE)
|
|
747
|
+
|
|
748
|
+
# Annotation-to-component-type mapping
|
|
749
|
+
annotation_type_map = {
|
|
750
|
+
"Controller": "controller",
|
|
751
|
+
"RestController": "controller",
|
|
752
|
+
"Service": "service",
|
|
753
|
+
"Repository": "repository",
|
|
754
|
+
"Entity": "entity",
|
|
755
|
+
"Stateless": "ejb",
|
|
756
|
+
"Stateful": "ejb",
|
|
757
|
+
"Singleton": "ejb",
|
|
758
|
+
"MessageDriven": "ejb",
|
|
759
|
+
"WebServlet": "servlet",
|
|
760
|
+
"ManagedBean": "controller",
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
# HTTP mapping annotations
|
|
764
|
+
http_mapping_annotations = {
|
|
765
|
+
"RequestMapping": None, # method extracted from params
|
|
766
|
+
"GetMapping": "GET",
|
|
767
|
+
"PostMapping": "POST",
|
|
768
|
+
"PutMapping": "PUT",
|
|
769
|
+
"DeleteMapping": "DELETE",
|
|
770
|
+
"PatchMapping": "PATCH",
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
try:
|
|
774
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
775
|
+
for fname in files:
|
|
776
|
+
if not fname.endswith(".java"):
|
|
777
|
+
continue
|
|
778
|
+
|
|
779
|
+
fpath = Path(root) / fname
|
|
780
|
+
rel_path = str(fpath.relative_to(source_path))
|
|
781
|
+
|
|
782
|
+
try:
|
|
783
|
+
source_code = fpath.read_text(encoding="utf-8", errors="replace")
|
|
784
|
+
except (OSError, IOError):
|
|
785
|
+
continue
|
|
786
|
+
|
|
787
|
+
line_counts = _count_lines(fpath)
|
|
788
|
+
|
|
789
|
+
# Package
|
|
790
|
+
pkg_match = re_package.search(source_code)
|
|
791
|
+
package = pkg_match.group(1) if pkg_match else ""
|
|
792
|
+
|
|
793
|
+
# Imports
|
|
794
|
+
import_list = []
|
|
795
|
+
for m in re_import.finditer(source_code):
|
|
796
|
+
import_list.append(m.group(2))
|
|
797
|
+
|
|
798
|
+
# All annotations in the file
|
|
799
|
+
file_annotations = [m.group(1) for m in re_annotation.finditer(source_code)]
|
|
800
|
+
|
|
801
|
+
# Class-level request mapping (prefix)
|
|
802
|
+
class_path_prefix = ""
|
|
803
|
+
class_rm = re.search(
|
|
804
|
+
r"@RequestMapping\s*\(\s*(?:value\s*=\s*)?[\"']([^\"']+)[\"']",
|
|
805
|
+
source_code,
|
|
806
|
+
)
|
|
807
|
+
if class_rm:
|
|
808
|
+
class_path_prefix = class_rm.group(1)
|
|
809
|
+
|
|
810
|
+
# Classes
|
|
811
|
+
for cm in re_class.finditer(source_code):
|
|
812
|
+
kind = cm.group(1) # class, interface, enum
|
|
813
|
+
class_name = cm.group(2)
|
|
814
|
+
extends = cm.group(3)
|
|
815
|
+
implements = cm.group(4)
|
|
816
|
+
|
|
817
|
+
comp_id = f"lcomp-{uuid.uuid4().hex[:12]}"
|
|
818
|
+
qualified = f"{package}.{class_name}" if package else class_name
|
|
819
|
+
|
|
820
|
+
# Determine component type from annotations
|
|
821
|
+
comp_type = kind # default: class, interface, enum
|
|
822
|
+
for ann in file_annotations:
|
|
823
|
+
if ann in annotation_type_map:
|
|
824
|
+
comp_type = annotation_type_map[ann]
|
|
825
|
+
break
|
|
826
|
+
|
|
827
|
+
props = {
|
|
828
|
+
"package": package,
|
|
829
|
+
"extends": extends,
|
|
830
|
+
"implements": [s.strip() for s in implements.split(",")] if implements else [],
|
|
831
|
+
"annotations": list(set(file_annotations)),
|
|
832
|
+
"kind": kind,
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
conn.execute(
|
|
836
|
+
"""INSERT OR IGNORE INTO legacy_components
|
|
837
|
+
(id, legacy_app_id, name, component_type, file_path,
|
|
838
|
+
qualified_name, loc, cyclomatic_complexity, properties)
|
|
839
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
840
|
+
(
|
|
841
|
+
comp_id, app_id, class_name, comp_type, rel_path,
|
|
842
|
+
qualified, line_counts["code"],
|
|
843
|
+
_estimate_complexity_regex(source_code),
|
|
844
|
+
json.dumps(props),
|
|
845
|
+
),
|
|
846
|
+
)
|
|
847
|
+
components_added += 1
|
|
848
|
+
|
|
849
|
+
# Inheritance dependency
|
|
850
|
+
if extends:
|
|
851
|
+
_insert_dependency(
|
|
852
|
+
conn, app_id, comp_id, None,
|
|
853
|
+
"inheritance", evidence=f"extends {extends}"
|
|
854
|
+
)
|
|
855
|
+
dependencies_added += 1
|
|
856
|
+
|
|
857
|
+
# Implements dependency
|
|
858
|
+
if implements:
|
|
859
|
+
for iface in implements.split(","):
|
|
860
|
+
iface = iface.strip()
|
|
861
|
+
if iface:
|
|
862
|
+
_insert_dependency(
|
|
863
|
+
conn, app_id, comp_id, None,
|
|
864
|
+
"inheritance", evidence=f"implements {iface}"
|
|
865
|
+
)
|
|
866
|
+
dependencies_added += 1
|
|
867
|
+
|
|
868
|
+
# Import dependencies
|
|
869
|
+
for imp in import_list:
|
|
870
|
+
_insert_dependency(
|
|
871
|
+
conn, app_id, comp_id, None,
|
|
872
|
+
"import", evidence=f"import {imp}"
|
|
873
|
+
)
|
|
874
|
+
dependencies_added += 1
|
|
875
|
+
|
|
876
|
+
# Annotation-based dependencies (EJB injection, Spring autowire)
|
|
877
|
+
for ann in file_annotations:
|
|
878
|
+
if ann in ("Inject", "Autowired", "EJB", "Resource"):
|
|
879
|
+
_insert_dependency(
|
|
880
|
+
conn, app_id, comp_id, None,
|
|
881
|
+
"injection", evidence=f"@{ann}"
|
|
882
|
+
)
|
|
883
|
+
dependencies_added += 1
|
|
884
|
+
|
|
885
|
+
# HTTP endpoint extraction from annotations
|
|
886
|
+
for ann_name, default_method in http_mapping_annotations.items():
|
|
887
|
+
ann_pattern = re.compile(
|
|
888
|
+
rf"@{ann_name}\s*\(\s*(?:value\s*=\s*)?[\"']([^\"']*)[\"']"
|
|
889
|
+
rf"(?:\s*,\s*method\s*=\s*(?:RequestMethod\.)?(\w+))?",
|
|
890
|
+
re.MULTILINE,
|
|
891
|
+
)
|
|
892
|
+
for am in ann_pattern.finditer(source_code):
|
|
893
|
+
endpoint_path = am.group(1)
|
|
894
|
+
http_method = am.group(2) or default_method or "ALL"
|
|
895
|
+
|
|
896
|
+
full_path = class_path_prefix.rstrip("/") + "/" + endpoint_path.lstrip("/")
|
|
897
|
+
full_path = "/" + full_path.strip("/")
|
|
898
|
+
|
|
899
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
900
|
+
conn.execute(
|
|
901
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
902
|
+
(id, legacy_app_id, component_id, method, path,
|
|
903
|
+
handler_function)
|
|
904
|
+
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
905
|
+
(
|
|
906
|
+
api_id, app_id, comp_id,
|
|
907
|
+
http_method.upper(), full_path,
|
|
908
|
+
f"{class_name}.{ann_name}",
|
|
909
|
+
),
|
|
910
|
+
)
|
|
911
|
+
apis_added += 1
|
|
912
|
+
|
|
913
|
+
# Detect Struts actions from struts-config.xml
|
|
914
|
+
struts_apis = _detect_struts_actions(source_path, app_id)
|
|
915
|
+
apis_added += struts_apis
|
|
916
|
+
|
|
917
|
+
# Detect Spring beans from applicationContext.xml
|
|
918
|
+
spring_deps = _detect_spring_beans(source_path, app_id, conn)
|
|
919
|
+
dependencies_added += spring_deps
|
|
920
|
+
|
|
921
|
+
conn.commit()
|
|
922
|
+
finally:
|
|
923
|
+
conn.close()
|
|
924
|
+
|
|
925
|
+
print(f"[INFO] Java analysis complete for {app_id}")
|
|
926
|
+
print(f" Components: {components_added} | Dependencies: {dependencies_added} | APIs: {apis_added}")
|
|
927
|
+
return {
|
|
928
|
+
"components": components_added,
|
|
929
|
+
"dependencies": dependencies_added,
|
|
930
|
+
"apis": apis_added,
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
def _estimate_complexity_regex(source_code):
|
|
935
|
+
"""Estimate cyclomatic complexity from source code via keyword counting.
|
|
936
|
+
|
|
937
|
+
Used for Java/C# where we do not have AST. Counts branching keywords.
|
|
938
|
+
"""
|
|
939
|
+
complexity = 1
|
|
940
|
+
branching_keywords = [
|
|
941
|
+
r"\bif\s*\(", r"\belse\s+if\s*\(", r"\bfor\s*\(",
|
|
942
|
+
r"\bwhile\s*\(", r"\bcatch\s*\(", r"\bcase\s+",
|
|
943
|
+
r"\b\?\s*", r"&&", r"\|\|",
|
|
944
|
+
]
|
|
945
|
+
for pattern in branching_keywords:
|
|
946
|
+
complexity += len(re.findall(pattern, source_code))
|
|
947
|
+
return complexity
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
def _detect_struts_actions(source_path, app_id):
|
|
951
|
+
"""Parse struts-config.xml for Action mappings if present."""
|
|
952
|
+
config_path = source_path / "WEB-INF" / "struts-config.xml"
|
|
953
|
+
if not config_path.exists():
|
|
954
|
+
# Search for it elsewhere
|
|
955
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
956
|
+
if "struts-config.xml" in files:
|
|
957
|
+
config_path = Path(root) / "struts-config.xml"
|
|
958
|
+
break
|
|
959
|
+
else:
|
|
960
|
+
return 0
|
|
961
|
+
|
|
962
|
+
count = 0
|
|
963
|
+
try:
|
|
964
|
+
content = config_path.read_text(encoding="utf-8", errors="replace")
|
|
965
|
+
# <action path="/login" type="com.example.LoginAction" ...>
|
|
966
|
+
pattern = re.compile(
|
|
967
|
+
r'<action\s+[^>]*path\s*=\s*["\']([^"\']+)["\']'
|
|
968
|
+
r'[^>]*type\s*=\s*["\']([^"\']+)["\']',
|
|
969
|
+
re.IGNORECASE,
|
|
970
|
+
)
|
|
971
|
+
conn = _get_db()
|
|
972
|
+
try:
|
|
973
|
+
for m in pattern.finditer(content):
|
|
974
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
975
|
+
conn.execute(
|
|
976
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
977
|
+
(id, legacy_app_id, component_id, method, path, handler_function)
|
|
978
|
+
VALUES (?, ?, NULL, 'ALL', ?, ?)""",
|
|
979
|
+
(api_id, app_id, m.group(1), m.group(2)),
|
|
980
|
+
)
|
|
981
|
+
count += 1
|
|
982
|
+
conn.commit()
|
|
983
|
+
finally:
|
|
984
|
+
conn.close()
|
|
985
|
+
except (OSError, IOError):
|
|
986
|
+
pass
|
|
987
|
+
return count
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
def _detect_spring_beans(source_path, app_id, conn):
|
|
991
|
+
"""Parse applicationContext.xml for Spring bean definitions."""
|
|
992
|
+
count = 0
|
|
993
|
+
for xml_name in ("applicationContext.xml", "spring-context.xml", "beans.xml"):
|
|
994
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
995
|
+
if xml_name in files:
|
|
996
|
+
xml_path = Path(root) / xml_name
|
|
997
|
+
try:
|
|
998
|
+
content = xml_path.read_text(encoding="utf-8", errors="replace")
|
|
999
|
+
# <bean id="userService" class="com.example.UserService" ...>
|
|
1000
|
+
bean_pattern = re.compile(
|
|
1001
|
+
r'<bean\s+[^>]*id\s*=\s*["\']([^"\']+)["\']'
|
|
1002
|
+
r'[^>]*class\s*=\s*["\']([^"\']+)["\']',
|
|
1003
|
+
re.IGNORECASE,
|
|
1004
|
+
)
|
|
1005
|
+
for m in bean_pattern.finditer(content):
|
|
1006
|
+
bean_id_str = m.group(1)
|
|
1007
|
+
m.group(2)
|
|
1008
|
+
# Look for property refs (injection)
|
|
1009
|
+
ref_pattern = re.compile(
|
|
1010
|
+
rf'<bean[^>]*id\s*=\s*["\'{bean_id_str}["\'].*?</bean>',
|
|
1011
|
+
re.DOTALL | re.IGNORECASE,
|
|
1012
|
+
)
|
|
1013
|
+
bean_block = ref_pattern.search(content)
|
|
1014
|
+
if bean_block:
|
|
1015
|
+
for ref in re.findall(r'ref\s*=\s*["\']([^"\']+)["\']', bean_block.group(0)):
|
|
1016
|
+
count += 1
|
|
1017
|
+
except (OSError, IOError):
|
|
1018
|
+
pass
|
|
1019
|
+
return count
|
|
1020
|
+
|
|
1021
|
+
|
|
1022
|
+
# ---------------------------------------------------------------------------
|
|
1023
|
+
# C# analysis (regex-based)
|
|
1024
|
+
# ---------------------------------------------------------------------------
|
|
1025
|
+
|
|
1026
|
+
def analyze_csharp(app_id, source_path):
|
|
1027
|
+
"""Analyze C# source files using regex pattern matching.
|
|
1028
|
+
|
|
1029
|
+
Extracts:
|
|
1030
|
+
- Namespaces and using statements
|
|
1031
|
+
- Classes, interfaces, structs, enums with modifiers
|
|
1032
|
+
- Methods with visibility
|
|
1033
|
+
- Attributes ([HttpGet], [HttpPost], [Route], [ApiController], etc.)
|
|
1034
|
+
- ASP.NET Web API/MVC endpoints
|
|
1035
|
+
- WCF ServiceContract interfaces
|
|
1036
|
+
- WebForms code-behind detection
|
|
1037
|
+
|
|
1038
|
+
Args:
|
|
1039
|
+
app_id: Legacy application ID.
|
|
1040
|
+
source_path: Path to the source root.
|
|
1041
|
+
|
|
1042
|
+
Returns:
|
|
1043
|
+
dict with counts of extracted components, dependencies, and APIs.
|
|
1044
|
+
"""
|
|
1045
|
+
source_path = Path(source_path)
|
|
1046
|
+
conn = _get_db()
|
|
1047
|
+
|
|
1048
|
+
components_added = 0
|
|
1049
|
+
dependencies_added = 0
|
|
1050
|
+
apis_added = 0
|
|
1051
|
+
|
|
1052
|
+
re_namespace = re.compile(r"^\s*namespace\s+([\w.]+)", re.MULTILINE)
|
|
1053
|
+
re_using = re.compile(r"^\s*using\s+([\w.]+)\s*;", re.MULTILINE)
|
|
1054
|
+
re_class = re.compile(
|
|
1055
|
+
r"(?:public|private|internal|protected)?\s*"
|
|
1056
|
+
r"(?:abstract\s+|sealed\s+|static\s+|partial\s+)*"
|
|
1057
|
+
r"(class|interface|struct|enum)\s+(\w+)"
|
|
1058
|
+
r"(?:\s*:\s*([\w,\s.]+))?",
|
|
1059
|
+
re.MULTILINE,
|
|
1060
|
+
)
|
|
1061
|
+
re.compile(
|
|
1062
|
+
r"(?:public|private|protected|internal)\s+(?:static\s+)?(?:async\s+)?"
|
|
1063
|
+
r"(?:virtual\s+)?(?:override\s+)?(?:abstract\s+)?"
|
|
1064
|
+
r"[\w<>\[\]?,\s]+\s+(\w+)\s*\(",
|
|
1065
|
+
re.MULTILINE,
|
|
1066
|
+
)
|
|
1067
|
+
re_attribute = re.compile(r"\[(\w+)(?:\(([^]]*)\))?\]", re.MULTILINE)
|
|
1068
|
+
|
|
1069
|
+
# Attribute-to-component-type mapping
|
|
1070
|
+
attr_type_map = {
|
|
1071
|
+
"ApiController": "controller",
|
|
1072
|
+
"Controller": "controller",
|
|
1073
|
+
"ServiceContract": "interface",
|
|
1074
|
+
"DataContract": "model",
|
|
1075
|
+
"Table": "entity",
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
# HTTP attribute mapping
|
|
1079
|
+
http_attr_map = {
|
|
1080
|
+
"HttpGet": "GET",
|
|
1081
|
+
"HttpPost": "POST",
|
|
1082
|
+
"HttpPut": "PUT",
|
|
1083
|
+
"HttpDelete": "DELETE",
|
|
1084
|
+
"HttpPatch": "PATCH",
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
try:
|
|
1088
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1089
|
+
for fname in files:
|
|
1090
|
+
if not fname.endswith(".cs"):
|
|
1091
|
+
continue
|
|
1092
|
+
|
|
1093
|
+
fpath = Path(root) / fname
|
|
1094
|
+
rel_path = str(fpath.relative_to(source_path))
|
|
1095
|
+
|
|
1096
|
+
try:
|
|
1097
|
+
source_code = fpath.read_text(encoding="utf-8", errors="replace")
|
|
1098
|
+
except (OSError, IOError):
|
|
1099
|
+
continue
|
|
1100
|
+
|
|
1101
|
+
line_counts = _count_lines(fpath)
|
|
1102
|
+
|
|
1103
|
+
# Namespace
|
|
1104
|
+
ns_match = re_namespace.search(source_code)
|
|
1105
|
+
namespace = ns_match.group(1) if ns_match else ""
|
|
1106
|
+
|
|
1107
|
+
# Using statements
|
|
1108
|
+
usings = [m.group(1) for m in re_using.finditer(source_code)]
|
|
1109
|
+
|
|
1110
|
+
# All attributes in the file
|
|
1111
|
+
file_attrs = [m.group(1) for m in re_attribute.finditer(source_code)]
|
|
1112
|
+
|
|
1113
|
+
# Detect WebForms code-behind
|
|
1114
|
+
is_webforms = fname.endswith(".aspx.cs") or fname.endswith(".ascx.cs")
|
|
1115
|
+
|
|
1116
|
+
# Class-level Route prefix
|
|
1117
|
+
class_route_prefix = ""
|
|
1118
|
+
route_match = re.search(
|
|
1119
|
+
r'\[Route\s*\(\s*["\']([^"\']+)["\']\s*\)\]',
|
|
1120
|
+
source_code,
|
|
1121
|
+
)
|
|
1122
|
+
if route_match:
|
|
1123
|
+
class_route_prefix = route_match.group(1)
|
|
1124
|
+
|
|
1125
|
+
# Classes / interfaces / structs / enums
|
|
1126
|
+
for cm in re_class.finditer(source_code):
|
|
1127
|
+
kind = cm.group(1)
|
|
1128
|
+
class_name = cm.group(2)
|
|
1129
|
+
base_types_str = cm.group(3)
|
|
1130
|
+
|
|
1131
|
+
comp_id = f"lcomp-{uuid.uuid4().hex[:12]}"
|
|
1132
|
+
qualified = f"{namespace}.{class_name}" if namespace else class_name
|
|
1133
|
+
|
|
1134
|
+
# Determine component type
|
|
1135
|
+
comp_type = kind
|
|
1136
|
+
if is_webforms:
|
|
1137
|
+
comp_type = "view"
|
|
1138
|
+
for attr in file_attrs:
|
|
1139
|
+
if attr in attr_type_map:
|
|
1140
|
+
comp_type = attr_type_map[attr]
|
|
1141
|
+
break
|
|
1142
|
+
|
|
1143
|
+
base_types = []
|
|
1144
|
+
if base_types_str:
|
|
1145
|
+
base_types = [b.strip() for b in base_types_str.split(",") if b.strip()]
|
|
1146
|
+
|
|
1147
|
+
props = {
|
|
1148
|
+
"namespace": namespace,
|
|
1149
|
+
"base_types": base_types,
|
|
1150
|
+
"attributes": list(set(file_attrs)),
|
|
1151
|
+
"kind": kind,
|
|
1152
|
+
"is_webforms": is_webforms,
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
conn.execute(
|
|
1156
|
+
"""INSERT OR IGNORE INTO legacy_components
|
|
1157
|
+
(id, legacy_app_id, name, component_type, file_path,
|
|
1158
|
+
qualified_name, loc, cyclomatic_complexity, properties)
|
|
1159
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
|
1160
|
+
(
|
|
1161
|
+
comp_id, app_id, class_name, comp_type, rel_path,
|
|
1162
|
+
qualified, line_counts["code"],
|
|
1163
|
+
_estimate_complexity_regex(source_code),
|
|
1164
|
+
json.dumps(props),
|
|
1165
|
+
),
|
|
1166
|
+
)
|
|
1167
|
+
components_added += 1
|
|
1168
|
+
|
|
1169
|
+
# Inheritance / implementation dependencies
|
|
1170
|
+
for base in base_types:
|
|
1171
|
+
_insert_dependency(
|
|
1172
|
+
conn, app_id, comp_id, None,
|
|
1173
|
+
"inheritance", evidence=f"inherits {base}"
|
|
1174
|
+
)
|
|
1175
|
+
dependencies_added += 1
|
|
1176
|
+
|
|
1177
|
+
# Using dependencies
|
|
1178
|
+
for u in usings:
|
|
1179
|
+
_insert_dependency(
|
|
1180
|
+
conn, app_id, comp_id, None,
|
|
1181
|
+
"import", evidence=f"using {u}"
|
|
1182
|
+
)
|
|
1183
|
+
dependencies_added += 1
|
|
1184
|
+
|
|
1185
|
+
# Injection via [Inject] or constructor injection
|
|
1186
|
+
for attr in file_attrs:
|
|
1187
|
+
if attr in ("Inject", "Dependency"):
|
|
1188
|
+
_insert_dependency(
|
|
1189
|
+
conn, app_id, comp_id, None,
|
|
1190
|
+
"injection", evidence=f"[{attr}]"
|
|
1191
|
+
)
|
|
1192
|
+
dependencies_added += 1
|
|
1193
|
+
|
|
1194
|
+
# WCF ServiceContract detection
|
|
1195
|
+
if "ServiceContract" in file_attrs and kind == "interface":
|
|
1196
|
+
# Extract OperationContract methods as API endpoints
|
|
1197
|
+
op_pattern = re.compile(
|
|
1198
|
+
r'\[OperationContract\].*?'
|
|
1199
|
+
r'(?:public|private|protected|internal)?\s*[\w<>\[\]]+\s+(\w+)\s*\(',
|
|
1200
|
+
re.DOTALL,
|
|
1201
|
+
)
|
|
1202
|
+
for op in op_pattern.finditer(source_code):
|
|
1203
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
1204
|
+
conn.execute(
|
|
1205
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
1206
|
+
(id, legacy_app_id, component_id, method, path,
|
|
1207
|
+
handler_function)
|
|
1208
|
+
VALUES (?, ?, ?, 'ALL', ?, ?)""",
|
|
1209
|
+
(api_id, app_id, comp_id, f"/{op.group(1)}", f"{class_name}.{op.group(1)}"),
|
|
1210
|
+
)
|
|
1211
|
+
apis_added += 1
|
|
1212
|
+
|
|
1213
|
+
# HTTP endpoint extraction from attributes
|
|
1214
|
+
for attr_name, http_method in http_attr_map.items():
|
|
1215
|
+
attr_pattern = re.compile(
|
|
1216
|
+
rf'\[{attr_name}(?:\s*\(\s*["\']([^"\']*)["\'])?\s*\]',
|
|
1217
|
+
re.MULTILINE,
|
|
1218
|
+
)
|
|
1219
|
+
for am in attr_pattern.finditer(source_code):
|
|
1220
|
+
endpoint_path = am.group(1) or ""
|
|
1221
|
+
full_path = class_route_prefix.rstrip("/")
|
|
1222
|
+
if endpoint_path:
|
|
1223
|
+
full_path += "/" + endpoint_path.lstrip("/")
|
|
1224
|
+
if not full_path:
|
|
1225
|
+
full_path = f"/{class_name}"
|
|
1226
|
+
full_path = "/" + full_path.strip("/")
|
|
1227
|
+
|
|
1228
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
1229
|
+
conn.execute(
|
|
1230
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
1231
|
+
(id, legacy_app_id, component_id, method, path,
|
|
1232
|
+
handler_function)
|
|
1233
|
+
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
1234
|
+
(api_id, app_id, comp_id, http_method, full_path, class_name),
|
|
1235
|
+
)
|
|
1236
|
+
apis_added += 1
|
|
1237
|
+
|
|
1238
|
+
# Route attribute on methods
|
|
1239
|
+
route_method_pattern = re.compile(
|
|
1240
|
+
r'\[Route\s*\(\s*["\']([^"\']+)["\']\s*\)\]'
|
|
1241
|
+
r'\s*(?:\[Http(\w+)\])?\s*'
|
|
1242
|
+
r'(?:public|private|protected|internal)\s+[\w<>\[\]]+\s+(\w+)\s*\(',
|
|
1243
|
+
re.MULTILINE,
|
|
1244
|
+
)
|
|
1245
|
+
for rm in route_method_pattern.finditer(source_code):
|
|
1246
|
+
r_path = rm.group(1)
|
|
1247
|
+
r_method = rm.group(2) or "ALL"
|
|
1248
|
+
r_handler = rm.group(3)
|
|
1249
|
+
|
|
1250
|
+
full_path = "/" + class_route_prefix.strip("/")
|
|
1251
|
+
if r_path:
|
|
1252
|
+
full_path += "/" + r_path.lstrip("/")
|
|
1253
|
+
full_path = "/" + full_path.strip("/")
|
|
1254
|
+
|
|
1255
|
+
api_id = f"lapi-{uuid.uuid4().hex[:12]}"
|
|
1256
|
+
conn.execute(
|
|
1257
|
+
"""INSERT OR IGNORE INTO legacy_apis
|
|
1258
|
+
(id, legacy_app_id, component_id, method, path,
|
|
1259
|
+
handler_function)
|
|
1260
|
+
VALUES (?, ?, ?, ?, ?, ?)""",
|
|
1261
|
+
(
|
|
1262
|
+
api_id, app_id, comp_id,
|
|
1263
|
+
r_method.upper(), full_path,
|
|
1264
|
+
f"{class_name}.{r_handler}",
|
|
1265
|
+
),
|
|
1266
|
+
)
|
|
1267
|
+
apis_added += 1
|
|
1268
|
+
|
|
1269
|
+
conn.commit()
|
|
1270
|
+
finally:
|
|
1271
|
+
conn.close()
|
|
1272
|
+
|
|
1273
|
+
print(f"[INFO] C# analysis complete for {app_id}")
|
|
1274
|
+
print(f" Components: {components_added} | Dependencies: {dependencies_added} | APIs: {apis_added}")
|
|
1275
|
+
return {
|
|
1276
|
+
"components": components_added,
|
|
1277
|
+
"dependencies": dependencies_added,
|
|
1278
|
+
"apis": apis_added,
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
|
|
1282
|
+
# ---------------------------------------------------------------------------
|
|
1283
|
+
# Shared helpers
|
|
1284
|
+
# ---------------------------------------------------------------------------
|
|
1285
|
+
|
|
1286
|
+
def _insert_dependency(conn, app_id, source_comp_id, target_comp_id, dep_type, evidence=None):
|
|
1287
|
+
"""Insert a dependency record, ignoring duplicates."""
|
|
1288
|
+
try:
|
|
1289
|
+
conn.execute(
|
|
1290
|
+
"""INSERT OR IGNORE INTO legacy_dependencies
|
|
1291
|
+
(legacy_app_id, source_component_id, target_component_id,
|
|
1292
|
+
dependency_type, evidence)
|
|
1293
|
+
VALUES (?, ?, ?, ?, ?)""",
|
|
1294
|
+
(app_id, source_comp_id, target_comp_id, dep_type, evidence),
|
|
1295
|
+
)
|
|
1296
|
+
except sqlite3.IntegrityError:
|
|
1297
|
+
pass # Duplicate — ignore
|
|
1298
|
+
|
|
1299
|
+
|
|
1300
|
+
# ---------------------------------------------------------------------------
|
|
1301
|
+
# Framework and database detection
|
|
1302
|
+
# ---------------------------------------------------------------------------
|
|
1303
|
+
|
|
1304
|
+
def _detect_framework(source_path, language):
|
|
1305
|
+
"""Identify the application framework from file/code indicators.
|
|
1306
|
+
|
|
1307
|
+
Args:
|
|
1308
|
+
source_path: Path to source root.
|
|
1309
|
+
language: Primary language string (python, java, csharp).
|
|
1310
|
+
|
|
1311
|
+
Returns:
|
|
1312
|
+
Tuple of (framework_name, framework_version_guess) or (None, None).
|
|
1313
|
+
"""
|
|
1314
|
+
source_path = Path(source_path)
|
|
1315
|
+
|
|
1316
|
+
if language == "python":
|
|
1317
|
+
# Django: settings.py + urls.py
|
|
1318
|
+
has_settings = False
|
|
1319
|
+
has_urls = False
|
|
1320
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1321
|
+
if "settings.py" in files:
|
|
1322
|
+
has_settings = True
|
|
1323
|
+
if "urls.py" in files:
|
|
1324
|
+
has_urls = True
|
|
1325
|
+
if has_settings and has_urls:
|
|
1326
|
+
return ("Django", _detect_version_from_requirements(source_path, "django"))
|
|
1327
|
+
|
|
1328
|
+
# Flask: app.py (or wsgi.py) with Flask import
|
|
1329
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1330
|
+
for f in files:
|
|
1331
|
+
if f in ("app.py", "wsgi.py", "application.py", "__init__.py"):
|
|
1332
|
+
fpath = Path(root) / f
|
|
1333
|
+
try:
|
|
1334
|
+
content = fpath.read_text(encoding="utf-8", errors="replace")
|
|
1335
|
+
if "from flask" in content.lower() or "import flask" in content.lower():
|
|
1336
|
+
return ("Flask", _detect_version_from_requirements(source_path, "flask"))
|
|
1337
|
+
except (OSError, IOError):
|
|
1338
|
+
pass
|
|
1339
|
+
|
|
1340
|
+
# Pyramid
|
|
1341
|
+
setup_py = source_path / "setup.py"
|
|
1342
|
+
if setup_py.exists():
|
|
1343
|
+
try:
|
|
1344
|
+
content = setup_py.read_text(encoding="utf-8", errors="replace")
|
|
1345
|
+
if "pyramid" in content.lower():
|
|
1346
|
+
return ("Pyramid", _detect_version_from_requirements(source_path, "pyramid"))
|
|
1347
|
+
except (OSError, IOError):
|
|
1348
|
+
pass
|
|
1349
|
+
|
|
1350
|
+
elif language == "java":
|
|
1351
|
+
# Struts
|
|
1352
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1353
|
+
if "struts-config.xml" in files:
|
|
1354
|
+
return ("Struts", None)
|
|
1355
|
+
|
|
1356
|
+
# EJB
|
|
1357
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1358
|
+
if "ejb-jar.xml" in files:
|
|
1359
|
+
return ("EJB", None)
|
|
1360
|
+
|
|
1361
|
+
# Spring / Spring Boot
|
|
1362
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1363
|
+
for f in files:
|
|
1364
|
+
if f.endswith(".java"):
|
|
1365
|
+
fpath = Path(root) / f
|
|
1366
|
+
try:
|
|
1367
|
+
content = fpath.read_text(encoding="utf-8", errors="replace")
|
|
1368
|
+
if "@SpringBootApplication" in content:
|
|
1369
|
+
return ("Spring Boot", _detect_spring_version(source_path))
|
|
1370
|
+
if "@Controller" in content or "@Service" in content:
|
|
1371
|
+
return ("Spring", _detect_spring_version(source_path))
|
|
1372
|
+
except (OSError, IOError):
|
|
1373
|
+
pass
|
|
1374
|
+
|
|
1375
|
+
# Servlet-only (web.xml)
|
|
1376
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1377
|
+
if "web.xml" in files:
|
|
1378
|
+
return ("Servlet", None)
|
|
1379
|
+
|
|
1380
|
+
elif language == "csharp":
|
|
1381
|
+
# Check .csproj for target framework
|
|
1382
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1383
|
+
for f in files:
|
|
1384
|
+
if f.endswith(".csproj"):
|
|
1385
|
+
fpath = Path(root) / f
|
|
1386
|
+
try:
|
|
1387
|
+
content = fpath.read_text(encoding="utf-8", errors="replace")
|
|
1388
|
+
tf_match = re.search(r"<TargetFramework>(.*?)</TargetFramework>", content)
|
|
1389
|
+
fw_version = tf_match.group(1) if tf_match else None
|
|
1390
|
+
|
|
1391
|
+
if "Microsoft.NET.Sdk.Web" in content:
|
|
1392
|
+
return ("ASP.NET Core", fw_version)
|
|
1393
|
+
except (OSError, IOError):
|
|
1394
|
+
pass
|
|
1395
|
+
|
|
1396
|
+
# WCF
|
|
1397
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1398
|
+
for f in files:
|
|
1399
|
+
if f.endswith(".cs"):
|
|
1400
|
+
try:
|
|
1401
|
+
content = (Path(root) / f).read_text(encoding="utf-8", errors="replace")
|
|
1402
|
+
if "[ServiceContract]" in content:
|
|
1403
|
+
return ("WCF", None)
|
|
1404
|
+
except (OSError, IOError):
|
|
1405
|
+
pass
|
|
1406
|
+
|
|
1407
|
+
# WebForms
|
|
1408
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1409
|
+
for f in files:
|
|
1410
|
+
if f.endswith(".aspx"):
|
|
1411
|
+
return ("WebForms", None)
|
|
1412
|
+
|
|
1413
|
+
# Razor Pages
|
|
1414
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1415
|
+
for f in files:
|
|
1416
|
+
if f.endswith(".cshtml"):
|
|
1417
|
+
try:
|
|
1418
|
+
content = (Path(root) / f).read_text(encoding="utf-8", errors="replace")
|
|
1419
|
+
if "@page" in content:
|
|
1420
|
+
return ("Razor Pages", None)
|
|
1421
|
+
except (OSError, IOError):
|
|
1422
|
+
pass
|
|
1423
|
+
|
|
1424
|
+
return (None, None)
|
|
1425
|
+
|
|
1426
|
+
|
|
1427
|
+
def _detect_version_from_requirements(source_path, package_name):
|
|
1428
|
+
"""Try to extract a package version from requirements.txt or Pipfile."""
|
|
1429
|
+
for req_file in ("requirements.txt", "requirements/base.txt", "requirements/production.txt"):
|
|
1430
|
+
req_path = source_path / req_file
|
|
1431
|
+
if req_path.exists():
|
|
1432
|
+
try:
|
|
1433
|
+
for line in req_path.read_text(encoding="utf-8", errors="replace").splitlines():
|
|
1434
|
+
line = line.strip().lower()
|
|
1435
|
+
if line.startswith(package_name.lower()):
|
|
1436
|
+
# e.g., django==3.2.1 or flask>=2.0
|
|
1437
|
+
version_match = re.search(r"[=><]+(.+)", line)
|
|
1438
|
+
if version_match:
|
|
1439
|
+
return version_match.group(1).strip()
|
|
1440
|
+
except (OSError, IOError):
|
|
1441
|
+
pass
|
|
1442
|
+
return None
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
def _detect_spring_version(source_path):
|
|
1446
|
+
"""Attempt to detect Spring version from pom.xml or build.gradle."""
|
|
1447
|
+
pom = source_path / "pom.xml"
|
|
1448
|
+
if pom.exists():
|
|
1449
|
+
try:
|
|
1450
|
+
content = pom.read_text(encoding="utf-8", errors="replace")
|
|
1451
|
+
v = re.search(r"<spring-boot\.version>(.*?)</spring-boot\.version>", content)
|
|
1452
|
+
if v:
|
|
1453
|
+
return v.group(1)
|
|
1454
|
+
v = re.search(r"<version>(.*?)</version>", content)
|
|
1455
|
+
if v:
|
|
1456
|
+
return v.group(1)
|
|
1457
|
+
except (OSError, IOError):
|
|
1458
|
+
pass
|
|
1459
|
+
|
|
1460
|
+
gradle = source_path / "build.gradle"
|
|
1461
|
+
if gradle.exists():
|
|
1462
|
+
try:
|
|
1463
|
+
content = gradle.read_text(encoding="utf-8", errors="replace")
|
|
1464
|
+
v = re.search(r"springBootVersion\s*=\s*['\"]([^'\"]+)['\"]", content)
|
|
1465
|
+
if v:
|
|
1466
|
+
return v.group(1)
|
|
1467
|
+
except (OSError, IOError):
|
|
1468
|
+
pass
|
|
1469
|
+
|
|
1470
|
+
return None
|
|
1471
|
+
|
|
1472
|
+
|
|
1473
|
+
def _detect_database(source_path):
|
|
1474
|
+
"""Detect database type from configuration files and source code.
|
|
1475
|
+
|
|
1476
|
+
Searches for:
|
|
1477
|
+
- Python: Django DATABASES setting, SQLAlchemy URLs, DB driver imports
|
|
1478
|
+
- Java: JDBC URLs, Hibernate config, JPA persistence.xml
|
|
1479
|
+
- C#: connection strings in web.config/appsettings.json
|
|
1480
|
+
|
|
1481
|
+
Args:
|
|
1482
|
+
source_path: Path to source root.
|
|
1483
|
+
|
|
1484
|
+
Returns:
|
|
1485
|
+
Database type string (e.g. 'postgresql', 'mysql', 'oracle') or None.
|
|
1486
|
+
"""
|
|
1487
|
+
source_path = Path(source_path)
|
|
1488
|
+
|
|
1489
|
+
db_indicators = {
|
|
1490
|
+
"postgresql": [
|
|
1491
|
+
"psycopg2", "postgresql", "postgres", "org.postgresql",
|
|
1492
|
+
"Npgsql", "5432",
|
|
1493
|
+
],
|
|
1494
|
+
"mysql": [
|
|
1495
|
+
"pymysql", "mysqlclient", "mysql-connector", "com.mysql",
|
|
1496
|
+
"MySql.Data", "3306",
|
|
1497
|
+
],
|
|
1498
|
+
"oracle": [
|
|
1499
|
+
"cx_Oracle", "oracledb", "oracle.jdbc", "Oracle.ManagedDataAccess",
|
|
1500
|
+
"1521",
|
|
1501
|
+
],
|
|
1502
|
+
"mssql": [
|
|
1503
|
+
"pyodbc", "pymssql", "com.microsoft.sqlserver",
|
|
1504
|
+
"System.Data.SqlClient", "SqlConnection", "1433",
|
|
1505
|
+
],
|
|
1506
|
+
"sqlite": [
|
|
1507
|
+
"sqlite3", "org.sqlite", "Microsoft.Data.Sqlite",
|
|
1508
|
+
"System.Data.SQLite",
|
|
1509
|
+
],
|
|
1510
|
+
"db2": ["ibm_db", "com.ibm.db2"],
|
|
1511
|
+
"h2": ["org.h2"],
|
|
1512
|
+
"derby": ["org.apache.derby"],
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
# Scan files for DB indicators
|
|
1516
|
+
scan_extensions = {".py", ".java", ".cs", ".xml", ".json", ".properties", ".yaml", ".yml", ".cfg", ".ini", ".config"}
|
|
1517
|
+
scan_filenames = {
|
|
1518
|
+
"settings.py", "database.py", "db.py",
|
|
1519
|
+
"application.properties", "application.yml", "application.yaml",
|
|
1520
|
+
"persistence.xml", "hibernate.cfg.xml",
|
|
1521
|
+
"web.config", "appsettings.json", "appsettings.Development.json",
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
for root, _dirs, files in os.walk(str(source_path)):
|
|
1525
|
+
for fname in files:
|
|
1526
|
+
ext = Path(fname).suffix.lower()
|
|
1527
|
+
if ext not in scan_extensions and fname not in scan_filenames:
|
|
1528
|
+
continue
|
|
1529
|
+
|
|
1530
|
+
fpath = Path(root) / fname
|
|
1531
|
+
try:
|
|
1532
|
+
content = fpath.read_text(encoding="utf-8", errors="replace").lower()
|
|
1533
|
+
except (OSError, IOError):
|
|
1534
|
+
continue
|
|
1535
|
+
|
|
1536
|
+
for db_type, indicators in db_indicators.items():
|
|
1537
|
+
for indicator in indicators:
|
|
1538
|
+
if indicator.lower() in content:
|
|
1539
|
+
return db_type
|
|
1540
|
+
|
|
1541
|
+
return None
|
|
1542
|
+
|
|
1543
|
+
|
|
1544
|
+
# ---------------------------------------------------------------------------
|
|
1545
|
+
# Quality metrics
|
|
1546
|
+
# ---------------------------------------------------------------------------
|
|
1547
|
+
|
|
1548
|
+
def _compute_tech_debt(app_id):
|
|
1549
|
+
"""Estimate technical debt in hours for a legacy application.
|
|
1550
|
+
|
|
1551
|
+
Formula per component:
|
|
1552
|
+
debt = (LOC * complexity_factor * coupling_factor) / productivity_rate
|
|
1553
|
+
|
|
1554
|
+
Where:
|
|
1555
|
+
complexity_factor: 1.0 (CC<5), 1.5 (5-10), 2.0 (10-20), 3.0 (>20)
|
|
1556
|
+
coupling_factor: 1.0 (deps<3), 1.2 (3-6), 1.5 (>6)
|
|
1557
|
+
productivity_rate: 20 LOC/hour
|
|
1558
|
+
|
|
1559
|
+
Args:
|
|
1560
|
+
app_id: Legacy application ID.
|
|
1561
|
+
|
|
1562
|
+
Returns:
|
|
1563
|
+
Total estimated tech debt hours (float).
|
|
1564
|
+
"""
|
|
1565
|
+
conn = _get_db()
|
|
1566
|
+
try:
|
|
1567
|
+
rows = conn.execute(
|
|
1568
|
+
"""SELECT loc, cyclomatic_complexity, dependencies_out
|
|
1569
|
+
FROM legacy_components WHERE legacy_app_id = ?""",
|
|
1570
|
+
(app_id,),
|
|
1571
|
+
).fetchall()
|
|
1572
|
+
finally:
|
|
1573
|
+
conn.close()
|
|
1574
|
+
|
|
1575
|
+
if not rows:
|
|
1576
|
+
return 0.0
|
|
1577
|
+
|
|
1578
|
+
total_debt = 0.0
|
|
1579
|
+
for row in rows:
|
|
1580
|
+
loc = row["loc"] or 0
|
|
1581
|
+
cc = row["cyclomatic_complexity"] or 1
|
|
1582
|
+
deps = row["dependencies_out"] or 0
|
|
1583
|
+
|
|
1584
|
+
# Complexity factor
|
|
1585
|
+
if cc < 5:
|
|
1586
|
+
complexity_factor = 1.0
|
|
1587
|
+
elif cc < 10:
|
|
1588
|
+
complexity_factor = 1.5
|
|
1589
|
+
elif cc < 20:
|
|
1590
|
+
complexity_factor = 2.0
|
|
1591
|
+
else:
|
|
1592
|
+
complexity_factor = 3.0
|
|
1593
|
+
|
|
1594
|
+
# Coupling factor
|
|
1595
|
+
if deps < 3:
|
|
1596
|
+
coupling_factor = 1.0
|
|
1597
|
+
elif deps <= 6:
|
|
1598
|
+
coupling_factor = 1.2
|
|
1599
|
+
else:
|
|
1600
|
+
coupling_factor = 1.5
|
|
1601
|
+
|
|
1602
|
+
total_debt += (loc * complexity_factor * coupling_factor) / PRODUCTIVITY_RATE
|
|
1603
|
+
|
|
1604
|
+
return round(total_debt, 2)
|
|
1605
|
+
|
|
1606
|
+
|
|
1607
|
+
def _compute_maintainability_index(app_id):
|
|
1608
|
+
"""Compute a Halstead-simplified Maintainability Index (0-100).
|
|
1609
|
+
|
|
1610
|
+
MI = max(0, (171 - 5.2*ln(avg_CC) - 0.23*avg_coupling - 16.2*ln(avg_LOC)) * 100 / 171)
|
|
1611
|
+
|
|
1612
|
+
This is the Microsoft Visual Studio variant of the maintainability index,
|
|
1613
|
+
scaled to 0-100 where higher is better.
|
|
1614
|
+
|
|
1615
|
+
Args:
|
|
1616
|
+
app_id: Legacy application ID.
|
|
1617
|
+
|
|
1618
|
+
Returns:
|
|
1619
|
+
Maintainability index score (float, 0-100).
|
|
1620
|
+
"""
|
|
1621
|
+
conn = _get_db()
|
|
1622
|
+
try:
|
|
1623
|
+
rows = conn.execute(
|
|
1624
|
+
"""SELECT loc, cyclomatic_complexity, coupling_score
|
|
1625
|
+
FROM legacy_components WHERE legacy_app_id = ?""",
|
|
1626
|
+
(app_id,),
|
|
1627
|
+
).fetchall()
|
|
1628
|
+
finally:
|
|
1629
|
+
conn.close()
|
|
1630
|
+
|
|
1631
|
+
if not rows:
|
|
1632
|
+
return 0.0
|
|
1633
|
+
|
|
1634
|
+
total_cc = 0.0
|
|
1635
|
+
total_coupling = 0.0
|
|
1636
|
+
total_loc = 0.0
|
|
1637
|
+
count = 0
|
|
1638
|
+
|
|
1639
|
+
for row in rows:
|
|
1640
|
+
loc = row["loc"] or 1
|
|
1641
|
+
cc = row["cyclomatic_complexity"] or 1
|
|
1642
|
+
coupling = row["coupling_score"] or 0
|
|
1643
|
+
|
|
1644
|
+
total_cc += cc
|
|
1645
|
+
total_coupling += coupling
|
|
1646
|
+
total_loc += loc
|
|
1647
|
+
count += 1
|
|
1648
|
+
|
|
1649
|
+
if count == 0:
|
|
1650
|
+
return 0.0
|
|
1651
|
+
|
|
1652
|
+
avg_cc = max(total_cc / count, 1.0)
|
|
1653
|
+
avg_coupling = total_coupling / count
|
|
1654
|
+
avg_loc = max(total_loc / count, 1.0)
|
|
1655
|
+
|
|
1656
|
+
mi_raw = 171.0 - 5.2 * math.log(avg_cc) - 0.23 * avg_coupling - 16.2 * math.log(avg_loc)
|
|
1657
|
+
mi = max(0.0, mi_raw * 100.0 / 171.0)
|
|
1658
|
+
return round(min(mi, 100.0), 2)
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
# ---------------------------------------------------------------------------
|
|
1662
|
+
# Full analysis orchestrator
|
|
1663
|
+
# ---------------------------------------------------------------------------
|
|
1664
|
+
|
|
1665
|
+
def analyze_full(project_id, app_id, source_path_override=None):
|
|
1666
|
+
"""Run complete static analysis on a registered legacy application.
|
|
1667
|
+
|
|
1668
|
+
Orchestrates:
|
|
1669
|
+
1. Fetch app record from DB
|
|
1670
|
+
2. Dispatch to language-specific analyzer
|
|
1671
|
+
3. Detect framework and database
|
|
1672
|
+
4. Compute tech debt and maintainability index
|
|
1673
|
+
5. Update DB with results
|
|
1674
|
+
|
|
1675
|
+
Args:
|
|
1676
|
+
project_id: ICDEV project ID.
|
|
1677
|
+
app_id: Legacy application ID.
|
|
1678
|
+
source_path_override: Optional override for the source path.
|
|
1679
|
+
|
|
1680
|
+
Returns:
|
|
1681
|
+
Summary dict with all analysis results.
|
|
1682
|
+
"""
|
|
1683
|
+
conn = _get_db()
|
|
1684
|
+
try:
|
|
1685
|
+
row = conn.execute(
|
|
1686
|
+
"SELECT * FROM legacy_applications WHERE id = ? AND project_id = ?",
|
|
1687
|
+
(app_id, project_id),
|
|
1688
|
+
).fetchone()
|
|
1689
|
+
finally:
|
|
1690
|
+
conn.close()
|
|
1691
|
+
|
|
1692
|
+
if not row:
|
|
1693
|
+
raise ValueError(f"Application {app_id} not found in project {project_id}")
|
|
1694
|
+
|
|
1695
|
+
source_path = Path(source_path_override or row["source_path"])
|
|
1696
|
+
language = row["primary_language"]
|
|
1697
|
+
|
|
1698
|
+
if not source_path.is_dir():
|
|
1699
|
+
raise FileNotFoundError(f"Source path does not exist: {source_path}")
|
|
1700
|
+
|
|
1701
|
+
print(f"[INFO] Starting full analysis of {row['name']} ({app_id})")
|
|
1702
|
+
print(f" Language: {language} | Source: {source_path}")
|
|
1703
|
+
|
|
1704
|
+
# Mark as analyzing
|
|
1705
|
+
conn = _get_db()
|
|
1706
|
+
try:
|
|
1707
|
+
conn.execute(
|
|
1708
|
+
"UPDATE legacy_applications SET analysis_status = 'analyzing' WHERE id = ?",
|
|
1709
|
+
(app_id,),
|
|
1710
|
+
)
|
|
1711
|
+
conn.commit()
|
|
1712
|
+
finally:
|
|
1713
|
+
conn.close()
|
|
1714
|
+
|
|
1715
|
+
# Language-specific analysis
|
|
1716
|
+
analysis_result = {"components": 0, "dependencies": 0, "apis": 0}
|
|
1717
|
+
try:
|
|
1718
|
+
if language == "python":
|
|
1719
|
+
analysis_result = analyze_python(app_id, source_path)
|
|
1720
|
+
elif language == "java":
|
|
1721
|
+
analysis_result = analyze_java(app_id, source_path)
|
|
1722
|
+
elif language == "csharp":
|
|
1723
|
+
analysis_result = analyze_csharp(app_id, source_path)
|
|
1724
|
+
else:
|
|
1725
|
+
print(f"[WARN] No analyzer available for language: {language}")
|
|
1726
|
+
print(" Supported: python, java, csharp")
|
|
1727
|
+
except Exception as exc:
|
|
1728
|
+
print(f"[ERROR] Analysis failed: {exc}")
|
|
1729
|
+
conn = _get_db()
|
|
1730
|
+
try:
|
|
1731
|
+
conn.execute(
|
|
1732
|
+
"UPDATE legacy_applications SET analysis_status = 'failed' WHERE id = ?",
|
|
1733
|
+
(app_id,),
|
|
1734
|
+
)
|
|
1735
|
+
conn.commit()
|
|
1736
|
+
finally:
|
|
1737
|
+
conn.close()
|
|
1738
|
+
raise
|
|
1739
|
+
|
|
1740
|
+
# Update dependency counts on components
|
|
1741
|
+
_update_dependency_counts(app_id)
|
|
1742
|
+
|
|
1743
|
+
# Detect framework and database
|
|
1744
|
+
framework, framework_version = _detect_framework(source_path, language)
|
|
1745
|
+
db_type = _detect_database(source_path)
|
|
1746
|
+
|
|
1747
|
+
# Compute quality metrics
|
|
1748
|
+
tech_debt = _compute_tech_debt(app_id)
|
|
1749
|
+
maintainability = _compute_maintainability_index(app_id)
|
|
1750
|
+
|
|
1751
|
+
# Compute average complexity score
|
|
1752
|
+
conn = _get_db()
|
|
1753
|
+
try:
|
|
1754
|
+
avg_row = conn.execute(
|
|
1755
|
+
"""SELECT AVG(cyclomatic_complexity) as avg_cc
|
|
1756
|
+
FROM legacy_components WHERE legacy_app_id = ?""",
|
|
1757
|
+
(app_id,),
|
|
1758
|
+
).fetchone()
|
|
1759
|
+
avg_complexity = round(avg_row["avg_cc"] or 0.0, 2) if avg_row else 0.0
|
|
1760
|
+
finally:
|
|
1761
|
+
conn.close()
|
|
1762
|
+
|
|
1763
|
+
# Update the application record
|
|
1764
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
1765
|
+
conn = _get_db()
|
|
1766
|
+
try:
|
|
1767
|
+
conn.execute(
|
|
1768
|
+
"""UPDATE legacy_applications
|
|
1769
|
+
SET framework = ?, framework_version = ?,
|
|
1770
|
+
tech_debt_hours = ?, maintainability_index = ?,
|
|
1771
|
+
complexity_score = ?, analysis_status = 'analyzed',
|
|
1772
|
+
analyzed_at = ?
|
|
1773
|
+
WHERE id = ?""",
|
|
1774
|
+
(
|
|
1775
|
+
framework, framework_version,
|
|
1776
|
+
tech_debt, maintainability,
|
|
1777
|
+
avg_complexity, now, app_id,
|
|
1778
|
+
),
|
|
1779
|
+
)
|
|
1780
|
+
conn.commit()
|
|
1781
|
+
finally:
|
|
1782
|
+
conn.close()
|
|
1783
|
+
|
|
1784
|
+
summary = {
|
|
1785
|
+
"app_id": app_id,
|
|
1786
|
+
"project_id": project_id,
|
|
1787
|
+
"name": row["name"],
|
|
1788
|
+
"language": language,
|
|
1789
|
+
"framework": framework,
|
|
1790
|
+
"framework_version": framework_version,
|
|
1791
|
+
"database_detected": db_type,
|
|
1792
|
+
"analysis_status": "analyzed",
|
|
1793
|
+
"components_found": analysis_result["components"],
|
|
1794
|
+
"dependencies_found": analysis_result["dependencies"],
|
|
1795
|
+
"apis_found": analysis_result["apis"],
|
|
1796
|
+
"loc_total": row["loc_total"],
|
|
1797
|
+
"loc_code": row["loc_code"],
|
|
1798
|
+
"file_count": row["file_count"],
|
|
1799
|
+
"complexity_score": avg_complexity,
|
|
1800
|
+
"tech_debt_hours": tech_debt,
|
|
1801
|
+
"maintainability_index": maintainability,
|
|
1802
|
+
"analyzed_at": now,
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
print(f"[INFO] Analysis complete for {row['name']}")
|
|
1806
|
+
print(f" Framework: {framework or 'unknown'} {framework_version or ''}")
|
|
1807
|
+
print(f" Database: {db_type or 'not detected'}")
|
|
1808
|
+
print(f" Components: {analysis_result['components']} | "
|
|
1809
|
+
f"Dependencies: {analysis_result['dependencies']} | "
|
|
1810
|
+
f"APIs: {analysis_result['apis']}")
|
|
1811
|
+
print(f" Complexity: {avg_complexity} | Tech Debt: {tech_debt}h | "
|
|
1812
|
+
f"Maintainability: {maintainability}")
|
|
1813
|
+
|
|
1814
|
+
return summary
|
|
1815
|
+
|
|
1816
|
+
|
|
1817
|
+
def _update_dependency_counts(app_id):
|
|
1818
|
+
"""Update dependencies_in and dependencies_out counts on all components."""
|
|
1819
|
+
conn = _get_db()
|
|
1820
|
+
try:
|
|
1821
|
+
# Count outgoing dependencies per component
|
|
1822
|
+
out_counts = conn.execute(
|
|
1823
|
+
"""SELECT source_component_id, COUNT(*) as cnt
|
|
1824
|
+
FROM legacy_dependencies
|
|
1825
|
+
WHERE legacy_app_id = ? AND source_component_id IS NOT NULL
|
|
1826
|
+
GROUP BY source_component_id""",
|
|
1827
|
+
(app_id,),
|
|
1828
|
+
).fetchall()
|
|
1829
|
+
|
|
1830
|
+
for row in out_counts:
|
|
1831
|
+
conn.execute(
|
|
1832
|
+
"UPDATE legacy_components SET dependencies_out = ? WHERE id = ?",
|
|
1833
|
+
(row["cnt"], row["source_component_id"]),
|
|
1834
|
+
)
|
|
1835
|
+
|
|
1836
|
+
# Count incoming dependencies per component
|
|
1837
|
+
in_counts = conn.execute(
|
|
1838
|
+
"""SELECT target_component_id, COUNT(*) as cnt
|
|
1839
|
+
FROM legacy_dependencies
|
|
1840
|
+
WHERE legacy_app_id = ? AND target_component_id IS NOT NULL
|
|
1841
|
+
GROUP BY target_component_id""",
|
|
1842
|
+
(app_id,),
|
|
1843
|
+
).fetchall()
|
|
1844
|
+
|
|
1845
|
+
for row in in_counts:
|
|
1846
|
+
conn.execute(
|
|
1847
|
+
"UPDATE legacy_components SET dependencies_in = ? WHERE id = ?",
|
|
1848
|
+
(row["cnt"], row["target_component_id"]),
|
|
1849
|
+
)
|
|
1850
|
+
|
|
1851
|
+
conn.commit()
|
|
1852
|
+
finally:
|
|
1853
|
+
conn.close()
|
|
1854
|
+
|
|
1855
|
+
|
|
1856
|
+
# ---------------------------------------------------------------------------
|
|
1857
|
+
# CLI interface
|
|
1858
|
+
# ---------------------------------------------------------------------------
|
|
1859
|
+
|
|
1860
|
+
def main():
|
|
1861
|
+
"""Command-line entry point for legacy code analysis."""
|
|
1862
|
+
parser = argparse.ArgumentParser(
|
|
1863
|
+
description="CUI // SP-CTI — Legacy Code Static Analysis Engine",
|
|
1864
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
1865
|
+
epilog="""
|
|
1866
|
+
Examples:
|
|
1867
|
+
# Register a legacy app
|
|
1868
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
1869
|
+
--register --project-id proj-123 --name "my-legacy-app" \\
|
|
1870
|
+
--source-path /opt/legacy/my-app
|
|
1871
|
+
|
|
1872
|
+
# Run full analysis
|
|
1873
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
1874
|
+
--analyze --project-id proj-123 --app-id lapp-abc123def456
|
|
1875
|
+
|
|
1876
|
+
# Analyze with source path override and JSON output
|
|
1877
|
+
python tools/modernization/legacy_analyzer.py \\
|
|
1878
|
+
--analyze --project-id proj-123 --app-id lapp-abc123def456 \\
|
|
1879
|
+
--source-path /opt/legacy/my-app --json
|
|
1880
|
+
|
|
1881
|
+
Classification: CUI // SP-CTI
|
|
1882
|
+
""",
|
|
1883
|
+
)
|
|
1884
|
+
|
|
1885
|
+
action_group = parser.add_mutually_exclusive_group(required=True)
|
|
1886
|
+
action_group.add_argument(
|
|
1887
|
+
"--register", action="store_true",
|
|
1888
|
+
help="Register a new legacy application for analysis",
|
|
1889
|
+
)
|
|
1890
|
+
action_group.add_argument(
|
|
1891
|
+
"--analyze", action="store_true",
|
|
1892
|
+
help="Run full static analysis on a registered application",
|
|
1893
|
+
)
|
|
1894
|
+
|
|
1895
|
+
parser.add_argument("--project-id", required=True, help="ICDEV project ID")
|
|
1896
|
+
parser.add_argument("--name", help="Application name (required for --register)")
|
|
1897
|
+
parser.add_argument("--app-id", help="Legacy application ID (required for --analyze)")
|
|
1898
|
+
parser.add_argument("--source-path", help="Path to source code root")
|
|
1899
|
+
parser.add_argument("--description", help="Application description (for --register)")
|
|
1900
|
+
parser.add_argument("--json", action="store_true", dest="json_output",
|
|
1901
|
+
help="Output results as JSON")
|
|
1902
|
+
|
|
1903
|
+
args = parser.parse_args()
|
|
1904
|
+
|
|
1905
|
+
try:
|
|
1906
|
+
if args.register:
|
|
1907
|
+
if not args.name:
|
|
1908
|
+
parser.error("--name is required for --register")
|
|
1909
|
+
if not args.source_path:
|
|
1910
|
+
parser.error("--source-path is required for --register")
|
|
1911
|
+
|
|
1912
|
+
result = register_application(
|
|
1913
|
+
project_id=args.project_id,
|
|
1914
|
+
name=args.name,
|
|
1915
|
+
source_path=args.source_path,
|
|
1916
|
+
description=args.description,
|
|
1917
|
+
)
|
|
1918
|
+
|
|
1919
|
+
if args.json_output:
|
|
1920
|
+
print(json.dumps(result, indent=2))
|
|
1921
|
+
|
|
1922
|
+
elif args.analyze:
|
|
1923
|
+
if not args.app_id:
|
|
1924
|
+
parser.error("--app-id is required for --analyze")
|
|
1925
|
+
|
|
1926
|
+
result = analyze_full(
|
|
1927
|
+
project_id=args.project_id,
|
|
1928
|
+
app_id=args.app_id,
|
|
1929
|
+
source_path_override=args.source_path,
|
|
1930
|
+
)
|
|
1931
|
+
|
|
1932
|
+
if args.json_output:
|
|
1933
|
+
print(json.dumps(result, indent=2))
|
|
1934
|
+
|
|
1935
|
+
except FileNotFoundError as exc:
|
|
1936
|
+
print(f"[ERROR] {exc}")
|
|
1937
|
+
raise SystemExit(1)
|
|
1938
|
+
except ValueError as exc:
|
|
1939
|
+
print(f"[ERROR] {exc}")
|
|
1940
|
+
raise SystemExit(1)
|
|
1941
|
+
except sqlite3.Error as exc:
|
|
1942
|
+
print(f"[ERROR] Database error: {exc}")
|
|
1943
|
+
raise SystemExit(1)
|
|
1944
|
+
|
|
1945
|
+
|
|
1946
|
+
if __name__ == "__main__":
|
|
1947
|
+
main()
|
|
1948
|
+
# [TEMPLATE: CUI // SP-CTI]
|