@complior/engine 0.9.0
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.
- package/.well-known/ai-compliance.json +16 -0
- package/COMPLIANCE.md +64 -0
- package/data/data-integrity.test.ts +75 -0
- package/data/eval/eval-mappings.json +33 -0
- package/data/llm/model-pricing.json +15 -0
- package/data/llm/model-routing.json +36 -0
- package/data/onboarding/risk-profile.json +17 -0
- package/data/regulations/eu-ai-act/README.md +245 -0
- package/data/regulations/eu-ai-act/applicability-tree.json +160 -0
- package/data/regulations/eu-ai-act/cross-mapping.json +175 -0
- package/data/regulations/eu-ai-act/localization.json +186 -0
- package/data/regulations/eu-ai-act/obligations.json +3981 -0
- package/data/regulations/eu-ai-act/regulation-meta.json +482 -0
- package/data/regulations/eu-ai-act/scoring.json +342 -0
- package/data/regulations/eu-ai-act/technical-requirements.json +2590 -0
- package/data/regulations/eu-ai-act/timeline.json +160 -0
- package/data/regulations/jurisdictions/at.json +15 -0
- package/data/regulations/jurisdictions/be.json +15 -0
- package/data/regulations/jurisdictions/bg.json +15 -0
- package/data/regulations/jurisdictions/cy.json +15 -0
- package/data/regulations/jurisdictions/cz.json +15 -0
- package/data/regulations/jurisdictions/de.json +15 -0
- package/data/regulations/jurisdictions/dk.json +15 -0
- package/data/regulations/jurisdictions/ee.json +15 -0
- package/data/regulations/jurisdictions/es.json +15 -0
- package/data/regulations/jurisdictions/fi.json +15 -0
- package/data/regulations/jurisdictions/fr.json +15 -0
- package/data/regulations/jurisdictions/gr.json +15 -0
- package/data/regulations/jurisdictions/hr.json +15 -0
- package/data/regulations/jurisdictions/hu.json +15 -0
- package/data/regulations/jurisdictions/ie.json +15 -0
- package/data/regulations/jurisdictions/is.json +15 -0
- package/data/regulations/jurisdictions/it.json +15 -0
- package/data/regulations/jurisdictions/li.json +15 -0
- package/data/regulations/jurisdictions/lt.json +15 -0
- package/data/regulations/jurisdictions/lu.json +15 -0
- package/data/regulations/jurisdictions/lv.json +15 -0
- package/data/regulations/jurisdictions/mt.json +15 -0
- package/data/regulations/jurisdictions/nl.json +15 -0
- package/data/regulations/jurisdictions/no.json +15 -0
- package/data/regulations/jurisdictions/pl.json +15 -0
- package/data/regulations/jurisdictions/pt.json +15 -0
- package/data/regulations/jurisdictions/ro.json +15 -0
- package/data/regulations/jurisdictions/se.json +15 -0
- package/data/regulations/jurisdictions/si.json +15 -0
- package/data/regulations/jurisdictions/sk.json +15 -0
- package/data/scanner/check-id-categories.json +81 -0
- package/data/scanner/confidence-params.json +16 -0
- package/data/scanner/limits.json +4 -0
- package/data/schemas/http-contract-sample.json +79 -0
- package/data/schemas/http-contract.json +144 -0
- package/data/semgrep-rules/bare-call.yaml +37 -0
- package/data/semgrep-rules/injection.yaml +73 -0
- package/data/semgrep-rules/missing-error-handling.yaml +58 -0
- package/data/semgrep-rules/unsafe-deser.yaml +65 -0
- package/data/templates/eu-ai-act/ai-literacy.md +184 -0
- package/data/templates/eu-ai-act/art5-screening.md +131 -0
- package/data/templates/eu-ai-act/data-governance.md +145 -0
- package/data/templates/eu-ai-act/declaration-of-conformity.md +161 -0
- package/data/templates/eu-ai-act/fria.md +127 -0
- package/data/templates/eu-ai-act/gpai-systemic-risk.md +150 -0
- package/data/templates/eu-ai-act/gpai-transparency.md +166 -0
- package/data/templates/eu-ai-act/incident-report.md +188 -0
- package/data/templates/eu-ai-act/instructions-for-use.md +202 -0
- package/data/templates/eu-ai-act/monitoring-policy.md +110 -0
- package/data/templates/eu-ai-act/qms.md +180 -0
- package/data/templates/eu-ai-act/risk-management-system.md +123 -0
- package/data/templates/eu-ai-act/technical-documentation.md +287 -0
- package/data/templates/eu-ai-act/worker-notification.md +143 -0
- package/data/templates/policies/biometrics-ai-policy.md +214 -0
- package/data/templates/policies/critical-infra-ai-policy.md +228 -0
- package/data/templates/policies/education-ai-policy.md +184 -0
- package/data/templates/policies/finance-ai-policy.md +191 -0
- package/data/templates/policies/healthcare-ai-policy.md +197 -0
- package/data/templates/policies/hr-ai-policy.md +178 -0
- package/data/templates/policies/legal-ai-policy.md +189 -0
- package/data/templates/policies/migration-ai-policy.md +239 -0
- package/engine.log +7 -0
- package/package.json +74 -0
- package/src/composition-root.ts +791 -0
- package/src/data/eval/conformity-tests.test.ts +122 -0
- package/src/data/eval/ct-1-transparency.ts +106 -0
- package/src/data/eval/ct-10-gpai.ts +25 -0
- package/src/data/eval/ct-11-industry.ts +42 -0
- package/src/data/eval/ct-2-oversight.ts +41 -0
- package/src/data/eval/ct-3-explanation.ts +14 -0
- package/src/data/eval/ct-4-bias.ts +83 -0
- package/src/data/eval/ct-5-accuracy.ts +41 -0
- package/src/data/eval/ct-6-robustness.ts +81 -0
- package/src/data/eval/ct-7-prohibited.ts +52 -0
- package/src/data/eval/ct-8-logging.ts +68 -0
- package/src/data/eval/ct-9-risk-awareness.ts +33 -0
- package/src/data/eval/deterministic-evaluator.ts +120 -0
- package/src/data/eval/index.ts +55 -0
- package/src/data/eval/judge-prompts.ts +146 -0
- package/src/data/eval/llm-judged-tests.ts +279 -0
- package/src/data/eval/llm-tests.test.ts +83 -0
- package/src/data/eval/remediation/ct-1-transparency.ts +91 -0
- package/src/data/eval/remediation/ct-10-gpai.ts +94 -0
- package/src/data/eval/remediation/ct-11-industry.ts +94 -0
- package/src/data/eval/remediation/ct-2-oversight.ts +71 -0
- package/src/data/eval/remediation/ct-3-explanation.ts +70 -0
- package/src/data/eval/remediation/ct-4-bias.ts +70 -0
- package/src/data/eval/remediation/ct-5-accuracy.ts +70 -0
- package/src/data/eval/remediation/ct-6-robustness.ts +70 -0
- package/src/data/eval/remediation/ct-7-prohibited.ts +94 -0
- package/src/data/eval/remediation/ct-8-logging.ts +94 -0
- package/src/data/eval/remediation/ct-9-risk-awareness.ts +94 -0
- package/src/data/eval/remediation/index.ts +89 -0
- package/src/data/eval/remediation/owasp-art5.ts +15 -0
- package/src/data/eval/remediation/owasp-llm01.ts +72 -0
- package/src/data/eval/remediation/owasp-llm02.ts +72 -0
- package/src/data/eval/remediation/owasp-llm03.ts +15 -0
- package/src/data/eval/remediation/owasp-llm04.ts +15 -0
- package/src/data/eval/remediation/owasp-llm05.ts +15 -0
- package/src/data/eval/remediation/owasp-llm06.ts +15 -0
- package/src/data/eval/remediation/owasp-llm07.ts +15 -0
- package/src/data/eval/remediation/owasp-llm08.ts +15 -0
- package/src/data/eval/remediation/owasp-llm09.ts +15 -0
- package/src/data/eval/remediation/owasp-llm10.ts +15 -0
- package/src/data/eval/remediation/remediation.test.ts +229 -0
- package/src/data/eval/remediation/test-mapping.ts +290 -0
- package/src/data/eval/security-rubrics.ts +381 -0
- package/src/data/finding-explanations.json +453 -0
- package/src/data/industry-patterns.ts +161 -0
- package/src/data/registry-cards.ts +368 -0
- package/src/data/regulation/index.ts +5 -0
- package/src/data/regulation/jurisdiction-data.test.ts +73 -0
- package/src/data/regulation/jurisdiction-data.ts +65 -0
- package/src/data/regulation/regulation-data.ts +19 -0
- package/src/data/regulation/regulation-loader.test.ts +107 -0
- package/src/data/regulation/regulation-loader.ts +56 -0
- package/src/data/scanner-constants.ts +46 -0
- package/src/data/schemas/schemas-core.ts +140 -0
- package/src/data/schemas/schemas-supplementary.ts +211 -0
- package/src/data/schemas/schemas.ts +28 -0
- package/src/data/security/attack-probes.test.ts +62 -0
- package/src/data/security/attack-probes.ts +496 -0
- package/src/data/security/eu-ai-act-security.ts +40 -0
- package/src/data/security/index.ts +19 -0
- package/src/data/security/mitre-atlas.test.ts +43 -0
- package/src/data/security/mitre-atlas.ts +93 -0
- package/src/data/security/nist-ai-rmf.ts +43 -0
- package/src/data/security/owasp-llm-top10.test.ts +60 -0
- package/src/data/security/owasp-llm-top10.ts +138 -0
- package/src/data/template-registry.ts +53 -0
- package/src/data/tool-versions.json +22 -0
- package/src/domain/audit/audit-package.test.ts +152 -0
- package/src/domain/audit/audit-package.ts +166 -0
- package/src/domain/audit/audit-trail.test.ts +121 -0
- package/src/domain/audit/audit-trail.ts +174 -0
- package/src/domain/audit/index.ts +8 -0
- package/src/domain/audit/permissions-matrix.test.ts +136 -0
- package/src/domain/audit/permissions-matrix.ts +121 -0
- package/src/domain/certification/adversarial/bias-tests.ts +95 -0
- package/src/domain/certification/adversarial/evaluators.ts +304 -0
- package/src/domain/certification/adversarial/index.ts +11 -0
- package/src/domain/certification/adversarial/prompt-injection.ts +103 -0
- package/src/domain/certification/adversarial/safety-boundary.ts +132 -0
- package/src/domain/certification/aiuc1-readiness.test.ts +236 -0
- package/src/domain/certification/aiuc1-readiness.ts +298 -0
- package/src/domain/certification/aiuc1-requirements.ts +235 -0
- package/src/domain/certification/index.ts +10 -0
- package/src/domain/certification/redteam-runner.test.ts +97 -0
- package/src/domain/certification/redteam-runner.ts +205 -0
- package/src/domain/certification/test-runner.test.ts +232 -0
- package/src/domain/certification/test-runner.ts +289 -0
- package/src/domain/cost/cost-estimator.test.ts +187 -0
- package/src/domain/cost/cost-estimator.ts +133 -0
- package/src/domain/disclaimer.test.ts +52 -0
- package/src/domain/disclaimer.ts +39 -0
- package/src/domain/documents/ai-enricher.test.ts +120 -0
- package/src/domain/documents/ai-enricher.ts +159 -0
- package/src/domain/documents/document-generator.test.ts +318 -0
- package/src/domain/documents/document-generator.ts +239 -0
- package/src/domain/documents/index.ts +9 -0
- package/src/domain/documents/passport-helpers.ts +25 -0
- package/src/domain/documents/policy-generator.test.ts +252 -0
- package/src/domain/documents/policy-generator.ts +94 -0
- package/src/domain/documents/worker-notification-generator.test.ts +162 -0
- package/src/domain/documents/worker-notification-generator.ts +141 -0
- package/src/domain/eval/adapters/adapter-port.ts +94 -0
- package/src/domain/eval/adapters/adapters.test.ts +303 -0
- package/src/domain/eval/adapters/anthropic-adapter.ts +57 -0
- package/src/domain/eval/adapters/auto-detect.ts +104 -0
- package/src/domain/eval/adapters/create-chat-adapter.ts +106 -0
- package/src/domain/eval/adapters/custom-adapter.ts +74 -0
- package/src/domain/eval/adapters/http-adapter.ts +66 -0
- package/src/domain/eval/adapters/index.ts +7 -0
- package/src/domain/eval/adapters/ollama-adapter.ts +48 -0
- package/src/domain/eval/adapters/openai-adapter.ts +58 -0
- package/src/domain/eval/adapters/with-timeout.ts +25 -0
- package/src/domain/eval/conformity-score.test.ts +161 -0
- package/src/domain/eval/conformity-score.ts +135 -0
- package/src/domain/eval/eval-constants.ts +55 -0
- package/src/domain/eval/eval-evidence.test.ts +85 -0
- package/src/domain/eval/eval-evidence.ts +103 -0
- package/src/domain/eval/eval-fix-generator.test.ts +421 -0
- package/src/domain/eval/eval-fix-generator.ts +205 -0
- package/src/domain/eval/eval-passport.test.ts +82 -0
- package/src/domain/eval/eval-passport.ts +89 -0
- package/src/domain/eval/eval-remediation-report.test.ts +682 -0
- package/src/domain/eval/eval-remediation-report.ts +170 -0
- package/src/domain/eval/eval-report.ts +108 -0
- package/src/domain/eval/eval-runner.test.ts +609 -0
- package/src/domain/eval/eval-runner.ts +593 -0
- package/src/domain/eval/eval-to-findings.test.ts +293 -0
- package/src/domain/eval/eval-to-findings.ts +83 -0
- package/src/domain/eval/index.ts +31 -0
- package/src/domain/eval/llm-judge.test.ts +139 -0
- package/src/domain/eval/llm-judge.ts +168 -0
- package/src/domain/eval/remediation-types.ts +90 -0
- package/src/domain/eval/security-integration.test.ts +196 -0
- package/src/domain/eval/security-integration.ts +136 -0
- package/src/domain/eval/types.test.ts +173 -0
- package/src/domain/eval/types.ts +244 -0
- package/src/domain/eval/verdict-utils.ts +45 -0
- package/src/domain/fixer/create-fixer.ts +101 -0
- package/src/domain/fixer/diff.ts +70 -0
- package/src/domain/fixer/fix-history.ts +23 -0
- package/src/domain/fixer/fixer.test.ts +306 -0
- package/src/domain/fixer/index.ts +9 -0
- package/src/domain/fixer/strategies/bandit-fix.ts +61 -0
- package/src/domain/fixer/strategies/bias-testing.ts +49 -0
- package/src/domain/fixer/strategies/ci-compliance.ts +57 -0
- package/src/domain/fixer/strategies/content-marking.ts +45 -0
- package/src/domain/fixer/strategies/cve-upgrade.ts +66 -0
- package/src/domain/fixer/strategies/data-governance.ts +65 -0
- package/src/domain/fixer/strategies/disclosure.ts +69 -0
- package/src/domain/fixer/strategies/doc-code-sync.ts +53 -0
- package/src/domain/fixer/strategies/documentation.ts +59 -0
- package/src/domain/fixer/strategies/error-handler.ts +63 -0
- package/src/domain/fixer/strategies/hitl-gate.ts +67 -0
- package/src/domain/fixer/strategies/index.ts +61 -0
- package/src/domain/fixer/strategies/kill-switch-test.ts +85 -0
- package/src/domain/fixer/strategies/kill-switch.ts +53 -0
- package/src/domain/fixer/strategies/license-fix.ts +57 -0
- package/src/domain/fixer/strategies/log-retention.ts +40 -0
- package/src/domain/fixer/strategies/logging.ts +59 -0
- package/src/domain/fixer/strategies/metadata.ts +45 -0
- package/src/domain/fixer/strategies/permission-guard.ts +84 -0
- package/src/domain/fixer/strategies/record-keeping.ts +69 -0
- package/src/domain/fixer/strategies/secret-rotation.ts +52 -0
- package/src/domain/fixer/strategies.test.ts +341 -0
- package/src/domain/fixer/template-engine.test.ts +64 -0
- package/src/domain/fixer/template-engine.ts +38 -0
- package/src/domain/fixer/types.ts +88 -0
- package/src/domain/frameworks/aiuc1-framework.test.ts +159 -0
- package/src/domain/frameworks/aiuc1-framework.ts +126 -0
- package/src/domain/frameworks/collect-foundation-metrics.test.ts +96 -0
- package/src/domain/frameworks/collect-foundation-metrics.ts +34 -0
- package/src/domain/frameworks/eu-ai-act-framework.test.ts +117 -0
- package/src/domain/frameworks/eu-ai-act-framework.ts +100 -0
- package/src/domain/frameworks/framework-registry.test.ts +91 -0
- package/src/domain/frameworks/framework-registry.ts +38 -0
- package/src/domain/frameworks/index.ts +8 -0
- package/src/domain/frameworks/mitre-atlas-framework.test.ts +53 -0
- package/src/domain/frameworks/mitre-atlas-framework.ts +53 -0
- package/src/domain/frameworks/owasp-llm-framework.test.ts +77 -0
- package/src/domain/frameworks/owasp-llm-framework.ts +54 -0
- package/src/domain/frameworks/score-plugin-framework.ts +117 -0
- package/src/domain/fria/fria-generator.test.ts +273 -0
- package/src/domain/fria/fria-generator.ts +366 -0
- package/src/domain/import/promptfoo-importer.test.ts +103 -0
- package/src/domain/import/promptfoo-importer.ts +151 -0
- package/src/domain/onboarding/guided-onboarding.test.ts +144 -0
- package/src/domain/onboarding/guided-onboarding.ts +135 -0
- package/src/domain/passport/builder/domain-mapper.ts +9 -0
- package/src/domain/passport/builder/manifest-builder.test.ts +546 -0
- package/src/domain/passport/builder/manifest-builder.ts +535 -0
- package/src/domain/passport/builder/manifest-diff.test.ts +105 -0
- package/src/domain/passport/builder/manifest-diff.ts +89 -0
- package/src/domain/passport/builder/manifest-files.ts +17 -0
- package/src/domain/passport/crypto-signer.test.ts +93 -0
- package/src/domain/passport/crypto-signer.ts +157 -0
- package/src/domain/passport/discovery/agent-discovery.test.ts +296 -0
- package/src/domain/passport/discovery/agent-discovery.ts +325 -0
- package/src/domain/passport/discovery/autonomy-analyzer.test.ts +141 -0
- package/src/domain/passport/discovery/autonomy-analyzer.ts +113 -0
- package/src/domain/passport/discovery/permission-scanner.test.ts +191 -0
- package/src/domain/passport/discovery/permission-scanner.ts +414 -0
- package/src/domain/passport/export/a2a-mapper.ts +75 -0
- package/src/domain/passport/export/aiuc1-mapper.ts +126 -0
- package/src/domain/passport/export/export.test.ts +207 -0
- package/src/domain/passport/export/index.ts +41 -0
- package/src/domain/passport/export/nist-mapper.ts +227 -0
- package/src/domain/passport/import/a2a-importer.test.ts +133 -0
- package/src/domain/passport/import/a2a-importer.ts +156 -0
- package/src/domain/passport/import/index.ts +2 -0
- package/src/domain/passport/index.ts +32 -0
- package/src/domain/passport/obligation-field-map.test.ts +113 -0
- package/src/domain/passport/obligation-field-map.ts +117 -0
- package/src/domain/passport/passport-validator.test.ts +156 -0
- package/src/domain/passport/passport-validator.ts +126 -0
- package/src/domain/passport/scan-to-compliance.test.ts +336 -0
- package/src/domain/passport/scan-to-compliance.ts +166 -0
- package/src/domain/passport/test-generator.test.ts +93 -0
- package/src/domain/passport/test-generator.ts +136 -0
- package/src/domain/proxy/index.ts +11 -0
- package/src/domain/proxy/json-rpc.test.ts +72 -0
- package/src/domain/proxy/json-rpc.ts +53 -0
- package/src/domain/proxy/policy-engine.test.ts +259 -0
- package/src/domain/proxy/policy-engine.ts +137 -0
- package/src/domain/proxy/proxy-bridge.ts +125 -0
- package/src/domain/proxy/proxy-interceptor.test.ts +184 -0
- package/src/domain/proxy/proxy-interceptor.ts +120 -0
- package/src/domain/proxy/proxy-types.ts +35 -0
- package/src/domain/registry/compute-agent-score.test.ts +279 -0
- package/src/domain/registry/compute-agent-score.ts +162 -0
- package/src/domain/reporter/audit-report.test.ts +87 -0
- package/src/domain/reporter/audit-report.ts +116 -0
- package/src/domain/reporter/badge-generator.test.ts +54 -0
- package/src/domain/reporter/badge-generator.ts +40 -0
- package/src/domain/reporter/compliance-md.ts +45 -0
- package/src/domain/reporter/index.ts +7 -0
- package/src/domain/reporter/pdf-renderer.ts +282 -0
- package/src/domain/reporter/share.test.ts +92 -0
- package/src/domain/reporter/share.ts +80 -0
- package/src/domain/scanner/ast/swc-analyzer.test.ts +49 -0
- package/src/domain/scanner/ast/swc-analyzer.ts +124 -0
- package/src/domain/scanner/attestations.ts +97 -0
- package/src/domain/scanner/checks/ai-disclosure.test.ts +90 -0
- package/src/domain/scanner/checks/ai-disclosure.ts +54 -0
- package/src/domain/scanner/checks/ai-literacy.ts +163 -0
- package/src/domain/scanner/checks/behavioral-constraints.test.ts +167 -0
- package/src/domain/scanner/checks/behavioral-constraints.ts +86 -0
- package/src/domain/scanner/checks/compliance-metadata.ts +63 -0
- package/src/domain/scanner/checks/content-marking.ts +74 -0
- package/src/domain/scanner/checks/dep-deep-scan.test.ts +318 -0
- package/src/domain/scanner/checks/dep-deep-scan.ts +137 -0
- package/src/domain/scanner/checks/documentation.test.ts +88 -0
- package/src/domain/scanner/checks/documentation.ts +79 -0
- package/src/domain/scanner/checks/git-history.test.ts +120 -0
- package/src/domain/scanner/checks/git-history.ts +163 -0
- package/src/domain/scanner/checks/gpai-systemic-risk.test.ts +84 -0
- package/src/domain/scanner/checks/gpai-systemic-risk.ts +98 -0
- package/src/domain/scanner/checks/gpai-transparency.ts +94 -0
- package/src/domain/scanner/checks/index.ts +28 -0
- package/src/domain/scanner/checks/industry/index.ts +40 -0
- package/src/domain/scanner/checks/industry/industry.test.ts +287 -0
- package/src/domain/scanner/checks/interaction-logging.test.ts +113 -0
- package/src/domain/scanner/checks/interaction-logging.ts +142 -0
- package/src/domain/scanner/checks/nhi-scanner.test.ts +158 -0
- package/src/domain/scanner/checks/nhi-scanner.ts +78 -0
- package/src/domain/scanner/checks/passport-completeness.test.ts +127 -0
- package/src/domain/scanner/checks/passport-completeness.ts +82 -0
- package/src/domain/scanner/checks/passport-presence.test.ts +56 -0
- package/src/domain/scanner/checks/passport-presence.ts +78 -0
- package/src/domain/scanner/checks/pattern-check-factory.ts +70 -0
- package/src/domain/scanner/checks/permission-scanner.test.ts +279 -0
- package/src/domain/scanner/checks/permission-scanner.ts +90 -0
- package/src/domain/scanner/checks/presence-check-factory.test.ts +124 -0
- package/src/domain/scanner/checks/presence-check-factory.ts +275 -0
- package/src/domain/scanner/compliance-diff.test.ts +165 -0
- package/src/domain/scanner/compliance-diff.ts +138 -0
- package/src/domain/scanner/confidence.test.ts +235 -0
- package/src/domain/scanner/confidence.ts +156 -0
- package/src/domain/scanner/constants.ts +13 -0
- package/src/domain/scanner/create-scanner.ts +573 -0
- package/src/domain/scanner/cross-layer.test.ts +372 -0
- package/src/domain/scanner/cross-layer.ts +232 -0
- package/src/domain/scanner/data/ai-packages.ts +82 -0
- package/src/domain/scanner/debt-calculator.test.ts +89 -0
- package/src/domain/scanner/debt-calculator.ts +111 -0
- package/src/domain/scanner/drift.test.ts +191 -0
- package/src/domain/scanner/drift.ts +73 -0
- package/src/domain/scanner/evidence-store.test.ts +207 -0
- package/src/domain/scanner/evidence-store.ts +195 -0
- package/src/domain/scanner/evidence.test.ts +104 -0
- package/src/domain/scanner/evidence.ts +71 -0
- package/src/domain/scanner/external/bandit-runner.test.ts +45 -0
- package/src/domain/scanner/external/bandit-runner.ts +90 -0
- package/src/domain/scanner/external/checks.ts +321 -0
- package/src/domain/scanner/external/dedup.test.ts +79 -0
- package/src/domain/scanner/external/dedup.ts +94 -0
- package/src/domain/scanner/external/detect-secrets-runner.test.ts +58 -0
- package/src/domain/scanner/external/detect-secrets-runner.ts +81 -0
- package/src/domain/scanner/external/external-scanner.test.ts +221 -0
- package/src/domain/scanner/external/external-scanner.ts +36 -0
- package/src/domain/scanner/external/finding-mapper.test.ts +95 -0
- package/src/domain/scanner/external/finding-mapper.ts +138 -0
- package/src/domain/scanner/external/index.ts +15 -0
- package/src/domain/scanner/external/mappings.ts +93 -0
- package/src/domain/scanner/external/modelscan-runner.test.ts +35 -0
- package/src/domain/scanner/external/modelscan-runner.ts +101 -0
- package/src/domain/scanner/external/path-utils.ts +8 -0
- package/src/domain/scanner/external/runner-port.ts +45 -0
- package/src/domain/scanner/external/semgrep-runner.test.ts +52 -0
- package/src/domain/scanner/external/semgrep-runner.ts +94 -0
- package/src/domain/scanner/external/types.ts +32 -0
- package/src/domain/scanner/finding-attribution.test.ts +444 -0
- package/src/domain/scanner/finding-attribution.ts +195 -0
- package/src/domain/scanner/finding-explainer.test.ts +157 -0
- package/src/domain/scanner/finding-explainer.ts +73 -0
- package/src/domain/scanner/fix-diff-builder.test.ts +272 -0
- package/src/domain/scanner/fix-diff-builder.ts +477 -0
- package/src/domain/scanner/import-graph.test.ts +162 -0
- package/src/domain/scanner/import-graph.ts +198 -0
- package/src/domain/scanner/languages/adapter.test.ts +105 -0
- package/src/domain/scanner/languages/adapter.ts +239 -0
- package/src/domain/scanner/layers/index.ts +24 -0
- package/src/domain/scanner/layers/layer1-files.ts +54 -0
- package/src/domain/scanner/layers/layer2-docs.test.ts +1207 -0
- package/src/domain/scanner/layers/layer2-docs.ts +297 -0
- package/src/domain/scanner/layers/layer2-parsing.ts +217 -0
- package/src/domain/scanner/layers/layer3-config.test.ts +187 -0
- package/src/domain/scanner/layers/layer3-config.ts +279 -0
- package/src/domain/scanner/layers/layer3-parsers.ts +73 -0
- package/src/domain/scanner/layers/layer4-patterns.test.ts +397 -0
- package/src/domain/scanner/layers/layer4-patterns.ts +216 -0
- package/src/domain/scanner/layers/layer5-docs.test.ts +99 -0
- package/src/domain/scanner/layers/layer5-docs.ts +250 -0
- package/src/domain/scanner/layers/layer5-llm.test.ts +146 -0
- package/src/domain/scanner/layers/layer5-llm.ts +262 -0
- package/src/domain/scanner/layers/layer5-targeted.test.ts +93 -0
- package/src/domain/scanner/layers/layer5-targeted.ts +233 -0
- package/src/domain/scanner/layers/lockfile-parsers.test.ts +320 -0
- package/src/domain/scanner/layers/lockfile-parsers.ts +184 -0
- package/src/domain/scanner/regulation-version.test.ts +54 -0
- package/src/domain/scanner/regulation-version.ts +23 -0
- package/src/domain/scanner/role-filter.test.ts +116 -0
- package/src/domain/scanner/role-filter.ts +51 -0
- package/src/domain/scanner/rules/banned-packages-data.ts +553 -0
- package/src/domain/scanner/rules/banned-packages-sdk.ts +65 -0
- package/src/domain/scanner/rules/banned-packages.test.ts +249 -0
- package/src/domain/scanner/rules/banned-packages.ts +55 -0
- package/src/domain/scanner/rules/comment-filter.test.ts +115 -0
- package/src/domain/scanner/rules/comment-filter.ts +297 -0
- package/src/domain/scanner/rules/index.ts +9 -0
- package/src/domain/scanner/rules/nhi-patterns.test.ts +128 -0
- package/src/domain/scanner/rules/nhi-patterns.ts +60 -0
- package/src/domain/scanner/rules/pattern-rules.ts +1152 -0
- package/src/domain/scanner/sbom.test.ts +136 -0
- package/src/domain/scanner/sbom.ts +103 -0
- package/src/domain/scanner/scan-cache.test.ts +136 -0
- package/src/domain/scanner/scan-cache.ts +115 -0
- package/src/domain/scanner/scanner.test.ts +125 -0
- package/src/domain/scanner/score-calculator.test.ts +363 -0
- package/src/domain/scanner/score-calculator.ts +189 -0
- package/src/domain/scanner/security-score.test.ts +107 -0
- package/src/domain/scanner/security-score.ts +116 -0
- package/src/domain/scanner/source-filter.ts +24 -0
- package/src/domain/scanner/validators.ts +223 -0
- package/src/domain/shared/compliance-constants.ts +48 -0
- package/src/domain/shared/disclosure-patterns.ts +16 -0
- package/src/domain/shared/index.ts +6 -0
- package/src/domain/shared/parse-dependencies.ts +21 -0
- package/src/domain/supply-chain/dependency-analyzer.ts +138 -0
- package/src/domain/supply-chain/index.ts +3 -0
- package/src/domain/supply-chain/supply-chain.test.ts +211 -0
- package/src/domain/supply-chain/types.ts +32 -0
- package/src/domain/whatif/config-fixer.ts +187 -0
- package/src/domain/whatif/index.ts +6 -0
- package/src/domain/whatif/scenario-engine.ts +121 -0
- package/src/domain/whatif/simulate-actions.test.ts +161 -0
- package/src/domain/whatif/simulate-actions.ts +114 -0
- package/src/domain/whatif/whatif.test.ts +135 -0
- package/src/e2e/gaps-e2e.test.ts +259 -0
- package/src/e2e/smoke.test.ts +101 -0
- package/src/hooks/hooks-export.test.ts +81 -0
- package/src/hooks/installer.ts +113 -0
- package/src/http/cors.test.ts +38 -0
- package/src/http/create-router.ts +259 -0
- package/src/http/routes/agent.route.ts +380 -0
- package/src/http/routes/audit.route.ts +66 -0
- package/src/http/routes/badge.route.ts +23 -0
- package/src/http/routes/cert.route.ts +66 -0
- package/src/http/routes/chat.route.ts +228 -0
- package/src/http/routes/cost.route.ts +33 -0
- package/src/http/routes/debt.route.ts +29 -0
- package/src/http/routes/disclaimer.route.ts +64 -0
- package/src/http/routes/eval.route.ts +161 -0
- package/src/http/routes/events.route.test.ts +108 -0
- package/src/http/routes/events.route.ts +71 -0
- package/src/http/routes/external-scan.route.ts +24 -0
- package/src/http/routes/file.route.ts +54 -0
- package/src/http/routes/fix.route.ts +219 -0
- package/src/http/routes/frameworks.route.test.ts +66 -0
- package/src/http/routes/frameworks.route.ts +36 -0
- package/src/http/routes/git.route.ts +27 -0
- package/src/http/routes/guided-onboarding.route.ts +65 -0
- package/src/http/routes/import.route.ts +64 -0
- package/src/http/routes/jurisdiction.route.ts +22 -0
- package/src/http/routes/obligations.route.test.ts +122 -0
- package/src/http/routes/obligations.route.ts +110 -0
- package/src/http/routes/onboarding.route.ts +53 -0
- package/src/http/routes/provider.route.ts +42 -0
- package/src/http/routes/proxy.route.ts +40 -0
- package/src/http/routes/redteam.route.ts +84 -0
- package/src/http/routes/report.route.ts +29 -0
- package/src/http/routes/scan.route.ts +104 -0
- package/src/http/routes/share.route.ts +44 -0
- package/src/http/routes/shell.route.ts +27 -0
- package/src/http/routes/status.route.ts +66 -0
- package/src/http/routes/supply-chain.route.ts +121 -0
- package/src/http/routes/sync.route.ts +328 -0
- package/src/http/routes/tools.route.ts +29 -0
- package/src/http/routes/whatif.route.ts +96 -0
- package/src/http/utils/validation.ts +31 -0
- package/src/index.ts +1 -0
- package/src/infra/bundle-fetcher.ts +77 -0
- package/src/infra/cache-storage.ts +34 -0
- package/src/infra/event-bus.ts +31 -0
- package/src/infra/file-collector.ts +61 -0
- package/src/infra/file-ops-adapter.ts +95 -0
- package/src/infra/file-watcher.test.ts +90 -0
- package/src/infra/file-watcher.ts +106 -0
- package/src/infra/git-adapter.ts +93 -0
- package/src/infra/git-history-adapter.ts +41 -0
- package/src/infra/headless-browser.ts +178 -0
- package/src/infra/llm-adapter.test.ts +83 -0
- package/src/infra/llm-adapter.ts +86 -0
- package/src/infra/logger.ts +27 -0
- package/src/infra/project-config.test.ts +74 -0
- package/src/infra/project-config.ts +35 -0
- package/src/infra/rate-limiter.test.ts +36 -0
- package/src/infra/rate-limiter.ts +34 -0
- package/src/infra/retry.ts +46 -0
- package/src/infra/saas-client.ts +123 -0
- package/src/infra/search-adapter.ts +113 -0
- package/src/infra/shell-adapter.ts +68 -0
- package/src/infra/tool-manager.test.ts +99 -0
- package/src/infra/tool-manager.ts +197 -0
- package/src/llm/agents/agent-modes.test.ts +44 -0
- package/src/llm/agents/modes.ts +68 -0
- package/src/llm/routing/cost-routing.test.ts +37 -0
- package/src/llm/routing/cost-tracker.ts +74 -0
- package/src/llm/routing/model-routing.test.ts +79 -0
- package/src/llm/routing/model-routing.ts +38 -0
- package/src/llm/routing/pricing.ts +19 -0
- package/src/llm/sse-protocol.ts +77 -0
- package/src/llm/tool-definitions.ts +83 -0
- package/src/llm/tool-executors.ts +80 -0
- package/src/llm/tools/types.ts +13 -0
- package/src/mcp/create-mcp-stack.ts +82 -0
- package/src/mcp/handlers.ts +245 -0
- package/src/mcp/index.ts +28 -0
- package/src/mcp/mcp-server.test.ts +80 -0
- package/src/mcp/server.ts +79 -0
- package/src/mcp/tools.ts +48 -0
- package/src/onboarding/auto-detect.ts +164 -0
- package/src/onboarding/onboarding.test.ts +89 -0
- package/src/onboarding/profile.ts +169 -0
- package/src/onboarding/questions.ts +112 -0
- package/src/onboarding/wizard.ts +66 -0
- package/src/output/github-issue.ts +32 -0
- package/src/output/json-output.ts +67 -0
- package/src/ports/browser.port.ts +23 -0
- package/src/ports/events.port.ts +28 -0
- package/src/ports/llm.port.ts +23 -0
- package/src/ports/logger.port.ts +6 -0
- package/src/ports/process.port.ts +6 -0
- package/src/ports/scanner.port.ts +15 -0
- package/src/server.ts +134 -0
- package/src/services/badge-service.ts +67 -0
- package/src/services/chat-service.test.ts +162 -0
- package/src/services/chat-service.ts +152 -0
- package/src/services/cost-service.ts +52 -0
- package/src/services/debt-service.ts +65 -0
- package/src/services/eval-integration.test.ts +132 -0
- package/src/services/eval-service.test.ts +373 -0
- package/src/services/eval-service.ts +463 -0
- package/src/services/external-scan-service.ts +60 -0
- package/src/services/file-service.ts +37 -0
- package/src/services/fix-service.test.ts +470 -0
- package/src/services/fix-service.ts +648 -0
- package/src/services/framework-service.test.ts +159 -0
- package/src/services/framework-service.ts +67 -0
- package/src/services/onboarding-service.ts +165 -0
- package/src/services/passport-audit.ts +244 -0
- package/src/services/passport-documents.ts +258 -0
- package/src/services/passport-service-utils.ts +72 -0
- package/src/services/passport-service.test.ts +251 -0
- package/src/services/passport-service.ts +339 -0
- package/src/services/proxy-service.ts +81 -0
- package/src/services/report-service.ts +72 -0
- package/src/services/scan-service.test.ts +470 -0
- package/src/services/scan-service.ts +335 -0
- package/src/services/share-service.ts +108 -0
- package/src/services/shared/backup.ts +23 -0
- package/src/services/status-service.ts +38 -0
- package/src/services/undo-service.test.ts +190 -0
- package/src/services/undo-service.ts +144 -0
- package/src/test-helpers/factories.ts +116 -0
- package/src/types/common.schemas.ts +147 -0
- package/src/types/common.types.ts +292 -0
- package/src/types/contract.test.ts +217 -0
- package/src/types/errors.ts +52 -0
- package/src/types/framework.types.ts +87 -0
- package/src/types/passport-schemas.ts +241 -0
- package/src/types/passport.types.ts +296 -0
- package/src/version.ts +1 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +9 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import type { Finding } from '../../types/common.types.js';
|
|
3
|
+
import { createFixer } from './create-fixer.js';
|
|
4
|
+
import { generateUnifiedDiff, generateCreateDiff } from './diff.js';
|
|
5
|
+
import type { FixContext } from './types.js';
|
|
6
|
+
|
|
7
|
+
// --- Helpers ---
|
|
8
|
+
|
|
9
|
+
const makeContext = (overrides?: Partial<FixContext>): FixContext => ({
|
|
10
|
+
projectPath: '/test/project',
|
|
11
|
+
framework: 'generic',
|
|
12
|
+
existingFiles: [],
|
|
13
|
+
...overrides,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const makeFinding = (overrides: Partial<Finding> & { checkId: string }): Finding => ({
|
|
17
|
+
type: 'fail',
|
|
18
|
+
message: 'Test finding',
|
|
19
|
+
severity: 'high',
|
|
20
|
+
...overrides,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// --- Diff tests ---
|
|
24
|
+
|
|
25
|
+
describe('generateUnifiedDiff', () => {
|
|
26
|
+
it('generates diff for modified content', () => {
|
|
27
|
+
const diff = generateUnifiedDiff('src/app.ts', 'line1\nline2\n', 'line1\nchanged\n');
|
|
28
|
+
expect(diff).toContain('--- a/src/app.ts');
|
|
29
|
+
expect(diff).toContain('+++ b/src/app.ts');
|
|
30
|
+
expect(diff).toContain('-line2');
|
|
31
|
+
expect(diff).toContain('+changed');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('generateCreateDiff', () => {
|
|
36
|
+
it('generates diff for new file', () => {
|
|
37
|
+
const diff = generateCreateDiff('new.ts', 'const x = 1;\n');
|
|
38
|
+
expect(diff).toContain('--- /dev/null');
|
|
39
|
+
expect(diff).toContain('+++ b/new.ts');
|
|
40
|
+
expect(diff).toContain('+const x = 1;');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// --- Fixer factory tests ---
|
|
45
|
+
|
|
46
|
+
describe('createFixer', () => {
|
|
47
|
+
const fixer = createFixer({
|
|
48
|
+
getFramework: () => 'Next.js',
|
|
49
|
+
getProjectPath: () => '/test/project',
|
|
50
|
+
getExistingFiles: () => [],
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('generateFix returns plan for fixable finding', () => {
|
|
54
|
+
const finding = makeFinding({ checkId: 'ai-disclosure' });
|
|
55
|
+
const plan = fixer.generateFix(finding);
|
|
56
|
+
expect(plan).not.toBeNull();
|
|
57
|
+
expect(plan!.framework).toBe('Next.js');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('generateFix returns null for pass findings', () => {
|
|
61
|
+
const finding: Finding = {
|
|
62
|
+
checkId: 'ai-disclosure',
|
|
63
|
+
type: 'pass',
|
|
64
|
+
message: 'OK',
|
|
65
|
+
severity: 'info',
|
|
66
|
+
};
|
|
67
|
+
const plan = fixer.generateFix(finding);
|
|
68
|
+
expect(plan).toBeNull();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('generateFixes processes multiple findings', () => {
|
|
72
|
+
const findings: Finding[] = [
|
|
73
|
+
makeFinding({ checkId: 'ai-disclosure' }),
|
|
74
|
+
makeFinding({ checkId: 'interaction-logging' }),
|
|
75
|
+
makeFinding({ checkId: 'unknown' }),
|
|
76
|
+
];
|
|
77
|
+
const plans = fixer.generateFixes(findings);
|
|
78
|
+
expect(plans).toHaveLength(2);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('generateFixes deduplicates plans with same output path', () => {
|
|
82
|
+
const findings: Finding[] = [
|
|
83
|
+
makeFinding({ checkId: 'l4-security-risk' }),
|
|
84
|
+
makeFinding({ checkId: 'l4-security-risk' }),
|
|
85
|
+
makeFinding({ checkId: 'l4-ast-missing-error-handling' }),
|
|
86
|
+
];
|
|
87
|
+
const plans = fixer.generateFixes(findings);
|
|
88
|
+
// All three produce src/middleware/ai-error-handler.ts — should deduplicate to 1
|
|
89
|
+
expect(plans).toHaveLength(1);
|
|
90
|
+
expect(plans[0].checkId).toBe('l4-security-risk');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('previewFix returns same as generateFix', () => {
|
|
94
|
+
const finding = makeFinding({ checkId: 'content-marking' });
|
|
95
|
+
const plan = fixer.previewFix(finding);
|
|
96
|
+
expect(plan).not.toBeNull();
|
|
97
|
+
expect(plan!.fixType).toBe('config_fix');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// --- Inline fix from fixDiff ---
|
|
102
|
+
|
|
103
|
+
describe('inline fix from fixDiff', () => {
|
|
104
|
+
const fixer = createFixer({
|
|
105
|
+
getFramework: () => 'generic',
|
|
106
|
+
getProjectPath: () => '/test/project',
|
|
107
|
+
getExistingFiles: () => [],
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('generates splice plan when finding has fixDiff', () => {
|
|
111
|
+
const finding = makeFinding({
|
|
112
|
+
checkId: 'l4-security-risk',
|
|
113
|
+
fixDiff: {
|
|
114
|
+
filePath: 'src/handler.ts',
|
|
115
|
+
startLine: 5,
|
|
116
|
+
before: ['return eval(req.body.code);'],
|
|
117
|
+
after: ['return /* COMPLIOR: eval() disabled */ undefined;'],
|
|
118
|
+
importLine: undefined,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
const plan = fixer.generateFix(finding);
|
|
122
|
+
expect(plan).not.toBeNull();
|
|
123
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
124
|
+
expect(plan!.actions[0].startLine).toBe(5);
|
|
125
|
+
expect(plan!.actions[0].beforeLines).toEqual(['return eval(req.body.code);']);
|
|
126
|
+
expect(plan!.actions[0].afterLines).toEqual(['return /* COMPLIOR: eval() disabled */ undefined;']);
|
|
127
|
+
expect(plan!.fixType).toBe('code_injection');
|
|
128
|
+
expect(plan!.scoreImpact).toBe(6);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it('inline fix takes priority over scaffold strategy', () => {
|
|
132
|
+
const finding = makeFinding({
|
|
133
|
+
checkId: 'l4-nhi-api-key',
|
|
134
|
+
fixDiff: {
|
|
135
|
+
filePath: 'src/config.ts',
|
|
136
|
+
startLine: 10,
|
|
137
|
+
before: ["const API_KEY = 'sk-1234567890abcdef';"],
|
|
138
|
+
after: ["const API_KEY = process.env.API_KEY ?? '';"],
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
const plan = fixer.generateFix(finding);
|
|
142
|
+
expect(plan).not.toBeNull();
|
|
143
|
+
// Should be splice (inline), not create (scaffold)
|
|
144
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
145
|
+
expect(plan!.actions[0].path).toBe('src/config.ts');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('returns null for info findings (no fix needed)', () => {
|
|
149
|
+
const finding = makeFinding({ checkId: 'l4-bare-llm', type: 'info', severity: 'info' });
|
|
150
|
+
const plan = fixer.generateFix(finding);
|
|
151
|
+
expect(plan).toBeNull();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('dedup by path:startLine for splice — different lines produce 2 plans', () => {
|
|
155
|
+
const findings = [
|
|
156
|
+
makeFinding({
|
|
157
|
+
checkId: 'l4-nhi-api-key',
|
|
158
|
+
fixDiff: { filePath: 'src/config.ts', startLine: 5, before: ["const A = 'sk-123';"], after: ["const A = process.env.A ?? '';"] },
|
|
159
|
+
}),
|
|
160
|
+
makeFinding({
|
|
161
|
+
checkId: 'l4-nhi-api-key',
|
|
162
|
+
fixDiff: { filePath: 'src/config.ts', startLine: 20, before: ["const B = 'sk-456';"], after: ["const B = process.env.B ?? '';"] },
|
|
163
|
+
}),
|
|
164
|
+
];
|
|
165
|
+
const plans = fixer.generateFixes(findings);
|
|
166
|
+
expect(plans).toHaveLength(2);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('dedup catches identical splice — same file same line produces 1 plan', () => {
|
|
170
|
+
const findings = [
|
|
171
|
+
makeFinding({
|
|
172
|
+
checkId: 'l4-nhi-api-key',
|
|
173
|
+
fixDiff: { filePath: 'src/config.ts', startLine: 5, before: ["const A = 'sk-123';"], after: ["const A = process.env.A ?? '';"] },
|
|
174
|
+
}),
|
|
175
|
+
makeFinding({
|
|
176
|
+
checkId: 'l4-nhi-api-key',
|
|
177
|
+
fixDiff: { filePath: 'src/config.ts', startLine: 5, before: ["const A = 'sk-123';"], after: ["const A = process.env.A ?? '';"] },
|
|
178
|
+
}),
|
|
179
|
+
];
|
|
180
|
+
const plans = fixer.generateFixes(findings);
|
|
181
|
+
expect(plans).toHaveLength(1);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// --- Inline fix for new fix types ---
|
|
186
|
+
|
|
187
|
+
describe('NHI inline fix', () => {
|
|
188
|
+
const fixer = createFixer({
|
|
189
|
+
getFramework: () => 'generic',
|
|
190
|
+
getProjectPath: () => '/test/project',
|
|
191
|
+
getExistingFiles: () => [],
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('generates splice plan with process.env replacement', () => {
|
|
195
|
+
const finding = makeFinding({
|
|
196
|
+
checkId: 'l4-nhi-openai-key',
|
|
197
|
+
fixDiff: {
|
|
198
|
+
filePath: 'src/config.ts',
|
|
199
|
+
startLine: 3,
|
|
200
|
+
before: ["const API_KEY = 'sk-1234567890abcdef';"],
|
|
201
|
+
after: ["const API_KEY = process.env.API_KEY ?? ''"],
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
const plan = fixer.generateFix(finding);
|
|
205
|
+
expect(plan).not.toBeNull();
|
|
206
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
207
|
+
expect(plan!.description).toContain('externalize secret');
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('generates splice plan with os.environ for Python', () => {
|
|
211
|
+
const finding = makeFinding({
|
|
212
|
+
checkId: 'l4-nhi-generic-secret',
|
|
213
|
+
fixDiff: {
|
|
214
|
+
filePath: 'config.py',
|
|
215
|
+
startLine: 5,
|
|
216
|
+
before: ['API_KEY = "sk-1234"'],
|
|
217
|
+
after: ["API_KEY = os.environ.get('API_KEY', '')"],
|
|
218
|
+
importLine: 'import os',
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
const plan = fixer.generateFix(finding);
|
|
222
|
+
expect(plan).not.toBeNull();
|
|
223
|
+
expect(plan!.actions[0].importLine).toBe('import os');
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
describe('security risk inline fix', () => {
|
|
228
|
+
const fixer = createFixer({
|
|
229
|
+
getFramework: () => 'generic',
|
|
230
|
+
getProjectPath: () => '/test/project',
|
|
231
|
+
getExistingFiles: () => [],
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('generates splice plan for security pattern', () => {
|
|
235
|
+
const finding = makeFinding({
|
|
236
|
+
checkId: 'l4-security-risk',
|
|
237
|
+
fixDiff: {
|
|
238
|
+
filePath: 'src/ml/pipeline.py',
|
|
239
|
+
startLine: 10,
|
|
240
|
+
before: ['model = pickle.load(f)'],
|
|
241
|
+
after: ['model = json.load(f)'],
|
|
242
|
+
importLine: 'import json',
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
const plan = fixer.generateFix(finding);
|
|
246
|
+
expect(plan).not.toBeNull();
|
|
247
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
248
|
+
expect(plan!.description).toContain('security risk');
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
describe('error handling inline fix', () => {
|
|
253
|
+
const fixer = createFixer({
|
|
254
|
+
getFramework: () => 'generic',
|
|
255
|
+
getProjectPath: () => '/test/project',
|
|
256
|
+
getExistingFiles: () => [],
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('generates splice plan with try/catch wrapping', () => {
|
|
260
|
+
const finding = makeFinding({
|
|
261
|
+
checkId: 'l4-ast-missing-error-handling',
|
|
262
|
+
fixDiff: {
|
|
263
|
+
filePath: 'src/chat/agent.ts',
|
|
264
|
+
startLine: 15,
|
|
265
|
+
before: [' const result = await client.messages.create({ model: "claude-3" });'],
|
|
266
|
+
after: [
|
|
267
|
+
' try {',
|
|
268
|
+
' const result = await client.messages.create({ model: "claude-3" });',
|
|
269
|
+
' } catch (err) {',
|
|
270
|
+
" console.error('LLM call failed:', err);",
|
|
271
|
+
' throw err;',
|
|
272
|
+
' }',
|
|
273
|
+
],
|
|
274
|
+
},
|
|
275
|
+
});
|
|
276
|
+
const plan = fixer.generateFix(finding);
|
|
277
|
+
expect(plan).not.toBeNull();
|
|
278
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
279
|
+
expect(plan!.description).toContain('error handling');
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
describe('banned dep inline fix', () => {
|
|
284
|
+
const fixer = createFixer({
|
|
285
|
+
getFramework: () => 'generic',
|
|
286
|
+
getProjectPath: () => '/test/project',
|
|
287
|
+
getExistingFiles: () => [],
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('generates splice plan removing banned dep line', () => {
|
|
291
|
+
const finding = makeFinding({
|
|
292
|
+
checkId: 'l3-banned-emotion-recognition',
|
|
293
|
+
fixDiff: {
|
|
294
|
+
filePath: 'package.json',
|
|
295
|
+
startLine: 8,
|
|
296
|
+
before: [' "emotion-recognition": "^1.0.0",'],
|
|
297
|
+
after: [],
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
const plan = fixer.generateFix(finding);
|
|
301
|
+
expect(plan).not.toBeNull();
|
|
302
|
+
expect(plan!.actions[0].type).toBe('splice');
|
|
303
|
+
expect(plan!.actions[0].afterLines).toEqual([]);
|
|
304
|
+
expect(plan!.description).toContain('banned dependency');
|
|
305
|
+
});
|
|
306
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createFixer } from './create-fixer.js';
|
|
2
|
+
export type { FixerDeps, Fixer } from './create-fixer.js';
|
|
3
|
+
export { generateUnifiedDiff, generateCreateDiff } from './diff.js';
|
|
4
|
+
export { createEmptyHistory, addEntry, markUndone, getLastApplied, getById } from './fix-history.js';
|
|
5
|
+
export { fillTemplate, getTemplateForObligation, getAvailableTemplates } from './template-engine.js';
|
|
6
|
+
export type { TemplateData } from './template-engine.js';
|
|
7
|
+
export type { FixType, FixAction, FixPlan, FixResult, FixContext } from './types.js';
|
|
8
|
+
export type { FixValidation, FixHistoryFile, FixHistoryEntry, FixHistory, FixStrategy, TemplateMapping } from './types.js';
|
|
9
|
+
export { findStrategy } from './strategies/index.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
import { ENGINE_VERSION } from '../../../version.js';
|
|
4
|
+
|
|
5
|
+
// --- Strategy: Bandit Fix (Art. 15.4) ---
|
|
6
|
+
|
|
7
|
+
const BANDIT_FIXES: Record<string, { issue: string; fix: string }> = {
|
|
8
|
+
'B301': { issue: 'Use of pickle (deserialization risk)', fix: 'Replace pickle with json or yaml for data serialization' },
|
|
9
|
+
'B603': { issue: 'subprocess call with shell=True', fix: 'Use subprocess.run() with a list of arguments instead of shell=True' },
|
|
10
|
+
'B608': { issue: 'SQL injection via string formatting', fix: 'Use parameterized queries instead of string concatenation' },
|
|
11
|
+
'B105': { issue: 'Hardcoded password in source code', fix: 'Move password to environment variable or secrets manager' },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const banditFixStrategy: FixStrategy = (finding, context) => {
|
|
15
|
+
if (!finding.checkId.startsWith('ext-bandit-')) return null;
|
|
16
|
+
|
|
17
|
+
const ruleId = finding.checkId.replace('ext-bandit-', '').toUpperCase();
|
|
18
|
+
const known = BANDIT_FIXES[ruleId];
|
|
19
|
+
|
|
20
|
+
const lines = [`# Security Fixes — Bandit Findings\n`];
|
|
21
|
+
lines.push(`Generated by Complior v${ENGINE_VERSION}\n`);
|
|
22
|
+
|
|
23
|
+
if (known) {
|
|
24
|
+
lines.push(`## ${ruleId}: ${known.issue}\n`);
|
|
25
|
+
lines.push(`**Fix:** ${known.fix}\n`);
|
|
26
|
+
} else {
|
|
27
|
+
lines.push(`## ${ruleId}: Security finding\n`);
|
|
28
|
+
lines.push(`**Fix:** Review the flagged code and apply the recommended remediation from Bandit documentation.\n`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (finding.message) {
|
|
32
|
+
lines.push(`### Details\n`);
|
|
33
|
+
lines.push(`${finding.message}\n`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
lines.push(`## Verification\n`);
|
|
37
|
+
lines.push(`- [ ] Fix applied\n- [ ] Re-run \`bandit\` to verify\n- [ ] Peer review completed\n`);
|
|
38
|
+
|
|
39
|
+
const content = lines.join('\n');
|
|
40
|
+
const filePath = 'complior-security-fixes.md';
|
|
41
|
+
|
|
42
|
+
const action: FixAction = {
|
|
43
|
+
type: 'create',
|
|
44
|
+
path: filePath,
|
|
45
|
+
content,
|
|
46
|
+
description: `Create security fix plan for Bandit ${ruleId}`,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-008',
|
|
51
|
+
checkId: finding.checkId,
|
|
52
|
+
article: finding.articleReference ?? 'Art. 15(4)',
|
|
53
|
+
fixType: 'template_generation',
|
|
54
|
+
framework: context.framework,
|
|
55
|
+
actions: [action],
|
|
56
|
+
diff: generateCreateDiff(filePath, content),
|
|
57
|
+
scoreImpact: 4,
|
|
58
|
+
commitMessage: `fix: add Bandit ${ruleId} remediation plan (Art. 15.4) -- via Complior`,
|
|
59
|
+
description: `Create security remediation plan for Bandit finding ${ruleId}`,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
|
|
4
|
+
// --- Strategy: Bias Testing (Art. 10) ---
|
|
5
|
+
|
|
6
|
+
export const biasTestingStrategy: FixStrategy = (finding, context) => {
|
|
7
|
+
if (finding.checkId !== 'l3-missing-bias-testing') return null;
|
|
8
|
+
|
|
9
|
+
const filePath = 'bias-testing.config.json';
|
|
10
|
+
const content = JSON.stringify({
|
|
11
|
+
version: '1.0',
|
|
12
|
+
protectedAttributes: ['gender', 'race', 'age', 'disability', 'religion', 'nationality'],
|
|
13
|
+
fairnessMetrics: {
|
|
14
|
+
equalized_odds: { enabled: true, threshold: 0.1 },
|
|
15
|
+
demographic_parity: { enabled: true, threshold: 0.1 },
|
|
16
|
+
predictive_parity: { enabled: true, threshold: 0.15 },
|
|
17
|
+
},
|
|
18
|
+
testDataset: {
|
|
19
|
+
path: 'tests/bias/',
|
|
20
|
+
format: 'jsonl',
|
|
21
|
+
minSamplesPerGroup: 100,
|
|
22
|
+
},
|
|
23
|
+
reporting: {
|
|
24
|
+
outputDir: 'reports/bias/',
|
|
25
|
+
format: 'json',
|
|
26
|
+
includeConfidenceIntervals: true,
|
|
27
|
+
},
|
|
28
|
+
}, null, 2);
|
|
29
|
+
|
|
30
|
+
const action: FixAction = {
|
|
31
|
+
type: 'create',
|
|
32
|
+
path: filePath,
|
|
33
|
+
content,
|
|
34
|
+
description: 'Create bias testing configuration',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-004',
|
|
39
|
+
checkId: finding.checkId,
|
|
40
|
+
article: finding.articleReference ?? 'Art. 10',
|
|
41
|
+
fixType: 'config_fix',
|
|
42
|
+
framework: context.framework,
|
|
43
|
+
actions: [action],
|
|
44
|
+
diff: generateCreateDiff(filePath, content),
|
|
45
|
+
scoreImpact: 4,
|
|
46
|
+
commitMessage: 'fix: add bias testing configuration (Art. 10) -- via Complior',
|
|
47
|
+
description: 'Add bias testing configuration with fairness metrics and thresholds',
|
|
48
|
+
};
|
|
49
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
|
|
4
|
+
// --- Strategy: CI Compliance (Art. 17) ---
|
|
5
|
+
|
|
6
|
+
export const ciComplianceStrategy: FixStrategy = (finding, context) => {
|
|
7
|
+
if (finding.checkId !== 'l3-ci-compliance') return null;
|
|
8
|
+
|
|
9
|
+
const filePath = '.github/workflows/compliance-check.yml';
|
|
10
|
+
const content = `name: Compliance Check
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
branches: [main, develop]
|
|
15
|
+
pull_request:
|
|
16
|
+
branches: [main]
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
compliance:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- uses: actions/setup-node@v4
|
|
25
|
+
with:
|
|
26
|
+
node-version: '22'
|
|
27
|
+
|
|
28
|
+
- name: Run Complior scan
|
|
29
|
+
run: npx complior scan --ci --threshold 70
|
|
30
|
+
|
|
31
|
+
- name: Upload SARIF
|
|
32
|
+
if: always()
|
|
33
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
34
|
+
with:
|
|
35
|
+
sarif_file: complior-report.sarif
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const action: FixAction = {
|
|
39
|
+
type: 'create',
|
|
40
|
+
path: filePath,
|
|
41
|
+
content,
|
|
42
|
+
description: 'Create GitHub Actions compliance check workflow',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-010',
|
|
47
|
+
checkId: finding.checkId,
|
|
48
|
+
article: finding.articleReference ?? 'Art. 17',
|
|
49
|
+
fixType: 'config_fix',
|
|
50
|
+
framework: context.framework,
|
|
51
|
+
actions: [action],
|
|
52
|
+
diff: generateCreateDiff(filePath, content),
|
|
53
|
+
scoreImpact: 4,
|
|
54
|
+
commitMessage: 'fix: add CI compliance check workflow (Art. 17) -- via Complior',
|
|
55
|
+
description: 'Add GitHub Actions workflow for automated compliance scanning',
|
|
56
|
+
};
|
|
57
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
|
|
4
|
+
export const contentMarkingStrategy: FixStrategy = (finding, context) => {
|
|
5
|
+
if (finding.checkId !== 'content-marking') return null;
|
|
6
|
+
|
|
7
|
+
const configPath = 'complior-content-marking.json';
|
|
8
|
+
const content = JSON.stringify({
|
|
9
|
+
version: '1.0',
|
|
10
|
+
standard: 'C2PA',
|
|
11
|
+
marking: {
|
|
12
|
+
enabled: true,
|
|
13
|
+
method: 'metadata',
|
|
14
|
+
fields: {
|
|
15
|
+
'dc:creator': 'AI-generated',
|
|
16
|
+
'ai:model': '[PASSPORT:model.model_id]',
|
|
17
|
+
'ai:provider': '[PASSPORT:model.provider]',
|
|
18
|
+
'xmp:CreatorTool': 'Complior Content Marking',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
iptc: {
|
|
22
|
+
'Iptc4xmpExt:DigitalSourceType': 'trainedAlgorithmicMedia',
|
|
23
|
+
},
|
|
24
|
+
}, null, 2);
|
|
25
|
+
|
|
26
|
+
const action: FixAction = {
|
|
27
|
+
type: 'create',
|
|
28
|
+
path: configPath,
|
|
29
|
+
content,
|
|
30
|
+
description: 'Create C2PA/IPTC content marking configuration',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-016',
|
|
35
|
+
checkId: finding.checkId,
|
|
36
|
+
article: finding.articleReference ?? 'Art. 50(2)',
|
|
37
|
+
fixType: 'config_fix',
|
|
38
|
+
framework: context.framework,
|
|
39
|
+
actions: [action],
|
|
40
|
+
diff: generateCreateDiff(configPath, content),
|
|
41
|
+
scoreImpact: 5,
|
|
42
|
+
commitMessage: 'fix: add C2PA content marking config (Art. 50.2) -- via Complior',
|
|
43
|
+
description: 'Add C2PA/IPTC content marking configuration for AI-generated content',
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
import { ENGINE_VERSION } from '../../../version.js';
|
|
4
|
+
|
|
5
|
+
// --- Strategy: CVE Upgrade (Art. 15) ---
|
|
6
|
+
|
|
7
|
+
export const cveUpgradeStrategy: FixStrategy = (finding, context) => {
|
|
8
|
+
if (finding.checkId !== 'l3-dep-vuln') return null;
|
|
9
|
+
|
|
10
|
+
const filePath = 'complior-upgrade-plan.md';
|
|
11
|
+
const content = `# Dependency Vulnerability Upgrade Plan
|
|
12
|
+
|
|
13
|
+
Generated by Complior v${ENGINE_VERSION}
|
|
14
|
+
|
|
15
|
+
## Vulnerability Summary
|
|
16
|
+
|
|
17
|
+
${finding.message || 'Vulnerable dependency detected — see scan results for details.'}
|
|
18
|
+
|
|
19
|
+
## Upgrade Commands
|
|
20
|
+
|
|
21
|
+
### npm / Node.js
|
|
22
|
+
\`\`\`bash
|
|
23
|
+
npm audit fix
|
|
24
|
+
npm update <package-name>
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
### pip / Python
|
|
28
|
+
\`\`\`bash
|
|
29
|
+
pip install --upgrade <package-name>
|
|
30
|
+
pip-audit --fix
|
|
31
|
+
\`\`\`
|
|
32
|
+
|
|
33
|
+
### cargo / Rust
|
|
34
|
+
\`\`\`bash
|
|
35
|
+
cargo update <package-name>
|
|
36
|
+
cargo audit fix
|
|
37
|
+
\`\`\`
|
|
38
|
+
|
|
39
|
+
## Verification Checklist
|
|
40
|
+
|
|
41
|
+
- [ ] Run \`npm audit\` / \`pip-audit\` / \`cargo audit\` after upgrade
|
|
42
|
+
- [ ] Run full test suite to verify no regressions
|
|
43
|
+
- [ ] Update lock file and commit
|
|
44
|
+
- [ ] Review changelog for breaking changes
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
const action: FixAction = {
|
|
48
|
+
type: 'create',
|
|
49
|
+
path: filePath,
|
|
50
|
+
content,
|
|
51
|
+
description: 'Create dependency upgrade plan for CVE remediation',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-008',
|
|
56
|
+
checkId: finding.checkId,
|
|
57
|
+
article: finding.articleReference ?? 'Art. 15',
|
|
58
|
+
fixType: 'dependency_fix',
|
|
59
|
+
framework: context.framework,
|
|
60
|
+
actions: [action],
|
|
61
|
+
diff: generateCreateDiff(filePath, content),
|
|
62
|
+
scoreImpact: 5,
|
|
63
|
+
commitMessage: 'fix: add dependency vulnerability upgrade plan (Art. 15) -- via Complior',
|
|
64
|
+
description: 'Create upgrade plan for vulnerable dependencies',
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { FixStrategy, FixAction } from '../types.js';
|
|
2
|
+
import { generateCreateDiff } from '../diff.js';
|
|
3
|
+
|
|
4
|
+
// --- Strategy: Data Governance (Art. 10) ---
|
|
5
|
+
|
|
6
|
+
export const dataGovernanceStrategy: FixStrategy = (finding, context) => {
|
|
7
|
+
if (finding.checkId !== 'l4-data-governance') return null;
|
|
8
|
+
|
|
9
|
+
const filePath = 'src/middleware/data-governance.ts';
|
|
10
|
+
const content = `// Data Governance Middleware (EU AI Act, Art. 10)
|
|
11
|
+
// Input validation, PII detection, and data quality checks
|
|
12
|
+
|
|
13
|
+
export interface DataQualityReport {
|
|
14
|
+
readonly timestamp: string;
|
|
15
|
+
readonly inputSize: number;
|
|
16
|
+
readonly piiDetected: boolean;
|
|
17
|
+
readonly validationPassed: boolean;
|
|
18
|
+
readonly issues: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const PII_PATTERNS = [
|
|
22
|
+
/\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}\\b/i,
|
|
23
|
+
/\\b\\d{3}-\\d{2}-\\d{4}\\b/,
|
|
24
|
+
/\\b\\d{16}\\b/,
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
export const detectPII = (text: string): boolean =>
|
|
28
|
+
PII_PATTERNS.some((p) => p.test(text));
|
|
29
|
+
|
|
30
|
+
export const validateInput = (input: string): DataQualityReport => {
|
|
31
|
+
const issues: string[] = [];
|
|
32
|
+
if (!input.trim()) issues.push('Empty input');
|
|
33
|
+
if (input.length > 100_000) issues.push('Input exceeds maximum length');
|
|
34
|
+
const piiDetected = detectPII(input);
|
|
35
|
+
if (piiDetected) issues.push('PII detected in input');
|
|
36
|
+
return {
|
|
37
|
+
timestamp: new Date().toISOString(),
|
|
38
|
+
inputSize: input.length,
|
|
39
|
+
piiDetected,
|
|
40
|
+
validationPassed: issues.length === 0,
|
|
41
|
+
issues,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
const action: FixAction = {
|
|
47
|
+
type: 'create',
|
|
48
|
+
path: filePath,
|
|
49
|
+
content,
|
|
50
|
+
description: 'Create data governance middleware with PII detection',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
obligationId: finding.obligationId ?? 'eu-ai-act-OBL-004',
|
|
55
|
+
checkId: finding.checkId,
|
|
56
|
+
article: finding.articleReference ?? 'Art. 10',
|
|
57
|
+
fixType: 'code_injection',
|
|
58
|
+
framework: context.framework,
|
|
59
|
+
actions: [action],
|
|
60
|
+
diff: generateCreateDiff(filePath, content),
|
|
61
|
+
scoreImpact: 5,
|
|
62
|
+
commitMessage: 'fix: add data governance middleware (Art. 10) -- via Complior',
|
|
63
|
+
description: 'Add data governance middleware with input validation and PII detection',
|
|
64
|
+
};
|
|
65
|
+
};
|