bps-kit 1.0.1 → 1.0.2
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/package.json +1 -1
- package/templates/.agents/agents/backend-specialist.md +263 -0
- package/templates/.agents/agents/code-archaeologist.md +106 -0
- package/templates/.agents/agents/database-architect.md +226 -0
- package/templates/.agents/agents/debugger.md +225 -0
- package/templates/.agents/agents/devops-engineer.md +242 -0
- package/templates/.agents/agents/documentation-writer.md +104 -0
- package/templates/.agents/agents/explorer-agent.md +73 -0
- package/templates/.agents/agents/frontend-specialist.md +593 -0
- package/templates/.agents/agents/game-developer.md +162 -0
- package/templates/.agents/agents/mobile-developer.md +377 -0
- package/templates/.agents/agents/orchestrator.md +416 -0
- package/templates/.agents/agents/penetration-tester.md +188 -0
- package/templates/.agents/agents/performance-optimizer.md +187 -0
- package/templates/.agents/agents/product-manager.md +112 -0
- package/templates/.agents/agents/product-owner.md +95 -0
- package/templates/.agents/agents/project-planner.md +406 -0
- package/templates/.agents/agents/qa-automation-engineer.md +103 -0
- package/templates/.agents/agents/security-auditor.md +170 -0
- package/templates/.agents/agents/seo-specialist.md +111 -0
- package/templates/.agents/agents/test-engineer.md +158 -0
- package/templates/.agents/rules/GEMINI.md +219 -0
- package/templates/.agents/scripts/auto_preview.py +148 -0
- package/templates/.agents/scripts/checklist.py +217 -0
- package/templates/.agents/scripts/session_manager.py +120 -0
- package/templates/.agents/scripts/verify_all.py +327 -0
- package/templates/.agents/workflows/brainstorm.md +113 -0
- package/templates/.agents/workflows/create.md +59 -0
- package/templates/.agents/workflows/debug.md +103 -0
- package/templates/.agents/workflows/deploy.md +176 -0
- package/templates/.agents/workflows/enhance.md +63 -0
- package/templates/.agents/workflows/orchestrate.md +237 -0
- package/templates/.agents/workflows/plan.md +89 -0
- package/templates/.agents/workflows/preview.md +81 -0
- package/templates/.agents/workflows/setup-brain.md +39 -0
- package/templates/.agents/workflows/status.md +86 -0
- package/templates/.agents/workflows/test.md +144 -0
- package/templates/.agents/workflows/ui-ux-pro-max.md +296 -0
- package/templates/skills_normal/api-patterns/scripts/api_validator.py +211 -0
- package/templates/skills_normal/database-design/scripts/schema_validator.py +172 -0
- package/templates/skills_normal/frontend-design/scripts/accessibility_checker.py +183 -0
- package/templates/skills_normal/frontend-design/scripts/ux_audit.py +722 -0
- package/templates/skills_normal/git-pushing/scripts/smart_commit.sh +19 -0
- package/templates/skills_normal/lint-and-validate/scripts/lint_runner.py +184 -0
- package/templates/skills_normal/lint-and-validate/scripts/type_coverage.py +173 -0
- package/templates/skills_normal/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/templates/skills_normal/senior-fullstack/scripts/code_quality_analyzer.py +114 -0
- package/templates/skills_normal/senior-fullstack/scripts/fullstack_scaffolder.py +114 -0
- package/templates/skills_normal/senior-fullstack/scripts/project_scaffolder.py +114 -0
- package/templates/skills_normal/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/templates/skills_normal/testing-patterns/scripts/test_runner.py +219 -0
- package/templates/skills_normal/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/templates/vault/007/scripts/config.py +472 -0
- package/templates/vault/007/scripts/full_audit.py +1306 -0
- package/templates/vault/007/scripts/quick_scan.py +481 -0
- package/templates/vault/007/scripts/requirements.txt +26 -0
- package/templates/vault/007/scripts/scanners/__init__.py +0 -0
- package/templates/vault/007/scripts/scanners/dependency_scanner.py +1305 -0
- package/templates/vault/007/scripts/scanners/injection_scanner.py +1104 -0
- package/templates/vault/007/scripts/scanners/secrets_scanner.py +1008 -0
- package/templates/vault/007/scripts/score_calculator.py +693 -0
- package/templates/vault/agent-orchestrator/scripts/match_skills.py +329 -0
- package/templates/vault/agent-orchestrator/scripts/orchestrate.py +304 -0
- package/templates/vault/agent-orchestrator/scripts/requirements.txt +1 -0
- package/templates/vault/agent-orchestrator/scripts/scan_registry.py +508 -0
- package/templates/vault/ai-studio-image/scripts/config.py +613 -0
- package/templates/vault/ai-studio-image/scripts/generate.py +630 -0
- package/templates/vault/ai-studio-image/scripts/prompt_engine.py +424 -0
- package/templates/vault/ai-studio-image/scripts/requirements.txt +4 -0
- package/templates/vault/ai-studio-image/scripts/templates.py +349 -0
- package/templates/vault/android_ui_verification/scripts/verify_ui.sh +32 -0
- package/templates/vault/apify-audience-analysis/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-brand-reputation-monitoring/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-competitor-intelligence/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-content-analytics/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-ecommerce/reference/scripts/package.json +3 -0
- package/templates/vault/apify-ecommerce/reference/scripts/run_actor.js +369 -0
- package/templates/vault/apify-influencer-discovery/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-lead-generation/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-market-research/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-trend-analysis/reference/scripts/run_actor.js +363 -0
- package/templates/vault/apify-ultimate-scraper/reference/scripts/run_actor.js +363 -0
- package/templates/vault/audio-transcriber/scripts/install-requirements.sh +190 -0
- package/templates/vault/audio-transcriber/scripts/transcribe.py +486 -0
- package/templates/vault/claude-monitor/scripts/api_bench.py +240 -0
- package/templates/vault/claude-monitor/scripts/config.py +69 -0
- package/templates/vault/claude-monitor/scripts/health_check.py +362 -0
- package/templates/vault/claude-monitor/scripts/monitor.py +296 -0
- package/templates/vault/content-creator/scripts/brand_voice_analyzer.py +185 -0
- package/templates/vault/content-creator/scripts/seo_optimizer.py +419 -0
- package/templates/vault/context-agent/scripts/active_context.py +227 -0
- package/templates/vault/context-agent/scripts/compressor.py +149 -0
- package/templates/vault/context-agent/scripts/config.py +69 -0
- package/templates/vault/context-agent/scripts/context_loader.py +155 -0
- package/templates/vault/context-agent/scripts/context_manager.py +302 -0
- package/templates/vault/context-agent/scripts/models.py +103 -0
- package/templates/vault/context-agent/scripts/project_registry.py +132 -0
- package/templates/vault/context-agent/scripts/requirements.txt +6 -0
- package/templates/vault/context-agent/scripts/search.py +115 -0
- package/templates/vault/context-agent/scripts/session_parser.py +206 -0
- package/templates/vault/context-agent/scripts/session_summary.py +319 -0
- package/templates/vault/context-guardian/scripts/context_snapshot.py +229 -0
- package/templates/vault/docx/ooxml/scripts/pack.py +159 -0
- package/templates/vault/docx/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/docx/ooxml/scripts/validate.py +69 -0
- package/templates/vault/docx/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/docx/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/docx/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/docx/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/docx/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/docx/scripts/__init__.py +1 -0
- package/templates/vault/docx/scripts/document.py +1276 -0
- package/templates/vault/docx/scripts/templates/comments.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsExtended.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsExtensible.xml +3 -0
- package/templates/vault/docx/scripts/templates/commentsIds.xml +3 -0
- package/templates/vault/docx/scripts/templates/people.xml +3 -0
- package/templates/vault/docx/scripts/utilities.py +374 -0
- package/templates/vault/docx-official/ooxml/scripts/pack.py +159 -0
- package/templates/vault/docx-official/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/docx-official/ooxml/scripts/validate.py +69 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/docx-official/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/docx-official/scripts/__init__.py +1 -0
- package/templates/vault/docx-official/scripts/document.py +1276 -0
- package/templates/vault/docx-official/scripts/templates/comments.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsExtended.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsExtensible.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/commentsIds.xml +3 -0
- package/templates/vault/docx-official/scripts/templates/people.xml +3 -0
- package/templates/vault/docx-official/scripts/utilities.py +374 -0
- package/templates/vault/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/templates/vault/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/templates/vault/i18n-localization/scripts/i18n_checker.py +241 -0
- package/templates/vault/instagram/scripts/account_setup.py +233 -0
- package/templates/vault/instagram/scripts/analyze.py +221 -0
- package/templates/vault/instagram/scripts/api_client.py +444 -0
- package/templates/vault/instagram/scripts/auth.py +411 -0
- package/templates/vault/instagram/scripts/comments.py +160 -0
- package/templates/vault/instagram/scripts/config.py +111 -0
- package/templates/vault/instagram/scripts/db.py +467 -0
- package/templates/vault/instagram/scripts/export.py +138 -0
- package/templates/vault/instagram/scripts/governance.py +233 -0
- package/templates/vault/instagram/scripts/hashtags.py +114 -0
- package/templates/vault/instagram/scripts/insights.py +170 -0
- package/templates/vault/instagram/scripts/media.py +65 -0
- package/templates/vault/instagram/scripts/messages.py +103 -0
- package/templates/vault/instagram/scripts/profile.py +58 -0
- package/templates/vault/instagram/scripts/publish.py +449 -0
- package/templates/vault/instagram/scripts/requirements.txt +5 -0
- package/templates/vault/instagram/scripts/run_all.py +189 -0
- package/templates/vault/instagram/scripts/schedule.py +189 -0
- package/templates/vault/instagram/scripts/serve_api.py +234 -0
- package/templates/vault/instagram/scripts/templates.py +155 -0
- package/templates/vault/junta-leiloeiros/scripts/db.py +216 -0
- package/templates/vault/junta-leiloeiros/scripts/export.py +137 -0
- package/templates/vault/junta-leiloeiros/scripts/requirements.txt +15 -0
- package/templates/vault/junta-leiloeiros/scripts/run_all.py +190 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/__init__.py +4 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/base_scraper.py +209 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/generic_scraper.py +110 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucap.py +110 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceac.py +72 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceal.py +72 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/juceb.py +68 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucec.py +63 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucema.py +211 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucemg.py +218 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucep.py +70 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepa.py +74 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepar.py +80 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepe.py +78 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucepi.py +69 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucer.py +256 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucerja.py +170 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucern.py +71 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucesc.py +89 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucesp.py +233 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucetins.py +134 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucis_df.py +63 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/jucisrs.py +299 -0
- package/templates/vault/junta-leiloeiros/scripts/scraper/states.py +99 -0
- package/templates/vault/junta-leiloeiros/scripts/serve_api.py +164 -0
- package/templates/vault/junta-leiloeiros/scripts/web_scraper_fallback.py +233 -0
- package/templates/vault/last30days/scripts/last30days.py +521 -0
- package/templates/vault/last30days/scripts/lib/__init__.py +1 -0
- package/templates/vault/last30days/scripts/lib/cache.py +152 -0
- package/templates/vault/last30days/scripts/lib/dates.py +124 -0
- package/templates/vault/last30days/scripts/lib/dedupe.py +120 -0
- package/templates/vault/last30days/scripts/lib/env.py +149 -0
- package/templates/vault/last30days/scripts/lib/http.py +152 -0
- package/templates/vault/last30days/scripts/lib/models.py +175 -0
- package/templates/vault/last30days/scripts/lib/normalize.py +160 -0
- package/templates/vault/last30days/scripts/lib/openai_reddit.py +230 -0
- package/templates/vault/last30days/scripts/lib/reddit_enrich.py +232 -0
- package/templates/vault/last30days/scripts/lib/render.py +383 -0
- package/templates/vault/last30days/scripts/lib/schema.py +336 -0
- package/templates/vault/last30days/scripts/lib/score.py +311 -0
- package/templates/vault/last30days/scripts/lib/ui.py +324 -0
- package/templates/vault/last30days/scripts/lib/websearch.py +401 -0
- package/templates/vault/last30days/scripts/lib/xai_x.py +217 -0
- package/templates/vault/leiloeiro-avaliacao/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-avaliacao/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-edital/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-edital/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-ia/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-ia/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-juridico/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-juridico/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-mercado/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-mercado/scripts/requirements.txt +1 -0
- package/templates/vault/leiloeiro-risco/scripts/governance.py +106 -0
- package/templates/vault/leiloeiro-risco/scripts/requirements.txt +1 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/database.ts +24 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/db.ts +35 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/index.ts +2 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/migrations.ts +31 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/db/schema.sql +8 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/index.ts +44 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/routes/todos.ts +155 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/backend/src/types/index.ts +35 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/App.css +384 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/App.tsx +81 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/api/todos.ts +57 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/ConfirmDialog.tsx +26 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/EmptyState.tsx +8 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoForm.tsx +43 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoItem.tsx +36 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/components/TodoList.tsx +27 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/hooks/useTodos.ts +81 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/index.css +48 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/main.tsx +10 -0
- package/templates/vault/loki-mode/examples/todo-app-generated/frontend/src/vite-env.d.ts +1 -0
- package/templates/vault/loki-mode/scripts/export-to-vibe-kanban.sh +178 -0
- package/templates/vault/loki-mode/scripts/loki-wrapper.sh +281 -0
- package/templates/vault/loki-mode/scripts/take-screenshots.js +55 -0
- package/templates/vault/matematico-tao/scripts/complexity_analyzer.py +544 -0
- package/templates/vault/matematico-tao/scripts/dependency_graph.py +538 -0
- package/templates/vault/mcp-builder/scripts/connections.py +151 -0
- package/templates/vault/mcp-builder/scripts/evaluation.py +373 -0
- package/templates/vault/mcp-builder/scripts/example_evaluation.xml +22 -0
- package/templates/vault/mcp-builder/scripts/requirements.txt +2 -0
- package/templates/vault/mobile-design/scripts/mobile_audit.py +670 -0
- package/templates/vault/notebooklm/scripts/__init__.py +81 -0
- package/templates/vault/notebooklm/scripts/ask_question.py +256 -0
- package/templates/vault/notebooklm/scripts/auth_manager.py +358 -0
- package/templates/vault/notebooklm/scripts/browser_session.py +255 -0
- package/templates/vault/notebooklm/scripts/browser_utils.py +107 -0
- package/templates/vault/notebooklm/scripts/cleanup_manager.py +302 -0
- package/templates/vault/notebooklm/scripts/config.py +44 -0
- package/templates/vault/notebooklm/scripts/notebook_manager.py +410 -0
- package/templates/vault/notebooklm/scripts/run.py +102 -0
- package/templates/vault/notebooklm/scripts/setup_environment.py +204 -0
- package/templates/vault/pdf/scripts/check_bounding_boxes.py +70 -0
- package/templates/vault/pdf/scripts/check_bounding_boxes_test.py +226 -0
- package/templates/vault/pdf/scripts/check_fillable_fields.py +12 -0
- package/templates/vault/pdf/scripts/convert_pdf_to_images.py +35 -0
- package/templates/vault/pdf/scripts/create_validation_image.py +41 -0
- package/templates/vault/pdf/scripts/extract_form_field_info.py +152 -0
- package/templates/vault/pdf/scripts/fill_fillable_fields.py +114 -0
- package/templates/vault/pdf/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/templates/vault/pdf-official/scripts/check_bounding_boxes.py +70 -0
- package/templates/vault/pdf-official/scripts/check_bounding_boxes_test.py +226 -0
- package/templates/vault/pdf-official/scripts/check_fillable_fields.py +12 -0
- package/templates/vault/pdf-official/scripts/convert_pdf_to_images.py +35 -0
- package/templates/vault/pdf-official/scripts/create_validation_image.py +41 -0
- package/templates/vault/pdf-official/scripts/extract_form_field_info.py +152 -0
- package/templates/vault/pdf-official/scripts/fill_fillable_fields.py +114 -0
- package/templates/vault/pdf-official/scripts/fill_pdf_form_with_annotations.py +108 -0
- package/templates/vault/planning-with-files/scripts/check-complete.sh +44 -0
- package/templates/vault/planning-with-files/scripts/init-session.sh +120 -0
- package/templates/vault/pptx/ooxml/scripts/pack.py +159 -0
- package/templates/vault/pptx/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/pptx/ooxml/scripts/validate.py +69 -0
- package/templates/vault/pptx/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/pptx/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/pptx/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/pptx/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/pptx/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/pptx/scripts/html2pptx.js +979 -0
- package/templates/vault/pptx/scripts/inventory.py +1020 -0
- package/templates/vault/pptx/scripts/rearrange.py +231 -0
- package/templates/vault/pptx/scripts/replace.py +385 -0
- package/templates/vault/pptx/scripts/thumbnail.py +450 -0
- package/templates/vault/pptx-official/ooxml/scripts/pack.py +159 -0
- package/templates/vault/pptx-official/ooxml/scripts/unpack.py +29 -0
- package/templates/vault/pptx-official/ooxml/scripts/validate.py +69 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/__init__.py +15 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/base.py +951 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/docx.py +274 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/pptx.py +315 -0
- package/templates/vault/pptx-official/ooxml/scripts/validation/redlining.py +279 -0
- package/templates/vault/pptx-official/scripts/html2pptx.js +979 -0
- package/templates/vault/pptx-official/scripts/inventory.py +1020 -0
- package/templates/vault/pptx-official/scripts/rearrange.py +231 -0
- package/templates/vault/pptx-official/scripts/replace.py +385 -0
- package/templates/vault/pptx-official/scripts/thumbnail.py +450 -0
- package/templates/vault/product-manager-toolkit/scripts/customer_interview_analyzer.py +441 -0
- package/templates/vault/product-manager-toolkit/scripts/rice_prioritizer.py +296 -0
- package/templates/vault/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/templates/vault/scripts/.skill_cache.json +7538 -0
- package/templates/vault/scripts/skill_search.py +228 -0
- package/templates/vault/senior-architect/scripts/architecture_diagram_generator.py +114 -0
- package/templates/vault/senior-architect/scripts/dependency_analyzer.py +114 -0
- package/templates/vault/senior-architect/scripts/project_architect.py +114 -0
- package/templates/vault/shopify-development/scripts/requirements.txt +19 -0
- package/templates/vault/shopify-development/scripts/shopify_graphql.py +428 -0
- package/templates/vault/shopify-development/scripts/shopify_init.py +441 -0
- package/templates/vault/shopify-development/scripts/tests/test_shopify_init.py +379 -0
- package/templates/vault/skill-creator/scripts/init_skill.py +303 -0
- package/templates/vault/skill-creator/scripts/package_skill.py +110 -0
- package/templates/vault/skill-creator/scripts/quick_validate.py +95 -0
- package/templates/vault/skill-installer/scripts/detect_skills.py +318 -0
- package/templates/vault/skill-installer/scripts/install_skill.py +1708 -0
- package/templates/vault/skill-installer/scripts/package_skill.py +417 -0
- package/templates/vault/skill-installer/scripts/requirements.txt +1 -0
- package/templates/vault/skill-installer/scripts/validate_skill.py +430 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/__init__.py +13 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/code_quality.py +247 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/cross_skill.py +134 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/dependencies.py +121 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/documentation.py +189 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/governance_audit.py +153 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/performance.py +164 -0
- package/templates/vault/skill-sentinel/scripts/analyzers/security.py +189 -0
- package/templates/vault/skill-sentinel/scripts/config.py +158 -0
- package/templates/vault/skill-sentinel/scripts/cost_optimizer.py +146 -0
- package/templates/vault/skill-sentinel/scripts/db.py +354 -0
- package/templates/vault/skill-sentinel/scripts/governance.py +58 -0
- package/templates/vault/skill-sentinel/scripts/recommender.py +228 -0
- package/templates/vault/skill-sentinel/scripts/report_generator.py +224 -0
- package/templates/vault/skill-sentinel/scripts/requirements.txt +1 -0
- package/templates/vault/skill-sentinel/scripts/run_audit.py +290 -0
- package/templates/vault/skill-sentinel/scripts/scanner.py +271 -0
- package/templates/vault/stability-ai/scripts/config.py +266 -0
- package/templates/vault/stability-ai/scripts/generate.py +687 -0
- package/templates/vault/stability-ai/scripts/requirements.txt +4 -0
- package/templates/vault/stability-ai/scripts/styles.py +174 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/bot-client.ts +86 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/handlers.ts +79 -0
- package/templates/vault/telegram/assets/boilerplate/nodejs/src/index.ts +32 -0
- package/templates/vault/telegram/scripts/send_message.py +143 -0
- package/templates/vault/telegram/scripts/setup_project.py +103 -0
- package/templates/vault/telegram/scripts/test_bot.py +144 -0
- package/templates/vault/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/templates/vault/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/templates/vault/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/templates/vault/ui-ux-pro-max/scripts/core.py +257 -0
- package/templates/vault/ui-ux-pro-max/scripts/design_system.py +487 -0
- package/templates/vault/ui-ux-pro-max/scripts/search.py +76 -0
- package/templates/vault/videodb/scripts/ws_listener.py +204 -0
- package/templates/vault/web-artifacts-builder/scripts/bundle-artifact.sh +54 -0
- package/templates/vault/web-artifacts-builder/scripts/init-artifact.sh +322 -0
- package/templates/vault/web-artifacts-builder/scripts/shadcn-components.tar.gz +0 -0
- package/templates/vault/webapp-testing/scripts/with_server.py +106 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/index.ts +125 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/template-manager.ts +67 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/types.ts +216 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/webhook-handler.ts +173 -0
- package/templates/vault/whatsapp-cloud-api/assets/boilerplate/nodejs/src/whatsapp-client.ts +193 -0
- package/templates/vault/whatsapp-cloud-api/scripts/send_test_message.py +137 -0
- package/templates/vault/whatsapp-cloud-api/scripts/setup_project.py +118 -0
- package/templates/vault/whatsapp-cloud-api/scripts/validate_config.py +190 -0
- package/templates/vault/youtube-summarizer/scripts/extract-transcript.py +65 -0
- package/templates/vault/youtube-summarizer/scripts/install-dependencies.sh +28 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
"""007 Score Calculator -- Unified security scoring engine.
|
|
2
|
+
|
|
3
|
+
Aggregates results from all scanners (secrets, dependency, injection, quick_scan)
|
|
4
|
+
into a unified, per-domain security score with a weighted final verdict.
|
|
5
|
+
|
|
6
|
+
The score covers 8 security domains as defined in config.SCORING_WEIGHTS:
|
|
7
|
+
- secrets, input_validation, authn_authz, data_protection,
|
|
8
|
+
resilience, monitoring, supply_chain, compliance.
|
|
9
|
+
|
|
10
|
+
Results are appended to data/score_history.json for trend analysis and
|
|
11
|
+
every run is recorded in the audit log.
|
|
12
|
+
|
|
13
|
+
Usage:
|
|
14
|
+
python score_calculator.py --target /path/to/project
|
|
15
|
+
python score_calculator.py --target /path/to/project --output json
|
|
16
|
+
python score_calculator.py --target /path/to/project --verbose
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import json
|
|
21
|
+
import os
|
|
22
|
+
import re
|
|
23
|
+
import sys
|
|
24
|
+
import time
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
# Imports from the 007 config hub (same directory)
|
|
29
|
+
# ---------------------------------------------------------------------------
|
|
30
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
31
|
+
|
|
32
|
+
from config import ( # noqa: E402
|
|
33
|
+
BASE_DIR,
|
|
34
|
+
DATA_DIR,
|
|
35
|
+
SCORING_WEIGHTS,
|
|
36
|
+
SCORING_LABELS,
|
|
37
|
+
SCORE_HISTORY_PATH,
|
|
38
|
+
SEVERITY,
|
|
39
|
+
SCANNABLE_EXTENSIONS,
|
|
40
|
+
SKIP_DIRECTORIES,
|
|
41
|
+
LIMITS,
|
|
42
|
+
ensure_directories,
|
|
43
|
+
get_verdict,
|
|
44
|
+
get_timestamp,
|
|
45
|
+
log_audit_event,
|
|
46
|
+
setup_logging,
|
|
47
|
+
calculate_weighted_score,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
# ---------------------------------------------------------------------------
|
|
51
|
+
# Import scanners (each lives in scanners/ sub-package or sibling script)
|
|
52
|
+
# ---------------------------------------------------------------------------
|
|
53
|
+
sys.path.insert(0, str(Path(__file__).resolve().parent / "scanners"))
|
|
54
|
+
|
|
55
|
+
import secrets_scanner # noqa: E402
|
|
56
|
+
import dependency_scanner # noqa: E402
|
|
57
|
+
import injection_scanner # noqa: E402
|
|
58
|
+
|
|
59
|
+
# quick_scan is a sibling script in the same directory
|
|
60
|
+
import quick_scan # noqa: E402
|
|
61
|
+
|
|
62
|
+
# ---------------------------------------------------------------------------
|
|
63
|
+
# Logger
|
|
64
|
+
# ---------------------------------------------------------------------------
|
|
65
|
+
logger = setup_logging("007-score-calculator")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# ---------------------------------------------------------------------------
|
|
69
|
+
# Positive-signal patterns (auth, encryption, resilience, monitoring)
|
|
70
|
+
# ---------------------------------------------------------------------------
|
|
71
|
+
# These patterns indicate GOOD practices. Their presence raises the score
|
|
72
|
+
# in the relevant domain.
|
|
73
|
+
|
|
74
|
+
_AUTH_PATTERNS = [
|
|
75
|
+
re.compile(r"""(?i)(?:@login_required|@auth|@require_auth|@authenticated|@permission_required)"""),
|
|
76
|
+
re.compile(r"""(?i)(?:passport\.authenticate|isAuthenticated|requireAuth|authMiddleware)"""),
|
|
77
|
+
re.compile(r"""(?i)(?:jwt\.verify|jwt\.decode|verify_jwt|decode_token)"""),
|
|
78
|
+
re.compile(r"""(?i)(?:OAuth|oauth2|OpenID|openid)"""),
|
|
79
|
+
re.compile(r"""(?i)(?:session\.get|flask_login|django\.contrib\.auth)"""),
|
|
80
|
+
re.compile(r"""(?i)(?:bcrypt|argon2|pbkdf2|scrypt)"""),
|
|
81
|
+
re.compile(r"""(?i)(?:RBAC|role_required|has_permission|check_permission)"""),
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
_ENCRYPTION_PATTERNS = [
|
|
85
|
+
re.compile(r"""(?i)(?:from\s+cryptography|import\s+cryptography)"""),
|
|
86
|
+
re.compile(r"""(?i)(?:from\s+hashlib|import\s+hashlib)"""),
|
|
87
|
+
re.compile(r"""(?i)(?:from\s+hmac|import\s+hmac)"""),
|
|
88
|
+
re.compile(r"""(?i)(?:AES|Fernet|RSA|ECDSA|ChaCha20)"""),
|
|
89
|
+
re.compile(r"""(?i)(?:https://|TLS|ssl_context|ssl\.create_default_context)"""),
|
|
90
|
+
re.compile(r"""(?i)verify\s*=\s*True"""),
|
|
91
|
+
re.compile(r"""(?i)(?:encrypt|decrypt|sign|verify_signature)"""),
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
_RESILIENCE_PATTERNS = [
|
|
95
|
+
re.compile(r"""(?:try\s*:|except\s+)"""),
|
|
96
|
+
re.compile(r"""(?i)(?:timeout|connect_timeout|read_timeout|socket_timeout)"""),
|
|
97
|
+
re.compile(r"""(?i)(?:retry|retries|backoff|exponential_backoff|tenacity)"""),
|
|
98
|
+
re.compile(r"""(?i)(?:circuit_breaker|CircuitBreaker|pybreaker)"""),
|
|
99
|
+
re.compile(r"""(?i)(?:rate_limit|ratelimit|throttle|RateLimiter)"""),
|
|
100
|
+
re.compile(r"""(?i)(?:max_retries|max_attempts)"""),
|
|
101
|
+
re.compile(r"""(?i)(?:graceful_shutdown|signal\.signal|atexit)"""),
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
_MONITORING_PATTERNS = [
|
|
105
|
+
re.compile(r"""(?:import\s+logging|from\s+logging)"""),
|
|
106
|
+
re.compile(r"""(?i)(?:logger\.\w+|logging\.getLogger)"""),
|
|
107
|
+
re.compile(r"""(?i)(?:sentry|sentry_sdk|raven)"""),
|
|
108
|
+
re.compile(r"""(?i)(?:prometheus|grafana|datadog|newrelic|elastic)"""),
|
|
109
|
+
re.compile(r"""(?i)(?:audit_log|audit_trail|log_event|log_action)"""),
|
|
110
|
+
re.compile(r"""(?i)(?:structlog|loguru)"""),
|
|
111
|
+
re.compile(r"""(?i)(?:alerting|alert_manager|pagerduty|opsgenie)"""),
|
|
112
|
+
]
|
|
113
|
+
|
|
114
|
+
_INPUT_VALIDATION_PATTERNS = [
|
|
115
|
+
re.compile(r"""(?i)(?:pydantic|BaseModel|validator|field_validator)"""),
|
|
116
|
+
re.compile(r"""(?i)(?:jsonschema|validate|Schema|Marshmallow)"""),
|
|
117
|
+
re.compile(r"""(?i)(?:wtforms|FlaskForm|ModelForm)"""),
|
|
118
|
+
re.compile(r"""(?i)(?:sanitize|escape|bleach|html\.escape|markupsafe)"""),
|
|
119
|
+
re.compile(r"""(?i)(?:parameterized|%s.*execute|placeholder|\?)"""),
|
|
120
|
+
re.compile(r"""(?i)(?:zod|yup|joi|express-validator|celebrate)"""),
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
# ---------------------------------------------------------------------------
|
|
125
|
+
# File collection (lightweight, only for positive-signal detection)
|
|
126
|
+
# ---------------------------------------------------------------------------
|
|
127
|
+
|
|
128
|
+
def _collect_source_files(target: Path) -> list[Path]:
|
|
129
|
+
"""Collect source files for positive-signal pattern scanning."""
|
|
130
|
+
files: list[Path] = []
|
|
131
|
+
max_files = LIMITS["max_files_per_scan"]
|
|
132
|
+
|
|
133
|
+
for root, dirs, filenames in os.walk(target):
|
|
134
|
+
dirs[:] = [d for d in dirs if d not in SKIP_DIRECTORIES]
|
|
135
|
+
for fname in filenames:
|
|
136
|
+
if len(files) >= max_files:
|
|
137
|
+
return files
|
|
138
|
+
fpath = Path(root) / fname
|
|
139
|
+
suffix = fpath.suffix.lower()
|
|
140
|
+
name = fpath.name.lower()
|
|
141
|
+
for ext in SCANNABLE_EXTENSIONS:
|
|
142
|
+
if name.endswith(ext) or suffix == ext:
|
|
143
|
+
files.append(fpath)
|
|
144
|
+
break
|
|
145
|
+
|
|
146
|
+
return files
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _count_pattern_matches(files: list[Path], patterns: list[re.Pattern]) -> int:
|
|
150
|
+
"""Count how many files contain at least one match for any of the patterns."""
|
|
151
|
+
count = 0
|
|
152
|
+
for fpath in files:
|
|
153
|
+
try:
|
|
154
|
+
size = fpath.stat().st_size
|
|
155
|
+
if size > LIMITS["max_file_size_bytes"]:
|
|
156
|
+
continue
|
|
157
|
+
text = fpath.read_text(encoding="utf-8", errors="replace")
|
|
158
|
+
except OSError:
|
|
159
|
+
continue
|
|
160
|
+
|
|
161
|
+
for pat in patterns:
|
|
162
|
+
if pat.search(text):
|
|
163
|
+
count += 1
|
|
164
|
+
break # one match per file is enough
|
|
165
|
+
|
|
166
|
+
return count
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
# ---------------------------------------------------------------------------
|
|
170
|
+
# Deduplication
|
|
171
|
+
# ---------------------------------------------------------------------------
|
|
172
|
+
|
|
173
|
+
def _deduplicate_findings(findings: list[dict]) -> list[dict]:
|
|
174
|
+
"""Remove duplicate findings by (file, line, pattern) tuple."""
|
|
175
|
+
seen: set[tuple] = set()
|
|
176
|
+
unique: list[dict] = []
|
|
177
|
+
|
|
178
|
+
for f in findings:
|
|
179
|
+
key = (f.get("file", ""), f.get("line", 0), f.get("pattern", ""))
|
|
180
|
+
if key not in seen:
|
|
181
|
+
seen.add(key)
|
|
182
|
+
unique.append(f)
|
|
183
|
+
|
|
184
|
+
return unique
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# ---------------------------------------------------------------------------
|
|
188
|
+
# Per-domain score calculators
|
|
189
|
+
# ---------------------------------------------------------------------------
|
|
190
|
+
|
|
191
|
+
def _score_from_findings(findings: list[dict], max_deduction: int = 100) -> int:
|
|
192
|
+
"""Compute a 0-100 score from findings. Fewer findings = higher score.
|
|
193
|
+
|
|
194
|
+
Deductions per severity: CRITICAL=15, HIGH=8, MEDIUM=3, LOW=1, INFO=0.
|
|
195
|
+
"""
|
|
196
|
+
deductions = {"CRITICAL": 15, "HIGH": 8, "MEDIUM": 3, "LOW": 1, "INFO": 0}
|
|
197
|
+
total_deduction = 0
|
|
198
|
+
for f in findings:
|
|
199
|
+
total_deduction += deductions.get(f.get("severity", "INFO"), 0)
|
|
200
|
+
return max(0, min(100, max_deduction - total_deduction))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def _score_from_positive_signals(
|
|
204
|
+
match_count: int,
|
|
205
|
+
total_files: int,
|
|
206
|
+
base_score: int = 30,
|
|
207
|
+
max_score: int = 100,
|
|
208
|
+
) -> int:
|
|
209
|
+
"""Score based on presence of positive patterns.
|
|
210
|
+
|
|
211
|
+
If no source files exist, return the base_score (no evidence either way).
|
|
212
|
+
The more files with positive signals, the higher the score.
|
|
213
|
+
"""
|
|
214
|
+
if total_files == 0:
|
|
215
|
+
return base_score
|
|
216
|
+
|
|
217
|
+
ratio = min(1.0, match_count / max(1, total_files * 0.1))
|
|
218
|
+
return min(max_score, int(base_score + ratio * (max_score - base_score)))
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def compute_domain_scores(
|
|
222
|
+
secrets_findings: list[dict],
|
|
223
|
+
injection_findings: list[dict],
|
|
224
|
+
dependency_report: dict,
|
|
225
|
+
quick_findings: list[dict],
|
|
226
|
+
source_files: list[Path],
|
|
227
|
+
total_source_files: int,
|
|
228
|
+
) -> dict[str, float]:
|
|
229
|
+
"""Compute per-domain security scores (0-100).
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
Dict mapping domain key -> score (float).
|
|
233
|
+
"""
|
|
234
|
+
scores: dict[str, float] = {}
|
|
235
|
+
|
|
236
|
+
# ---- secrets ----
|
|
237
|
+
secret_only = [f for f in secrets_findings if f.get("type") == "secret"]
|
|
238
|
+
scores["secrets"] = float(_score_from_findings(secret_only))
|
|
239
|
+
|
|
240
|
+
# ---- input_validation ----
|
|
241
|
+
# Based on injection findings (fewer = higher) + positive validation patterns
|
|
242
|
+
injection_input_related = [
|
|
243
|
+
f for f in injection_findings
|
|
244
|
+
if f.get("injection_type") in (
|
|
245
|
+
"sql_injection", "code_injection", "command_injection",
|
|
246
|
+
"xss", "path_traversal",
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
negative_score = _score_from_findings(injection_input_related)
|
|
250
|
+
positive_count = _count_pattern_matches(source_files, _INPUT_VALIDATION_PATTERNS)
|
|
251
|
+
positive_score = _score_from_positive_signals(positive_count, total_source_files)
|
|
252
|
+
scores["input_validation"] = float(min(100, (negative_score + positive_score) // 2))
|
|
253
|
+
|
|
254
|
+
# ---- authn_authz ----
|
|
255
|
+
auth_count = _count_pattern_matches(source_files, _AUTH_PATTERNS)
|
|
256
|
+
if total_source_files == 0:
|
|
257
|
+
scores["authn_authz"] = 50.0 # no code to evaluate
|
|
258
|
+
elif auth_count == 0:
|
|
259
|
+
scores["authn_authz"] = 25.0 # no auth patterns found = low score
|
|
260
|
+
else:
|
|
261
|
+
scores["authn_authz"] = float(_score_from_positive_signals(
|
|
262
|
+
auth_count, total_source_files, base_score=40, max_score=95,
|
|
263
|
+
))
|
|
264
|
+
|
|
265
|
+
# ---- data_protection ----
|
|
266
|
+
enc_count = _count_pattern_matches(source_files, _ENCRYPTION_PATTERNS)
|
|
267
|
+
# Also penalize for hardcoded IPs, secrets with data exposure risk
|
|
268
|
+
data_exposure = [
|
|
269
|
+
f for f in secrets_findings
|
|
270
|
+
if f.get("pattern") in (
|
|
271
|
+
"db_connection_string", "url_embedded_credentials",
|
|
272
|
+
"hardcoded_public_ip",
|
|
273
|
+
)
|
|
274
|
+
]
|
|
275
|
+
negative_dp = _score_from_findings(data_exposure)
|
|
276
|
+
positive_dp = _score_from_positive_signals(enc_count, total_source_files)
|
|
277
|
+
scores["data_protection"] = float(min(100, (negative_dp + positive_dp) // 2))
|
|
278
|
+
|
|
279
|
+
# ---- resilience ----
|
|
280
|
+
res_count = _count_pattern_matches(source_files, _RESILIENCE_PATTERNS)
|
|
281
|
+
scores["resilience"] = float(_score_from_positive_signals(
|
|
282
|
+
res_count, total_source_files, base_score=30, max_score=95,
|
|
283
|
+
))
|
|
284
|
+
|
|
285
|
+
# ---- monitoring ----
|
|
286
|
+
mon_count = _count_pattern_matches(source_files, _MONITORING_PATTERNS)
|
|
287
|
+
scores["monitoring"] = float(_score_from_positive_signals(
|
|
288
|
+
mon_count, total_source_files, base_score=20, max_score=95,
|
|
289
|
+
))
|
|
290
|
+
|
|
291
|
+
# ---- supply_chain ----
|
|
292
|
+
dep_score = dependency_report.get("score", 50)
|
|
293
|
+
scores["supply_chain"] = float(max(0, min(100, dep_score)))
|
|
294
|
+
|
|
295
|
+
# ---- compliance ----
|
|
296
|
+
# Aggregate of other scores weighted equally as a proxy
|
|
297
|
+
other_scores = [
|
|
298
|
+
scores.get(k, 0.0) for k in SCORING_WEIGHTS if k != "compliance"
|
|
299
|
+
]
|
|
300
|
+
if other_scores:
|
|
301
|
+
scores["compliance"] = float(round(sum(other_scores) / len(other_scores), 2))
|
|
302
|
+
else:
|
|
303
|
+
scores["compliance"] = 50.0
|
|
304
|
+
|
|
305
|
+
return scores
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
# ---------------------------------------------------------------------------
|
|
309
|
+
# Score history persistence
|
|
310
|
+
# ---------------------------------------------------------------------------
|
|
311
|
+
|
|
312
|
+
def _save_score_history(
|
|
313
|
+
target: str,
|
|
314
|
+
domain_scores: dict[str, float],
|
|
315
|
+
final_score: float,
|
|
316
|
+
verdict: dict,
|
|
317
|
+
) -> None:
|
|
318
|
+
"""Append a score entry to the score history JSON file."""
|
|
319
|
+
ensure_directories()
|
|
320
|
+
|
|
321
|
+
entry = {
|
|
322
|
+
"timestamp": get_timestamp(),
|
|
323
|
+
"target": target,
|
|
324
|
+
"domain_scores": domain_scores,
|
|
325
|
+
"final_score": final_score,
|
|
326
|
+
"verdict": {
|
|
327
|
+
"label": verdict["label"],
|
|
328
|
+
"description": verdict["description"],
|
|
329
|
+
"emoji": verdict["emoji"],
|
|
330
|
+
},
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
# Read existing history (JSON array)
|
|
334
|
+
history: list[dict] = []
|
|
335
|
+
if SCORE_HISTORY_PATH.exists():
|
|
336
|
+
try:
|
|
337
|
+
raw = SCORE_HISTORY_PATH.read_text(encoding="utf-8")
|
|
338
|
+
if raw.strip():
|
|
339
|
+
history = json.loads(raw)
|
|
340
|
+
if not isinstance(history, list):
|
|
341
|
+
history = [history]
|
|
342
|
+
except (json.JSONDecodeError, OSError):
|
|
343
|
+
history = []
|
|
344
|
+
|
|
345
|
+
history.append(entry)
|
|
346
|
+
|
|
347
|
+
SCORE_HISTORY_PATH.write_text(
|
|
348
|
+
json.dumps(history, indent=2, ensure_ascii=False) + "\n",
|
|
349
|
+
encoding="utf-8",
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
# ---------------------------------------------------------------------------
|
|
354
|
+
# Report formatters
|
|
355
|
+
# ---------------------------------------------------------------------------
|
|
356
|
+
|
|
357
|
+
def _bar(score: float, width: int = 20) -> str:
|
|
358
|
+
"""Render a simple ASCII progress bar."""
|
|
359
|
+
filled = int(score / 100 * width)
|
|
360
|
+
return "[" + "#" * filled + "." * (width - filled) + "]"
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
def format_text_report(
|
|
364
|
+
target: str,
|
|
365
|
+
domain_scores: dict[str, float],
|
|
366
|
+
final_score: float,
|
|
367
|
+
verdict: dict,
|
|
368
|
+
scanner_summaries: dict[str, dict],
|
|
369
|
+
total_findings: int,
|
|
370
|
+
elapsed: float,
|
|
371
|
+
) -> str:
|
|
372
|
+
"""Build a human-readable score report."""
|
|
373
|
+
lines: list[str] = []
|
|
374
|
+
|
|
375
|
+
lines.append("=" * 72)
|
|
376
|
+
lines.append(" 007 SECURITY SCORE REPORT")
|
|
377
|
+
lines.append("=" * 72)
|
|
378
|
+
lines.append("")
|
|
379
|
+
lines.append(f" Target: {target}")
|
|
380
|
+
lines.append(f" Timestamp: {get_timestamp()}")
|
|
381
|
+
lines.append(f" Duration: {elapsed:.2f}s")
|
|
382
|
+
lines.append(f" Total findings: {total_findings} (deduplicated)")
|
|
383
|
+
lines.append("")
|
|
384
|
+
|
|
385
|
+
# Scanner summaries
|
|
386
|
+
lines.append("-" * 72)
|
|
387
|
+
lines.append(" SCANNER RESULTS")
|
|
388
|
+
lines.append("-" * 72)
|
|
389
|
+
for scanner_name, summary in scanner_summaries.items():
|
|
390
|
+
findings_count = summary.get("findings", 0)
|
|
391
|
+
scanner_score = summary.get("score", "N/A")
|
|
392
|
+
lines.append(f" {scanner_name:<25} findings={findings_count:<6} score={scanner_score}")
|
|
393
|
+
lines.append("")
|
|
394
|
+
|
|
395
|
+
# Per-domain scores
|
|
396
|
+
lines.append("-" * 72)
|
|
397
|
+
lines.append(" DOMAIN SCORES")
|
|
398
|
+
lines.append("-" * 72)
|
|
399
|
+
lines.append(f" {'Domain':<30} {'Weight':>6} {'Score':>5} {'Bar'}")
|
|
400
|
+
lines.append(f" {'-' * 30} {'-' * 6} {'-' * 5} {'-' * 22}")
|
|
401
|
+
|
|
402
|
+
for domain, weight in SCORING_WEIGHTS.items():
|
|
403
|
+
score = domain_scores.get(domain, 0.0)
|
|
404
|
+
label = SCORING_LABELS.get(domain, domain)
|
|
405
|
+
weight_pct = f"{weight * 100:.0f}%"
|
|
406
|
+
lines.append(
|
|
407
|
+
f" {label:<30} {weight_pct:>6} {score:>5.1f} {_bar(score)}"
|
|
408
|
+
)
|
|
409
|
+
lines.append("")
|
|
410
|
+
|
|
411
|
+
# Final score and verdict
|
|
412
|
+
lines.append("=" * 72)
|
|
413
|
+
lines.append(f" FINAL SCORE: {final_score:.1f} / 100")
|
|
414
|
+
lines.append(f" VERDICT: {verdict['emoji']} {verdict['label']}")
|
|
415
|
+
lines.append(f" {verdict['description']}")
|
|
416
|
+
lines.append("=" * 72)
|
|
417
|
+
lines.append("")
|
|
418
|
+
|
|
419
|
+
return "\n".join(lines)
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def build_json_report(
|
|
423
|
+
target: str,
|
|
424
|
+
domain_scores: dict[str, float],
|
|
425
|
+
final_score: float,
|
|
426
|
+
verdict: dict,
|
|
427
|
+
scanner_summaries: dict[str, dict],
|
|
428
|
+
all_findings: list[dict],
|
|
429
|
+
total_findings: int,
|
|
430
|
+
elapsed: float,
|
|
431
|
+
) -> dict:
|
|
432
|
+
"""Build a structured JSON report."""
|
|
433
|
+
return {
|
|
434
|
+
"report": "score_calculator",
|
|
435
|
+
"target": target,
|
|
436
|
+
"timestamp": get_timestamp(),
|
|
437
|
+
"duration_seconds": round(elapsed, 3),
|
|
438
|
+
"total_findings": total_findings,
|
|
439
|
+
"domain_scores": domain_scores,
|
|
440
|
+
"final_score": final_score,
|
|
441
|
+
"verdict": {
|
|
442
|
+
"label": verdict["label"],
|
|
443
|
+
"description": verdict["description"],
|
|
444
|
+
"emoji": verdict["emoji"],
|
|
445
|
+
},
|
|
446
|
+
"scanner_summaries": scanner_summaries,
|
|
447
|
+
"findings": all_findings,
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
|
|
451
|
+
# ---------------------------------------------------------------------------
|
|
452
|
+
# Main entry point
|
|
453
|
+
# ---------------------------------------------------------------------------
|
|
454
|
+
|
|
455
|
+
def run_score(
|
|
456
|
+
target_path: str,
|
|
457
|
+
output_format: str = "text",
|
|
458
|
+
verbose: bool = False,
|
|
459
|
+
) -> dict:
|
|
460
|
+
"""Execute all scanners, aggregate results, compute unified score.
|
|
461
|
+
|
|
462
|
+
Args:
|
|
463
|
+
target_path: Path to the directory to scan.
|
|
464
|
+
output_format: 'text' or 'json'.
|
|
465
|
+
verbose: Enable debug-level logging.
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
JSON-compatible report dict.
|
|
469
|
+
"""
|
|
470
|
+
if verbose:
|
|
471
|
+
logger.setLevel("DEBUG")
|
|
472
|
+
|
|
473
|
+
ensure_directories()
|
|
474
|
+
|
|
475
|
+
target = Path(target_path).resolve()
|
|
476
|
+
if not target.exists():
|
|
477
|
+
logger.error("Target path does not exist: %s", target)
|
|
478
|
+
sys.exit(1)
|
|
479
|
+
if not target.is_dir():
|
|
480
|
+
logger.error("Target is not a directory: %s", target)
|
|
481
|
+
sys.exit(1)
|
|
482
|
+
|
|
483
|
+
logger.info("Starting unified security score calculation for %s", target)
|
|
484
|
+
start_time = time.time()
|
|
485
|
+
target_str = str(target)
|
|
486
|
+
|
|
487
|
+
# ------------------------------------------------------------------
|
|
488
|
+
# Phase 1: Run all scanners (suppress stdout by capturing reports)
|
|
489
|
+
# ------------------------------------------------------------------
|
|
490
|
+
|
|
491
|
+
scanner_summaries: dict[str, dict] = {}
|
|
492
|
+
|
|
493
|
+
# 1a. Secrets scanner
|
|
494
|
+
logger.info("Running secrets scanner...")
|
|
495
|
+
try:
|
|
496
|
+
secrets_report = secrets_scanner.run_scan(
|
|
497
|
+
target_path=target_str,
|
|
498
|
+
output_format="json",
|
|
499
|
+
verbose=verbose,
|
|
500
|
+
)
|
|
501
|
+
except SystemExit:
|
|
502
|
+
secrets_report = {"findings": [], "score": 50, "total_findings": 0}
|
|
503
|
+
|
|
504
|
+
secrets_findings = secrets_report.get("findings", [])
|
|
505
|
+
scanner_summaries["secrets_scanner"] = {
|
|
506
|
+
"findings": len(secrets_findings),
|
|
507
|
+
"score": secrets_report.get("score", 50),
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
# 1b. Dependency scanner
|
|
511
|
+
logger.info("Running dependency scanner...")
|
|
512
|
+
try:
|
|
513
|
+
dep_report = dependency_scanner.run_scan(
|
|
514
|
+
target_path=target_str,
|
|
515
|
+
output_format="json",
|
|
516
|
+
verbose=verbose,
|
|
517
|
+
)
|
|
518
|
+
except SystemExit:
|
|
519
|
+
dep_report = {"findings": [], "score": 50, "total_findings": 0}
|
|
520
|
+
|
|
521
|
+
dep_findings = dep_report.get("findings", [])
|
|
522
|
+
scanner_summaries["dependency_scanner"] = {
|
|
523
|
+
"findings": len(dep_findings),
|
|
524
|
+
"score": dep_report.get("score", 50),
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
# 1c. Injection scanner
|
|
528
|
+
logger.info("Running injection scanner...")
|
|
529
|
+
try:
|
|
530
|
+
inj_report = injection_scanner.run_scan(
|
|
531
|
+
target_path=target_str,
|
|
532
|
+
output_format="json",
|
|
533
|
+
verbose=verbose,
|
|
534
|
+
)
|
|
535
|
+
except SystemExit:
|
|
536
|
+
inj_report = {"findings": [], "score": 50, "total_findings": 0}
|
|
537
|
+
|
|
538
|
+
inj_findings = inj_report.get("findings", [])
|
|
539
|
+
scanner_summaries["injection_scanner"] = {
|
|
540
|
+
"findings": len(inj_findings),
|
|
541
|
+
"score": inj_report.get("score", 50),
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
# 1d. Quick scan (broad patterns)
|
|
545
|
+
logger.info("Running quick scan...")
|
|
546
|
+
try:
|
|
547
|
+
quick_report = quick_scan.run_scan(
|
|
548
|
+
target_path=target_str,
|
|
549
|
+
output_format="json",
|
|
550
|
+
verbose=verbose,
|
|
551
|
+
)
|
|
552
|
+
except SystemExit:
|
|
553
|
+
quick_report = {"findings": [], "score": 50, "total_findings": 0}
|
|
554
|
+
|
|
555
|
+
quick_findings = quick_report.get("findings", [])
|
|
556
|
+
scanner_summaries["quick_scan"] = {
|
|
557
|
+
"findings": len(quick_findings),
|
|
558
|
+
"score": quick_report.get("score", 50),
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
# ------------------------------------------------------------------
|
|
562
|
+
# Phase 2: Aggregate and deduplicate findings
|
|
563
|
+
# ------------------------------------------------------------------
|
|
564
|
+
all_findings_raw = secrets_findings + dep_findings + inj_findings + quick_findings
|
|
565
|
+
all_findings = _deduplicate_findings(all_findings_raw)
|
|
566
|
+
total_findings = len(all_findings)
|
|
567
|
+
|
|
568
|
+
logger.info(
|
|
569
|
+
"Aggregated %d raw findings -> %d unique (deduplicated)",
|
|
570
|
+
len(all_findings_raw), total_findings,
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
# ------------------------------------------------------------------
|
|
574
|
+
# Phase 3: Collect source files for positive-signal analysis
|
|
575
|
+
# ------------------------------------------------------------------
|
|
576
|
+
logger.info("Scanning for positive security signals...")
|
|
577
|
+
source_files = _collect_source_files(target)
|
|
578
|
+
total_source_files = len(source_files)
|
|
579
|
+
logger.info("Collected %d source files for positive-signal analysis", total_source_files)
|
|
580
|
+
|
|
581
|
+
# ------------------------------------------------------------------
|
|
582
|
+
# Phase 4: Compute per-domain scores
|
|
583
|
+
# ------------------------------------------------------------------
|
|
584
|
+
domain_scores = compute_domain_scores(
|
|
585
|
+
secrets_findings=secrets_findings,
|
|
586
|
+
injection_findings=inj_findings,
|
|
587
|
+
dependency_report=dep_report,
|
|
588
|
+
quick_findings=quick_findings,
|
|
589
|
+
source_files=source_files,
|
|
590
|
+
total_source_files=total_source_files,
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
# ------------------------------------------------------------------
|
|
594
|
+
# Phase 5: Compute weighted final score and verdict
|
|
595
|
+
# ------------------------------------------------------------------
|
|
596
|
+
final_score = calculate_weighted_score(domain_scores)
|
|
597
|
+
verdict = get_verdict(final_score)
|
|
598
|
+
|
|
599
|
+
elapsed = time.time() - start_time
|
|
600
|
+
logger.info(
|
|
601
|
+
"Score calculation complete in %.2fs: final_score=%.1f, verdict=%s",
|
|
602
|
+
elapsed, final_score, verdict["label"],
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
# ------------------------------------------------------------------
|
|
606
|
+
# Phase 6: Save history and audit log
|
|
607
|
+
# ------------------------------------------------------------------
|
|
608
|
+
_save_score_history(target_str, domain_scores, final_score, verdict)
|
|
609
|
+
|
|
610
|
+
log_audit_event(
|
|
611
|
+
action="score_calculation",
|
|
612
|
+
target=target_str,
|
|
613
|
+
result=f"final_score={final_score}, verdict={verdict['label']}",
|
|
614
|
+
details={
|
|
615
|
+
"domain_scores": domain_scores,
|
|
616
|
+
"total_findings": total_findings,
|
|
617
|
+
"scanner_summaries": scanner_summaries,
|
|
618
|
+
"duration_seconds": round(elapsed, 3),
|
|
619
|
+
},
|
|
620
|
+
)
|
|
621
|
+
|
|
622
|
+
# ------------------------------------------------------------------
|
|
623
|
+
# Phase 7: Build and output report
|
|
624
|
+
# ------------------------------------------------------------------
|
|
625
|
+
report = build_json_report(
|
|
626
|
+
target=target_str,
|
|
627
|
+
domain_scores=domain_scores,
|
|
628
|
+
final_score=final_score,
|
|
629
|
+
verdict=verdict,
|
|
630
|
+
scanner_summaries=scanner_summaries,
|
|
631
|
+
all_findings=all_findings,
|
|
632
|
+
total_findings=total_findings,
|
|
633
|
+
elapsed=elapsed,
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
if output_format == "json":
|
|
637
|
+
print(json.dumps(report, indent=2, ensure_ascii=False))
|
|
638
|
+
else:
|
|
639
|
+
print(format_text_report(
|
|
640
|
+
target=target_str,
|
|
641
|
+
domain_scores=domain_scores,
|
|
642
|
+
final_score=final_score,
|
|
643
|
+
verdict=verdict,
|
|
644
|
+
scanner_summaries=scanner_summaries,
|
|
645
|
+
total_findings=total_findings,
|
|
646
|
+
elapsed=elapsed,
|
|
647
|
+
))
|
|
648
|
+
|
|
649
|
+
return report
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
# ---------------------------------------------------------------------------
|
|
653
|
+
# CLI
|
|
654
|
+
# ---------------------------------------------------------------------------
|
|
655
|
+
|
|
656
|
+
if __name__ == "__main__":
|
|
657
|
+
parser = argparse.ArgumentParser(
|
|
658
|
+
description=(
|
|
659
|
+
"007 Score Calculator -- Unified security scoring engine.\n"
|
|
660
|
+
"Runs all scanners and computes per-domain security scores."
|
|
661
|
+
),
|
|
662
|
+
epilog=(
|
|
663
|
+
"Examples:\n"
|
|
664
|
+
" python score_calculator.py --target ./my-project\n"
|
|
665
|
+
" python score_calculator.py --target ./my-project --output json\n"
|
|
666
|
+
" python score_calculator.py --target ./my-project --verbose"
|
|
667
|
+
),
|
|
668
|
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
669
|
+
)
|
|
670
|
+
parser.add_argument(
|
|
671
|
+
"--target",
|
|
672
|
+
required=True,
|
|
673
|
+
help="Path to the directory to scan (required).",
|
|
674
|
+
)
|
|
675
|
+
parser.add_argument(
|
|
676
|
+
"--output",
|
|
677
|
+
choices=["text", "json"],
|
|
678
|
+
default="text",
|
|
679
|
+
help="Output format: 'text' (default) or 'json'.",
|
|
680
|
+
)
|
|
681
|
+
parser.add_argument(
|
|
682
|
+
"--verbose",
|
|
683
|
+
action="store_true",
|
|
684
|
+
default=False,
|
|
685
|
+
help="Enable verbose/debug logging.",
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
args = parser.parse_args()
|
|
689
|
+
run_score(
|
|
690
|
+
target_path=args.target,
|
|
691
|
+
output_format=args.output,
|
|
692
|
+
verbose=args.verbose,
|
|
693
|
+
)
|