kirograph 0.19.0 → 0.20.1
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/README.md +10 -8
- package/dist/architecture/layers/dart.d.ts +10 -0
- package/dist/architecture/layers/dart.d.ts.map +1 -0
- package/dist/architecture/layers/elixir.d.ts +6 -0
- package/dist/architecture/layers/elixir.d.ts.map +1 -0
- package/dist/architecture/layers/index.d.ts.map +1 -1
- package/dist/architecture/layers/ocaml.d.ts +6 -0
- package/dist/architecture/layers/ocaml.d.ts.map +1 -0
- package/dist/architecture/layers/scala.d.ts +6 -0
- package/dist/architecture/layers/scala.d.ts.map +1 -0
- package/dist/architecture/layers/solidity.d.ts +6 -0
- package/dist/architecture/layers/solidity.d.ts.map +1 -0
- package/dist/architecture/layers/vue.d.ts +6 -0
- package/dist/architecture/layers/vue.d.ts.map +1 -0
- package/dist/architecture/manifest/elm.d.ts +3 -0
- package/dist/architecture/manifest/elm.d.ts.map +1 -0
- package/dist/architecture/manifest/index.d.ts.map +1 -1
- package/dist/architecture/manifest/ocaml.d.ts +3 -0
- package/dist/architecture/manifest/ocaml.d.ts.map +1 -0
- package/dist/architecture/manifest/scala.d.ts +3 -0
- package/dist/architecture/manifest/scala.d.ts.map +1 -0
- package/dist/bin/banner.d.ts.map +1 -1
- package/dist/bin/commands/affected.d.ts.map +1 -1
- package/dist/bin/commands/attack-surface.d.ts +3 -0
- package/dist/bin/commands/attack-surface.d.ts.map +1 -0
- package/dist/bin/commands/attack-surface.js +7 -0
- package/dist/bin/commands/attack-surface.js.map +2 -2
- package/dist/bin/commands/benchmark.d.ts +9 -0
- package/dist/bin/commands/benchmark.d.ts.map +1 -0
- package/dist/bin/commands/budget.d.ts +6 -0
- package/dist/bin/commands/budget.d.ts.map +1 -0
- package/dist/bin/commands/caveman.d.ts +7 -0
- package/dist/bin/commands/caveman.d.ts.map +1 -0
- package/dist/bin/commands/communities.d.ts +3 -0
- package/dist/bin/commands/communities.d.ts.map +1 -0
- package/dist/bin/commands/compression.d.ts +7 -0
- package/dist/bin/commands/compression.d.ts.map +1 -0
- package/dist/bin/commands/context.d.ts.map +1 -1
- package/dist/bin/commands/data.d.ts +3 -0
- package/dist/bin/commands/data.d.ts.map +1 -0
- package/dist/bin/commands/dead-code.d.ts +3 -0
- package/dist/bin/commands/dead-code.d.ts.map +1 -0
- package/dist/bin/commands/dep-confusion.d.ts +3 -0
- package/dist/bin/commands/dep-confusion.d.ts.map +1 -0
- package/dist/bin/commands/docs.d.ts +3 -0
- package/dist/bin/commands/docs.d.ts.map +1 -0
- package/dist/bin/commands/exec.d.ts +11 -0
- package/dist/bin/commands/exec.d.ts.map +1 -0
- package/dist/bin/commands/export.d.ts +3 -0
- package/dist/bin/commands/export.d.ts.map +1 -0
- package/dist/bin/commands/flows.d.ts +3 -0
- package/dist/bin/commands/flows.d.ts.map +1 -0
- package/dist/bin/commands/gain.d.ts +6 -0
- package/dist/bin/commands/gain.d.ts.map +1 -0
- package/dist/bin/commands/help.d.ts +7 -0
- package/dist/bin/commands/help.d.ts.map +1 -1
- package/dist/bin/commands/help.js +20 -3
- package/dist/bin/commands/help.js.map +2 -2
- package/dist/bin/commands/hotspots.d.ts +3 -0
- package/dist/bin/commands/hotspots.d.ts.map +1 -0
- package/dist/bin/commands/hotspots.js +94 -1
- package/dist/bin/commands/hotspots.js.map +3 -3
- package/dist/bin/commands/install.d.ts.map +1 -1
- package/dist/bin/commands/install.js +3 -3
- package/dist/bin/commands/install.js.map +2 -2
- package/dist/bin/commands/licenses.d.ts +3 -0
- package/dist/bin/commands/licenses.d.ts.map +1 -0
- package/dist/bin/commands/memory.d.ts +16 -0
- package/dist/bin/commands/memory.d.ts.map +1 -0
- package/dist/bin/commands/memory.js +151 -4
- package/dist/bin/commands/memory.js.map +2 -2
- package/dist/bin/commands/path.d.ts +3 -0
- package/dist/bin/commands/path.d.ts.map +1 -0
- package/dist/bin/commands/pattern.d.ts +3 -0
- package/dist/bin/commands/pattern.d.ts.map +1 -0
- package/dist/bin/commands/pattern.js +592 -0
- package/dist/bin/commands/pattern.js.map +7 -0
- package/dist/bin/commands/query.d.ts.map +1 -1
- package/dist/bin/commands/reachability.d.ts +3 -0
- package/dist/bin/commands/reachability.d.ts.map +1 -0
- package/dist/bin/commands/read.d.ts +6 -0
- package/dist/bin/commands/read.d.ts.map +1 -0
- package/dist/bin/commands/refactor.d.ts +3 -0
- package/dist/bin/commands/refactor.d.ts.map +1 -0
- package/dist/bin/commands/remediation.d.ts +3 -0
- package/dist/bin/commands/remediation.d.ts.map +1 -0
- package/dist/bin/commands/sbom.d.ts +3 -0
- package/dist/bin/commands/sbom.d.ts.map +1 -0
- package/dist/bin/commands/security-ci-report.d.ts +9 -0
- package/dist/bin/commands/security-ci-report.d.ts.map +1 -0
- package/dist/bin/commands/security-export.d.ts +2 -0
- package/dist/bin/commands/security-export.d.ts.map +1 -0
- package/dist/bin/commands/security-flows.d.ts +3 -0
- package/dist/bin/commands/security-flows.d.ts.map +1 -0
- package/dist/bin/commands/security-secrets.d.ts +3 -0
- package/dist/bin/commands/security-secrets.d.ts.map +1 -0
- package/dist/bin/commands/security.d.ts +3 -0
- package/dist/bin/commands/security.d.ts.map +1 -0
- package/dist/bin/commands/security.js +15 -0
- package/dist/bin/commands/security.js.map +2 -2
- package/dist/bin/commands/snapshot.d.ts +3 -0
- package/dist/bin/commands/snapshot.d.ts.map +1 -0
- package/dist/bin/commands/staleness.d.ts +3 -0
- package/dist/bin/commands/staleness.d.ts.map +1 -0
- package/dist/bin/commands/status.d.ts.map +1 -1
- package/dist/bin/commands/status.js +27 -0
- package/dist/bin/commands/status.js.map +2 -2
- package/dist/bin/commands/supply-chain.d.ts +3 -0
- package/dist/bin/commands/supply-chain.d.ts.map +1 -0
- package/dist/bin/commands/surprising.d.ts +3 -0
- package/dist/bin/commands/surprising.d.ts.map +1 -0
- package/dist/bin/commands/sync.d.ts.map +1 -1
- package/dist/bin/commands/uninit.d.ts.map +1 -1
- package/dist/bin/commands/utils.d.ts +5 -0
- package/dist/bin/commands/utils.d.ts.map +1 -1
- package/dist/bin/commands/vex.d.ts +3 -0
- package/dist/bin/commands/vex.d.ts.map +1 -0
- package/dist/bin/commands/vuln-suppress.d.ts +3 -0
- package/dist/bin/commands/vuln-suppress.d.ts.map +1 -0
- package/dist/bin/commands/vulns.d.ts +3 -0
- package/dist/bin/commands/vulns.d.ts.map +1 -0
- package/dist/bin/installer/archive.d.ts +47 -0
- package/dist/bin/installer/archive.d.ts.map +1 -0
- package/dist/bin/installer/auto-detect.d.ts +16 -0
- package/dist/bin/installer/auto-detect.d.ts.map +1 -0
- package/dist/bin/installer/caveman.d.ts +12 -0
- package/dist/bin/installer/caveman.d.ts.map +1 -0
- package/dist/bin/installer/cli-agent.d.ts +7 -2
- package/dist/bin/installer/cli-agent.d.ts.map +1 -1
- package/dist/bin/installer/cli-agent.js +6 -2
- package/dist/bin/installer/cli-agent.js.map +2 -2
- package/dist/bin/installer/common.d.ts +36 -0
- package/dist/bin/installer/common.d.ts.map +1 -0
- package/dist/bin/installer/common.js +2 -1
- package/dist/bin/installer/common.js.map +2 -2
- package/dist/bin/installer/config-prompt.d.ts +1 -1
- package/dist/bin/installer/config-prompt.d.ts.map +1 -1
- package/dist/bin/installer/config-prompt.js +74 -2
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/dashboard.d.ts.map +1 -1
- package/dist/bin/installer/detect.d.ts +30 -0
- package/dist/bin/installer/detect.d.ts.map +1 -0
- package/dist/bin/installer/hooks.d.ts +4 -1
- package/dist/bin/installer/hooks.d.ts.map +1 -1
- package/dist/bin/installer/hooks.js +34 -0
- package/dist/bin/installer/hooks.js.map +2 -2
- package/dist/bin/installer/index.d.ts +5 -4
- package/dist/bin/installer/index.d.ts.map +1 -1
- package/dist/bin/installer/index.js +67 -8
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/instructions.d.ts +14 -0
- package/dist/bin/installer/instructions.d.ts.map +1 -0
- package/dist/bin/installer/instructions.js +15 -1
- package/dist/bin/installer/instructions.js.map +2 -2
- package/dist/bin/installer/mcp.d.ts.map +1 -1
- package/dist/bin/installer/prompts.d.ts +17 -0
- package/dist/bin/installer/prompts.d.ts.map +1 -1
- package/dist/bin/installer/qdrant-dashboard.d.ts.map +1 -1
- package/dist/bin/installer/steering.d.ts +14 -2
- package/dist/bin/installer/steering.d.ts.map +1 -1
- package/dist/bin/installer/steering.js +81 -0
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/aider.d.ts +6 -0
- package/dist/bin/installer/targets/aider.d.ts.map +1 -0
- package/dist/bin/installer/targets/aider.js +3 -3
- package/dist/bin/installer/targets/aider.js.map +2 -2
- package/dist/bin/installer/targets/amp.d.ts +6 -0
- package/dist/bin/installer/targets/amp.d.ts.map +1 -0
- package/dist/bin/installer/targets/amp.js +3 -3
- package/dist/bin/installer/targets/amp.js.map +2 -2
- package/dist/bin/installer/targets/antigravity.d.ts +13 -0
- package/dist/bin/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/bin/installer/targets/antigravity.js +2 -2
- package/dist/bin/installer/targets/antigravity.js.map +2 -2
- package/dist/bin/installer/targets/augment.d.ts +6 -0
- package/dist/bin/installer/targets/augment.d.ts.map +1 -0
- package/dist/bin/installer/targets/augment.js +3 -3
- package/dist/bin/installer/targets/augment.js.map +2 -2
- package/dist/bin/installer/targets/claude.d.ts +6 -0
- package/dist/bin/installer/targets/claude.d.ts.map +1 -0
- package/dist/bin/installer/targets/claude.js +2 -2
- package/dist/bin/installer/targets/claude.js.map +2 -2
- package/dist/bin/installer/targets/cline.d.ts +13 -0
- package/dist/bin/installer/targets/cline.d.ts.map +1 -0
- package/dist/bin/installer/targets/cline.js +2 -2
- package/dist/bin/installer/targets/cline.js.map +2 -2
- package/dist/bin/installer/targets/codex.d.ts +6 -0
- package/dist/bin/installer/targets/codex.d.ts.map +1 -0
- package/dist/bin/installer/targets/codex.js +2 -2
- package/dist/bin/installer/targets/codex.js.map +2 -2
- package/dist/bin/installer/targets/continue.d.ts +12 -0
- package/dist/bin/installer/targets/continue.d.ts.map +1 -0
- package/dist/bin/installer/targets/continue.js +2 -2
- package/dist/bin/installer/targets/continue.js.map +2 -2
- package/dist/bin/installer/targets/copilot-cli.d.ts +12 -0
- package/dist/bin/installer/targets/copilot-cli.d.ts.map +1 -0
- package/dist/bin/installer/targets/copilot-cli.js +2 -2
- package/dist/bin/installer/targets/copilot-cli.js.map +2 -2
- package/dist/bin/installer/targets/copilot.d.ts +6 -0
- package/dist/bin/installer/targets/copilot.d.ts.map +1 -0
- package/dist/bin/installer/targets/copilot.js +2 -2
- package/dist/bin/installer/targets/copilot.js.map +2 -2
- package/dist/bin/installer/targets/cursor.d.ts +6 -0
- package/dist/bin/installer/targets/cursor.d.ts.map +1 -0
- package/dist/bin/installer/targets/cursor.js +2 -2
- package/dist/bin/installer/targets/cursor.js.map +2 -2
- package/dist/bin/installer/targets/devin.d.ts +13 -0
- package/dist/bin/installer/targets/devin.d.ts.map +1 -0
- package/dist/bin/installer/targets/devin.js +2 -2
- package/dist/bin/installer/targets/devin.js.map +2 -2
- package/dist/bin/installer/targets/gemini-cli.d.ts +16 -0
- package/dist/bin/installer/targets/gemini-cli.d.ts.map +1 -0
- package/dist/bin/installer/targets/gemini-cli.js +2 -2
- package/dist/bin/installer/targets/gemini-cli.js.map +2 -2
- package/dist/bin/installer/targets/generic.d.ts +59 -0
- package/dist/bin/installer/targets/generic.d.ts.map +1 -0
- package/dist/bin/installer/targets/generic.js +2 -2
- package/dist/bin/installer/targets/generic.js.map +2 -2
- package/dist/bin/installer/targets/goose.d.ts +6 -0
- package/dist/bin/installer/targets/goose.d.ts.map +1 -0
- package/dist/bin/installer/targets/goose.js +3 -3
- package/dist/bin/installer/targets/goose.js.map +2 -2
- package/dist/bin/installer/targets/index.d.ts +11 -0
- package/dist/bin/installer/targets/index.d.ts.map +1 -0
- package/dist/bin/installer/targets/index.js.map +1 -1
- package/dist/bin/installer/targets/junie.d.ts +13 -0
- package/dist/bin/installer/targets/junie.d.ts.map +1 -0
- package/dist/bin/installer/targets/junie.js +2 -2
- package/dist/bin/installer/targets/junie.js.map +2 -2
- package/dist/bin/installer/targets/kilo.d.ts +12 -0
- package/dist/bin/installer/targets/kilo.d.ts.map +1 -0
- package/dist/bin/installer/targets/kilo.js +2 -2
- package/dist/bin/installer/targets/kilo.js.map +2 -2
- package/dist/bin/installer/targets/kiro.d.ts +5 -0
- package/dist/bin/installer/targets/kiro.d.ts.map +1 -0
- package/dist/bin/installer/targets/kiro.js +4 -4
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/installer/targets/opencode.d.ts +13 -0
- package/dist/bin/installer/targets/opencode.d.ts.map +1 -0
- package/dist/bin/installer/targets/opencode.js +2 -2
- package/dist/bin/installer/targets/opencode.js.map +2 -2
- package/dist/bin/installer/targets/openhands.d.ts +6 -0
- package/dist/bin/installer/targets/openhands.d.ts.map +1 -0
- package/dist/bin/installer/targets/openhands.js +3 -3
- package/dist/bin/installer/targets/openhands.js.map +2 -2
- package/dist/bin/installer/targets/qoder.d.ts +12 -0
- package/dist/bin/installer/targets/qoder.d.ts.map +1 -0
- package/dist/bin/installer/targets/qoder.js +2 -2
- package/dist/bin/installer/targets/qoder.js.map +2 -2
- package/dist/bin/installer/targets/qwen.d.ts +12 -0
- package/dist/bin/installer/targets/qwen.d.ts.map +1 -0
- package/dist/bin/installer/targets/qwen.js +2 -2
- package/dist/bin/installer/targets/qwen.js.map +2 -2
- package/dist/bin/installer/targets/replit.d.ts +6 -0
- package/dist/bin/installer/targets/replit.d.ts.map +1 -0
- package/dist/bin/installer/targets/replit.js +3 -3
- package/dist/bin/installer/targets/replit.js.map +2 -2
- package/dist/bin/installer/targets/roo.d.ts +13 -0
- package/dist/bin/installer/targets/roo.d.ts.map +1 -0
- package/dist/bin/installer/targets/roo.js +2 -2
- package/dist/bin/installer/targets/roo.js.map +2 -2
- package/dist/bin/installer/targets/tabnine.d.ts +6 -0
- package/dist/bin/installer/targets/tabnine.d.ts.map +1 -0
- package/dist/bin/installer/targets/tabnine.js +3 -3
- package/dist/bin/installer/targets/tabnine.js.map +2 -2
- package/dist/bin/installer/targets/trae.d.ts +6 -0
- package/dist/bin/installer/targets/trae.d.ts.map +1 -0
- package/dist/bin/installer/targets/trae.js +3 -3
- package/dist/bin/installer/targets/trae.js.map +2 -2
- package/dist/bin/installer/targets/warp.d.ts +12 -0
- package/dist/bin/installer/targets/warp.d.ts.map +1 -0
- package/dist/bin/installer/targets/warp.js +2 -2
- package/dist/bin/installer/targets/warp.js.map +2 -2
- package/dist/bin/installer/targets/windsurf.d.ts +13 -0
- package/dist/bin/installer/targets/windsurf.d.ts.map +1 -0
- package/dist/bin/installer/targets/windsurf.js +2 -2
- package/dist/bin/installer/targets/windsurf.js.map +2 -2
- package/dist/bin/kirograph.js +3 -1
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/bin/progress.d.ts +16 -1
- package/dist/bin/progress.d.ts.map +1 -1
- package/dist/compression/filters/aws.d.ts +9 -0
- package/dist/compression/filters/aws.d.ts.map +1 -0
- package/dist/compression/filters/docker.d.ts +6 -0
- package/dist/compression/filters/docker.d.ts.map +1 -0
- package/dist/compression/filters/files.d.ts +6 -0
- package/dist/compression/filters/files.d.ts.map +1 -0
- package/dist/compression/filters/generic.d.ts +7 -0
- package/dist/compression/filters/generic.d.ts.map +1 -0
- package/dist/compression/filters/git.d.ts +6 -0
- package/dist/compression/filters/git.d.ts.map +1 -0
- package/dist/compression/filters/github.d.ts +6 -0
- package/dist/compression/filters/github.d.ts.map +1 -0
- package/dist/compression/filters/lint.d.ts +6 -0
- package/dist/compression/filters/lint.d.ts.map +1 -0
- package/dist/compression/filters/misc.d.ts +6 -0
- package/dist/compression/filters/misc.d.ts.map +1 -0
- package/dist/compression/filters/package.d.ts +6 -0
- package/dist/compression/filters/package.d.ts.map +1 -0
- package/dist/compression/filters/test.d.ts +6 -0
- package/dist/compression/filters/test.d.ts.map +1 -0
- package/dist/compression/index.d.ts +29 -0
- package/dist/compression/index.d.ts.map +1 -0
- package/dist/compression/naive-cost.d.ts +26 -0
- package/dist/compression/naive-cost.d.ts.map +1 -0
- package/dist/compression/tracker.d.ts +155 -0
- package/dist/compression/tracker.d.ts.map +1 -0
- package/dist/compression/types.d.ts +49 -0
- package/dist/compression/types.d.ts.map +1 -0
- package/dist/config.d.ts +90 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +55 -1
- package/dist/config.js.map +2 -2
- package/dist/core/lock-manager.d.ts +2 -0
- package/dist/core/lock-manager.d.ts.map +1 -1
- package/dist/core/pipeline.d.ts +4 -1
- package/dist/core/pipeline.d.ts.map +1 -1
- package/dist/core/pipeline.js +42 -0
- package/dist/core/pipeline.js.map +2 -2
- package/dist/core/snapshot.d.ts +58 -0
- package/dist/core/snapshot.d.ts.map +1 -0
- package/dist/data/filters.d.ts +23 -0
- package/dist/data/filters.d.ts.map +1 -0
- package/dist/data/indexer.d.ts +25 -0
- package/dist/data/indexer.d.ts.map +1 -0
- package/dist/data/linker.d.ts +37 -0
- package/dist/data/linker.d.ts.map +1 -0
- package/dist/data/lint.d.ts +27 -0
- package/dist/data/lint.d.ts.map +1 -0
- package/dist/data/parsers/csv.d.ts +11 -0
- package/dist/data/parsers/csv.d.ts.map +1 -0
- package/dist/data/parsers/excel.d.ts +10 -0
- package/dist/data/parsers/excel.d.ts.map +1 -0
- package/dist/data/parsers/index.d.ts +28 -0
- package/dist/data/parsers/index.d.ts.map +1 -0
- package/dist/data/parsers/json-array.d.ts +9 -0
- package/dist/data/parsers/json-array.d.ts.map +1 -0
- package/dist/data/parsers/jsonl.d.ts +9 -0
- package/dist/data/parsers/jsonl.d.ts.map +1 -0
- package/dist/data/parsers/parquet.d.ts +10 -0
- package/dist/data/parsers/parquet.d.ts.map +1 -0
- package/dist/data/profiler.d.ts +29 -0
- package/dist/data/profiler.d.ts.map +1 -0
- package/dist/data/queries.d.ts +95 -0
- package/dist/data/queries.d.ts.map +1 -0
- package/dist/data/types.d.ts +103 -0
- package/dist/data/types.d.ts.map +1 -0
- package/dist/db/database.d.ts +57 -0
- package/dist/db/database.d.ts.map +1 -1
- package/dist/db/database.js +19 -0
- package/dist/db/database.js.map +2 -2
- package/dist/db/patterns-schema.sql +23 -0
- package/dist/docs/formats/asciidoc.d.ts +9 -0
- package/dist/docs/formats/asciidoc.d.ts.map +1 -0
- package/dist/docs/formats/html.d.ts +10 -0
- package/dist/docs/formats/html.d.ts.map +1 -0
- package/dist/docs/formats/index.d.ts +31 -0
- package/dist/docs/formats/index.d.ts.map +1 -0
- package/dist/docs/formats/markdown.d.ts +11 -0
- package/dist/docs/formats/markdown.d.ts.map +1 -0
- package/dist/docs/formats/openapi.d.ts +17 -0
- package/dist/docs/formats/openapi.d.ts.map +1 -0
- package/dist/docs/formats/org.d.ts +9 -0
- package/dist/docs/formats/org.d.ts.map +1 -0
- package/dist/docs/formats/plaintext.d.ts +11 -0
- package/dist/docs/formats/plaintext.d.ts.map +1 -0
- package/dist/docs/formats/rdoc.d.ts +10 -0
- package/dist/docs/formats/rdoc.d.ts.map +1 -0
- package/dist/docs/formats/rst.d.ts +11 -0
- package/dist/docs/formats/rst.d.ts.map +1 -0
- package/dist/docs/indexer.d.ts +49 -0
- package/dist/docs/indexer.d.ts.map +1 -0
- package/dist/docs/linker.d.ts +30 -0
- package/dist/docs/linker.d.ts.map +1 -0
- package/dist/docs/lint.d.ts +27 -0
- package/dist/docs/lint.d.ts.map +1 -0
- package/dist/docs/queries.d.ts +78 -0
- package/dist/docs/queries.d.ts.map +1 -0
- package/dist/docs/section-id.d.ts +48 -0
- package/dist/docs/section-id.d.ts.map +1 -0
- package/dist/docs/summarizer.d.ts +13 -0
- package/dist/docs/summarizer.d.ts.map +1 -0
- package/dist/docs/types.d.ts +71 -0
- package/dist/docs/types.d.ts.map +1 -0
- package/dist/docs/vectors.d.ts +54 -0
- package/dist/docs/vectors.d.ts.map +1 -0
- package/dist/extraction/extractor.d.ts +1 -1
- package/dist/extraction/extractor.d.ts.map +1 -1
- package/dist/extraction/extractor.js +26 -3
- package/dist/extraction/extractor.js.map +2 -2
- package/dist/extraction/grammars.d.ts +6 -0
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +1 -0
- package/dist/extraction/grammars.js.map +2 -2
- package/dist/extraction/languages.d.ts.map +1 -1
- package/dist/extraction/languages.js +5 -1
- package/dist/extraction/languages.js.map +2 -2
- package/dist/extraction/notebook.d.ts +14 -0
- package/dist/extraction/notebook.d.ts.map +1 -0
- package/dist/frameworks/amplify.d.ts +9 -0
- package/dist/frameworks/amplify.d.ts.map +1 -0
- package/dist/frameworks/angular.d.ts +9 -0
- package/dist/frameworks/angular.d.ts.map +1 -0
- package/dist/frameworks/ansible.d.ts +8 -0
- package/dist/frameworks/ansible.d.ts.map +1 -0
- package/dist/frameworks/cloudformation.d.ts +9 -0
- package/dist/frameworks/cloudformation.d.ts.map +1 -0
- package/dist/frameworks/docker.d.ts +9 -0
- package/dist/frameworks/docker.d.ts.map +1 -0
- package/dist/frameworks/elixir.d.ts +6 -0
- package/dist/frameworks/elixir.d.ts.map +1 -0
- package/dist/frameworks/flutter.d.ts +12 -0
- package/dist/frameworks/flutter.d.ts.map +1 -0
- package/dist/frameworks/iac.d.ts +10 -0
- package/dist/frameworks/iac.d.ts.map +1 -0
- package/dist/frameworks/index.d.ts +14 -0
- package/dist/frameworks/index.d.ts.map +1 -1
- package/dist/frameworks/kubernetes.d.ts +9 -0
- package/dist/frameworks/kubernetes.d.ts.map +1 -0
- package/dist/frameworks/pulumi.d.ts +9 -0
- package/dist/frameworks/pulumi.d.ts.map +1 -0
- package/dist/frameworks/scala.d.ts +6 -0
- package/dist/frameworks/scala.d.ts.map +1 -0
- package/dist/frameworks/solidity.d.ts +6 -0
- package/dist/frameworks/solidity.d.ts.map +1 -0
- package/dist/frameworks/terraform.d.ts +14 -0
- package/dist/frameworks/terraform.d.ts.map +1 -0
- package/dist/frameworks/vue.d.ts +7 -0
- package/dist/frameworks/vue.d.ts.map +1 -0
- package/dist/graph/communities.d.ts +43 -0
- package/dist/graph/communities.d.ts.map +1 -0
- package/dist/graph/flows.d.ts +55 -0
- package/dist/graph/flows.d.ts.map +1 -0
- package/dist/graph/refactor.d.ts +43 -0
- package/dist/graph/refactor.d.ts.map +1 -0
- package/dist/index.d.ts +36 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/mcp/cache.d.ts +69 -0
- package/dist/mcp/cache.d.ts.map +1 -0
- package/dist/mcp/read-modes.d.ts +31 -0
- package/dist/mcp/read-modes.d.ts.map +1 -0
- package/dist/mcp/server.d.ts +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +15 -2
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/tool-names.d.ts +2 -0
- package/dist/mcp/tool-names.d.ts.map +1 -0
- package/dist/mcp/tool-names.js +4 -1
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.d.ts +12 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +397 -0
- package/dist/mcp/tools.js.map +2 -2
- package/dist/memory/compress.d.ts +19 -0
- package/dist/memory/compress.d.ts.map +1 -0
- package/dist/memory/database.d.ts +92 -0
- package/dist/memory/database.d.ts.map +1 -0
- package/dist/memory/database.js +38 -0
- package/dist/memory/database.js.map +2 -2
- package/dist/memory/index.d.ts +71 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +12 -2
- package/dist/memory/index.js.map +2 -2
- package/dist/memory/symbols.d.ts +21 -0
- package/dist/memory/symbols.d.ts.map +1 -0
- package/dist/memory/types.d.ts +78 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js.map +1 -1
- package/dist/memory/vectors.d.ts +43 -0
- package/dist/memory/vectors.d.ts.map +1 -0
- package/dist/patterns/graph.d.ts +16 -0
- package/dist/patterns/graph.d.ts.map +1 -0
- package/dist/patterns/graph.js +45 -0
- package/dist/patterns/graph.js.map +7 -0
- package/dist/patterns/index.d.ts +4 -0
- package/dist/patterns/index.d.ts.map +1 -0
- package/dist/patterns/index.js +39 -0
- package/dist/patterns/index.js.map +7 -0
- package/dist/patterns/indexer.d.ts +15 -0
- package/dist/patterns/indexer.d.ts.map +1 -0
- package/dist/patterns/indexer.js +97 -0
- package/dist/patterns/indexer.js.map +7 -0
- package/dist/patterns/library/code-eval-elixir.yaml +11 -0
- package/dist/patterns/library/command-injection-c.yaml +11 -0
- package/dist/patterns/library/command-injection-go.yaml +29 -0
- package/dist/patterns/library/command-injection-kotlin.yaml +10 -0
- package/dist/patterns/library/command-injection-php.yaml +11 -0
- package/dist/patterns/library/command-injection-ruby.yaml +11 -0
- package/dist/patterns/library/command-injection-rust.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-bash.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-js.yaml +14 -0
- package/dist/patterns/library/dangerous-eval-php.yaml +11 -0
- package/dist/patterns/library/dangerous-eval-ruby.yaml +11 -0
- package/dist/patterns/library/dangerous-exec-py.yaml +13 -0
- package/dist/patterns/library/dangerous-reflection-java.yaml +8 -0
- package/dist/patterns/library/dynamic-load-lua.yaml +10 -0
- package/dist/patterns/library/os-cmd-elixir.yaml +16 -0
- package/dist/patterns/library/os-execute-lua.yaml +10 -0
- package/dist/patterns/library/path-traversal-go.yaml +11 -0
- package/dist/patterns/library/path-traversal-py.yaml +12 -0
- package/dist/patterns/library/path-traversal-readfile-js.yaml +14 -0
- package/dist/patterns/library/process-launch-swift.yaml +11 -0
- package/dist/patterns/library/process-run-dart.yaml +15 -0
- package/dist/patterns/library/prototype-pollution-js.yaml +12 -0
- package/dist/patterns/library/source-injection-bash.yaml +11 -0
- package/dist/patterns/library/sql-injection-concat-js.yaml +12 -0
- package/dist/patterns/library/sql-injection-dart.yaml +9 -0
- package/dist/patterns/library/sql-injection-java.yaml +13 -0
- package/dist/patterns/library/sql-injection-kotlin.yaml +11 -0
- package/dist/patterns/library/sql-injection-php.yaml +9 -0
- package/dist/patterns/library/sql-injection-py.yaml +12 -0
- package/dist/patterns/library/sql-injection-swift.yaml +11 -0
- package/dist/patterns/library/sql-injection-template-js.yaml +13 -0
- package/dist/patterns/library/subshell-injection-ruby.yaml +8 -0
- package/dist/patterns/library/unsafe-block-rust.yaml +8 -0
- package/dist/patterns/library/unsafe-string-c.yaml +11 -0
- package/dist/patterns/library/weak-crypto-md5-js.yaml +13 -0
- package/dist/patterns/library/weak-crypto-py.yaml +13 -0
- package/dist/patterns/loader.d.ts +18 -0
- package/dist/patterns/loader.d.ts.map +1 -0
- package/dist/patterns/loader.js +277 -0
- package/dist/patterns/loader.js.map +7 -0
- package/dist/patterns/runner.d.ts +42 -0
- package/dist/patterns/runner.d.ts.map +1 -0
- package/dist/patterns/runner.js +295 -0
- package/dist/patterns/runner.js.map +7 -0
- package/dist/patterns/types.d.ts +27 -0
- package/dist/patterns/types.d.ts.map +1 -0
- package/dist/patterns/types.js +34 -0
- package/dist/patterns/types.js.map +7 -0
- package/dist/resolution/bridges/android-rn.d.ts +13 -0
- package/dist/resolution/bridges/android-rn.d.ts.map +1 -0
- package/dist/resolution/bridges/expo-modules.d.ts +10 -0
- package/dist/resolution/bridges/expo-modules.d.ts.map +1 -0
- package/dist/resolution/bridges/flutter-channel.d.ts +14 -0
- package/dist/resolution/bridges/flutter-channel.d.ts.map +1 -0
- package/dist/resolution/bridges/index.d.ts +40 -0
- package/dist/resolution/bridges/index.d.ts.map +1 -0
- package/dist/resolution/bridges/native-events.d.ts +10 -0
- package/dist/resolution/bridges/native-events.d.ts.map +1 -0
- package/dist/resolution/bridges/native-views.d.ts +13 -0
- package/dist/resolution/bridges/native-views.d.ts.map +1 -0
- package/dist/resolution/bridges/react-native.d.ts +9 -0
- package/dist/resolution/bridges/react-native.d.ts.map +1 -0
- package/dist/resolution/bridges/swift-objc.d.ts +14 -0
- package/dist/resolution/bridges/swift-objc.d.ts.map +1 -0
- package/dist/resolution/bridges/turbomodules.d.ts +10 -0
- package/dist/resolution/bridges/turbomodules.d.ts.map +1 -0
- package/dist/resolution/index.d.ts +28 -3
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/security/attack-surface.d.ts +46 -0
- package/dist/security/attack-surface.d.ts.map +1 -0
- package/dist/security/attack-surface.js +43 -1
- package/dist/security/attack-surface.js.map +2 -2
- package/dist/security/context-warnings.d.ts +40 -0
- package/dist/security/context-warnings.d.ts.map +1 -0
- package/dist/security/data-flows.d.ts +33 -0
- package/dist/security/data-flows.d.ts.map +1 -0
- package/dist/security/data-flows.js +65 -7
- package/dist/security/data-flows.js.map +2 -2
- package/dist/security/dep-confusion.d.ts +23 -0
- package/dist/security/dep-confusion.d.ts.map +1 -0
- package/dist/security/errors.d.ts +16 -0
- package/dist/security/errors.d.ts.map +1 -0
- package/dist/security/export/fix-suggestions.d.ts +21 -0
- package/dist/security/export/fix-suggestions.d.ts.map +1 -0
- package/dist/security/export/sbom.d.ts +33 -0
- package/dist/security/export/sbom.d.ts.map +1 -0
- package/dist/security/export/serialization.d.ts +62 -0
- package/dist/security/export/serialization.d.ts.map +1 -0
- package/dist/security/export/vex.d.ts +58 -0
- package/dist/security/export/vex.d.ts.map +1 -0
- package/dist/security/index.d.ts +21 -0
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/integrator.d.ts +63 -0
- package/dist/security/integrator.d.ts.map +1 -0
- package/dist/security/integrator.js +8 -8
- package/dist/security/integrator.js.map +2 -2
- package/dist/security/license.d.ts +33 -0
- package/dist/security/license.d.ts.map +1 -0
- package/dist/security/manifest/adapter.d.ts +92 -0
- package/dist/security/manifest/adapter.d.ts.map +1 -0
- package/dist/security/manifest/parser.d.ts +73 -0
- package/dist/security/manifest/parser.d.ts.map +1 -0
- package/dist/security/manifest/plugins/cargo.d.ts +11 -0
- package/dist/security/manifest/plugins/cargo.d.ts.map +1 -0
- package/dist/security/manifest/plugins/composer.d.ts +11 -0
- package/dist/security/manifest/plugins/composer.d.ts.map +1 -0
- package/dist/security/manifest/plugins/go.d.ts +12 -0
- package/dist/security/manifest/plugins/go.d.ts.map +1 -0
- package/dist/security/manifest/plugins/gradle.d.ts +12 -0
- package/dist/security/manifest/plugins/gradle.d.ts.map +1 -0
- package/dist/security/manifest/plugins/hex.d.ts +11 -0
- package/dist/security/manifest/plugins/hex.d.ts.map +1 -0
- package/dist/security/manifest/plugins/maven.d.ts +11 -0
- package/dist/security/manifest/plugins/maven.d.ts.map +1 -0
- package/dist/security/manifest/plugins/npm.d.ts +11 -0
- package/dist/security/manifest/plugins/npm.d.ts.map +1 -0
- package/dist/security/manifest/plugins/nuget.d.ts +12 -0
- package/dist/security/manifest/plugins/nuget.d.ts.map +1 -0
- package/dist/security/manifest/plugins/pip.d.ts +11 -0
- package/dist/security/manifest/plugins/pip.d.ts.map +1 -0
- package/dist/security/manifest/plugins/pubspec.d.ts +11 -0
- package/dist/security/manifest/plugins/pubspec.d.ts.map +1 -0
- package/dist/security/manifest/plugins/pyproject.d.ts +3 -0
- package/dist/security/manifest/plugins/pyproject.d.ts.map +1 -0
- package/dist/security/manifest/plugins/rubygems.d.ts +11 -0
- package/dist/security/manifest/plugins/rubygems.d.ts.map +1 -0
- package/dist/security/manifest/plugins/swift.d.ts +11 -0
- package/dist/security/manifest/plugins/swift.d.ts.map +1 -0
- package/dist/security/owasp.d.ts +16 -0
- package/dist/security/owasp.d.ts.map +1 -0
- package/dist/security/pipeline.d.ts +37 -0
- package/dist/security/pipeline.d.ts.map +1 -0
- package/dist/security/reachability.d.ts +67 -0
- package/dist/security/reachability.d.ts.map +1 -0
- package/dist/security/remediation.d.ts +51 -0
- package/dist/security/remediation.d.ts.map +1 -0
- package/dist/security/secrets.d.ts +38 -0
- package/dist/security/secrets.d.ts.map +1 -0
- package/dist/security/staleness.d.ts +43 -0
- package/dist/security/staleness.d.ts.map +1 -0
- package/dist/security/supply-chain.d.ts +34 -0
- package/dist/security/supply-chain.d.ts.map +1 -0
- package/dist/security/suppressions.d.ts +18 -0
- package/dist/security/suppressions.d.ts.map +1 -0
- package/dist/security/types.d.ts +144 -0
- package/dist/security/types.d.ts.map +1 -0
- package/dist/security/vuln/client.d.ts +90 -0
- package/dist/security/vuln/client.d.ts.map +1 -0
- package/dist/security/vuln/client.js.map +2 -2
- package/dist/security/vuln/epss-client.d.ts +26 -0
- package/dist/security/vuln/epss-client.d.ts.map +1 -0
- package/dist/security/vuln/index.d.ts +6 -0
- package/dist/security/vuln/index.d.ts.map +1 -0
- package/dist/security/vuln/osv-adapter.d.ts +58 -0
- package/dist/security/vuln/osv-adapter.d.ts.map +1 -0
- package/dist/security/vuln/types.d.ts +29 -0
- package/dist/security/vuln/types.d.ts.map +1 -0
- package/dist/sync/index.d.ts +4 -2
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/types.d.ts +10 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +2 -2
- package/dist/vectors/index.d.ts +11 -3
- package/dist/vectors/index.d.ts.map +1 -1
- package/dist/vectors/qdrant-index.d.ts +10 -3
- package/dist/vectors/qdrant-index.d.ts.map +1 -1
- package/dist/vectors/turboquant-index.js +261 -0
- package/dist/vectors/turboquant-index.js.map +7 -0
- package/dist/vectors/typesense-index.d.ts.map +1 -1
- package/dist/watchmen/index.js +83 -0
- package/dist/watchmen/index.js.map +7 -0
- package/dist/watchmen/synthesize.js +475 -0
- package/dist/watchmen/synthesize.js.map +7 -0
- package/package.json +24 -2
- package/dist/security/context-warnings.test.js +0 -300
- package/dist/security/context-warnings.test.js.map +0 -7
- package/dist/security/export/fix-suggestions.test.js +0 -74
- package/dist/security/export/fix-suggestions.test.js.map +0 -7
- package/dist/security/export/sbom.test.js +0 -288
- package/dist/security/export/sbom.test.js.map +0 -7
- package/dist/security/export/serialization.test.js +0 -310
- package/dist/security/export/serialization.test.js.map +0 -7
- package/dist/security/export/vex.test.js +0 -278
- package/dist/security/export/vex.test.js.map +0 -7
- package/dist/security/integrator-transitives.test.js +0 -359
- package/dist/security/integrator-transitives.test.js.map +0 -7
- package/dist/security/integrator.test.js +0 -237
- package/dist/security/integrator.test.js.map +0 -7
- package/dist/security/manifest/adapter.test.js +0 -272
- package/dist/security/manifest/adapter.test.js.map +0 -7
- package/dist/security/manifest/parser.test.js +0 -110
- package/dist/security/manifest/parser.test.js.map +0 -7
- package/dist/security/manifest/plugins/cargo.test.js +0 -304
- package/dist/security/manifest/plugins/cargo.test.js.map +0 -7
- package/dist/security/manifest/plugins/go.test.js +0 -341
- package/dist/security/manifest/plugins/go.test.js.map +0 -7
- package/dist/security/manifest/plugins/maven.test.js +0 -389
- package/dist/security/manifest/plugins/maven.test.js.map +0 -7
- package/dist/security/manifest/plugins/npm.test.js +0 -298
- package/dist/security/manifest/plugins/npm.test.js.map +0 -7
- package/dist/security/manifest/plugins/pip.test.js +0 -208
- package/dist/security/manifest/plugins/pip.test.js.map +0 -7
- package/dist/security/reachability.test.js +0 -394
- package/dist/security/reachability.test.js.map +0 -7
- package/dist/security/vuln/client.test.js +0 -288
- package/dist/security/vuln/client.test.js.map +0 -7
- package/dist/security/vuln/osv-adapter.test.js +0 -391
- package/dist/security/vuln/osv-adapter.test.js.map +0 -7
|
@@ -0,0 +1,592 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var pattern_exports = {};
|
|
30
|
+
__export(pattern_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(pattern_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var import_config = require("../../config");
|
|
37
|
+
var import_ui = require("../ui");
|
|
38
|
+
const OWASP_CATEGORIES = {
|
|
39
|
+
A01: "Broken Access Control",
|
|
40
|
+
A02: "Cryptographic Failures",
|
|
41
|
+
A03: "Injection",
|
|
42
|
+
A04: "Insecure Design",
|
|
43
|
+
A05: "Security Misconfiguration",
|
|
44
|
+
A06: "Vulnerable Components",
|
|
45
|
+
A07: "Auth Failures",
|
|
46
|
+
A08: "Integrity Failures",
|
|
47
|
+
A09: "Logging Failures",
|
|
48
|
+
A10: "SSRF"
|
|
49
|
+
};
|
|
50
|
+
const SEVERITY_LEVELS = ["critical", "high", "medium", "low"];
|
|
51
|
+
const SEVERITY_ORDER = {
|
|
52
|
+
critical: 3,
|
|
53
|
+
high: 2,
|
|
54
|
+
medium: 1,
|
|
55
|
+
low: 0
|
|
56
|
+
};
|
|
57
|
+
function severityColor(severity) {
|
|
58
|
+
if (severity === "critical") return "\x1B[31m";
|
|
59
|
+
if (severity === "high") return "\x1B[31m";
|
|
60
|
+
if (severity === "medium") return "\x1B[33m";
|
|
61
|
+
return import_ui.dim;
|
|
62
|
+
}
|
|
63
|
+
function resolveLibraryPath() {
|
|
64
|
+
const devPath = path.join(__dirname, "../../patterns/library");
|
|
65
|
+
if (fs.existsSync(devPath)) return devPath;
|
|
66
|
+
const distPath = path.join(__dirname, "../patterns/library");
|
|
67
|
+
if (fs.existsSync(distPath)) return distPath;
|
|
68
|
+
return devPath;
|
|
69
|
+
}
|
|
70
|
+
function register(program) {
|
|
71
|
+
program.command("pattern [pattern] [projectPath]").description("AST structural search: live pattern search or library rule runner").option("--lang <language>", "Filter to a specific language (js, ts, python, go, rust, java, ...)").option("--severity <level>", "Filter: critical, high, medium, low").option("--format <fmt>", "Output format: text|json (default: text)", "text").option("--list", "Show all library rules (no @ast-grep/napi required)").option("--library <id>", "Run a specific library rule by ID").option("--fix", "Apply the rule's fix template to matched files (requires --library <id>)").option("--coverage", "Show OWASP Top 10 coverage report").option("--save-baseline [label]", "Save current pattern_matches as a baseline for diffing").option("--diff [label]", "Diff current pattern_matches against a saved baseline").action(async (patternArg, projectPathArg, opts) => {
|
|
72
|
+
const target = path.resolve(projectPathArg ?? process.cwd());
|
|
73
|
+
if (opts.list) {
|
|
74
|
+
const { PatternLibraryLoader } = await Promise.resolve().then(() => require("../../patterns/loader.js"));
|
|
75
|
+
const loader = new PatternLibraryLoader();
|
|
76
|
+
const config2 = await (0, import_config.loadConfig)(target).catch(() => null);
|
|
77
|
+
const libraryPath = resolveLibraryPath();
|
|
78
|
+
const customPath = config2?.patternLibraryPath;
|
|
79
|
+
const rules = loader.load(libraryPath, customPath);
|
|
80
|
+
if (opts.format === "json") {
|
|
81
|
+
process.stdout.write(JSON.stringify(rules, null, 2) + "\n");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (rules.length === 0) {
|
|
85
|
+
console.log(`
|
|
86
|
+
${import_ui.dim}No pattern rules found.${import_ui.reset}
|
|
87
|
+
`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
console.log(`
|
|
91
|
+
${(0, import_ui.section)("Pattern Library")} (${rules.length} rules)
|
|
92
|
+
`);
|
|
93
|
+
const maxSev = Math.max(...rules.map((r) => r.severity.length), 8);
|
|
94
|
+
const maxOWASP = Math.max(...rules.map((r) => r.owaspCategory.length), 5);
|
|
95
|
+
const maxId = Math.max(...rules.map((r) => r.id.length), 10);
|
|
96
|
+
for (const rule of rules) {
|
|
97
|
+
const sc = severityColor(rule.severity);
|
|
98
|
+
const sev = rule.severity.padEnd(maxSev);
|
|
99
|
+
const owasp = rule.owaspCategory.padEnd(maxOWASP);
|
|
100
|
+
const id = rule.id.padEnd(maxId);
|
|
101
|
+
console.log(` ${sc}${sev}${import_ui.reset} ${import_ui.dim}${owasp}${import_ui.reset} ${import_ui.violet}${import_ui.bold}${id}${import_ui.reset} ${import_ui.dim}${rule.description}${import_ui.reset}`);
|
|
102
|
+
}
|
|
103
|
+
console.log();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (opts.coverage) {
|
|
107
|
+
const { PatternLibraryLoader } = await Promise.resolve().then(() => require("../../patterns/loader.js"));
|
|
108
|
+
const loader = new PatternLibraryLoader();
|
|
109
|
+
const cfgCov = await (0, import_config.loadConfig)(target).catch(() => null);
|
|
110
|
+
const libraryPath = resolveLibraryPath();
|
|
111
|
+
const customPath = cfgCov?.patternLibraryPath;
|
|
112
|
+
const rules = loader.load(libraryPath, customPath);
|
|
113
|
+
const ruleCounts = {};
|
|
114
|
+
for (const cat of Object.keys(OWASP_CATEGORIES)) ruleCounts[cat] = 0;
|
|
115
|
+
for (const rule of rules) {
|
|
116
|
+
const cat = rule.owaspCategory.trim().split(/[\s-]/)[0].toUpperCase();
|
|
117
|
+
if (cat in ruleCounts) ruleCounts[cat]++;
|
|
118
|
+
}
|
|
119
|
+
let dbData = null;
|
|
120
|
+
const KiroGraphCov = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
121
|
+
if (cfgCov?.enablePatterns && KiroGraphCov.isInitialized(target)) {
|
|
122
|
+
try {
|
|
123
|
+
const cg2 = await KiroGraphCov.open(target);
|
|
124
|
+
const rawDb2 = cg2.getDatabase().getRawDb();
|
|
125
|
+
const tableExists = rawDb2.get(
|
|
126
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='pattern_matches'"
|
|
127
|
+
);
|
|
128
|
+
if (tableExists) {
|
|
129
|
+
const rows = rawDb2.all(
|
|
130
|
+
`SELECT owasp_category, COUNT(*) as matches, COUNT(DISTINCT file_path) as files
|
|
131
|
+
FROM pattern_matches
|
|
132
|
+
GROUP BY owasp_category`
|
|
133
|
+
);
|
|
134
|
+
dbData = {};
|
|
135
|
+
for (const row of rows) {
|
|
136
|
+
const cat = row.owasp_category.trim().split(/[\s-]/)[0].toUpperCase();
|
|
137
|
+
if (cat) dbData[cat] = { matches: row.matches, files: row.files };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
cg2.close();
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (opts.format === "json") {
|
|
145
|
+
const categories = {};
|
|
146
|
+
for (const cat of Object.keys(OWASP_CATEGORIES)) {
|
|
147
|
+
categories[cat] = {
|
|
148
|
+
rules: ruleCounts[cat] ?? 0,
|
|
149
|
+
matches: dbData ? dbData[cat]?.matches ?? 0 : null,
|
|
150
|
+
files: dbData ? dbData[cat]?.files ?? 0 : null
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const covered2 = Object.values(categories).filter((c) => c.rules > 0).length;
|
|
154
|
+
process.stdout.write(JSON.stringify({ categories, covered: covered2, total: 10 }, null, 2) + "\n");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const BAR_WIDTH = 10;
|
|
158
|
+
const sorted = Object.keys(OWASP_CATEGORIES).sort((a, b) => (ruleCounts[b] ?? 0) - (ruleCounts[a] ?? 0));
|
|
159
|
+
const maxNameLen = Math.max(...Object.values(OWASP_CATEGORIES).map((n) => n.length));
|
|
160
|
+
const isInitialized = KiroGraphCov.isInitialized(target);
|
|
161
|
+
const hasEnablePatterns = !!cfgCov?.enablePatterns;
|
|
162
|
+
let coverageSubtitle;
|
|
163
|
+
if (!isInitialized || !hasEnablePatterns) {
|
|
164
|
+
coverageSubtitle = ` ${import_ui.dim}(rules only \u2014 no match data)${import_ui.reset}`;
|
|
165
|
+
} else if (!dbData) {
|
|
166
|
+
coverageSubtitle = ` ${import_ui.dim}(no match data yet \u2014 run kirograph index)${import_ui.reset}`;
|
|
167
|
+
} else {
|
|
168
|
+
coverageSubtitle = "";
|
|
169
|
+
}
|
|
170
|
+
console.log(`
|
|
171
|
+
${(0, import_ui.section)("OWASP Top 10 Coverage")}${coverageSubtitle}`);
|
|
172
|
+
if (!isInitialized || !hasEnablePatterns) {
|
|
173
|
+
console.log(` ${import_ui.dim}Run kirograph index with enablePatterns: true to see actual findings.${import_ui.reset}`);
|
|
174
|
+
}
|
|
175
|
+
console.log();
|
|
176
|
+
for (const cat of sorted) {
|
|
177
|
+
const name = OWASP_CATEGORIES[cat];
|
|
178
|
+
const count = ruleCounts[cat] ?? 0;
|
|
179
|
+
const filledBars = Math.min(count, BAR_WIDTH);
|
|
180
|
+
const bar = count > 0 ? `${import_ui.violet}${"\u2588".repeat(filledBars)}${import_ui.dim}${"\u2591".repeat(BAR_WIDTH - filledBars)}${import_ui.reset}` : `${import_ui.dim}${"\u2591".repeat(BAR_WIDTH)}${import_ui.reset}`;
|
|
181
|
+
const catLabel = count > 0 ? `${import_ui.violet}${import_ui.bold}${cat}${import_ui.reset}` : `\x1B[31m${cat}${import_ui.reset}`;
|
|
182
|
+
const nameStr = name.padEnd(maxNameLen);
|
|
183
|
+
const ruleStr = count === 1 ? "1 rule " : `${count} rules`;
|
|
184
|
+
const ruleLabel = count > 0 ? `${import_ui.violet}${import_ui.bold}${ruleStr}${import_ui.reset}` : `${import_ui.dim}${ruleStr}${import_ui.reset}`;
|
|
185
|
+
if (count === 0) {
|
|
186
|
+
console.log(` ${catLabel} ${import_ui.dim}${nameStr}${import_ui.reset} ${bar} ${import_ui.dim}${ruleStr} \xB7 \u2014 no coverage${import_ui.reset}`);
|
|
187
|
+
} else if (dbData) {
|
|
188
|
+
const m = dbData[cat]?.matches ?? 0;
|
|
189
|
+
const f = dbData[cat]?.files ?? 0;
|
|
190
|
+
console.log(` ${catLabel} ${import_ui.dim}${nameStr}${import_ui.reset} ${bar} ${ruleLabel} \xB7 ${import_ui.violet}${m} match${m !== 1 ? "es" : ""}${import_ui.reset} ${import_ui.dim}\xB7 ${f} file${f !== 1 ? "s" : ""}${import_ui.reset}`);
|
|
191
|
+
} else {
|
|
192
|
+
console.log(` ${catLabel} ${import_ui.dim}${nameStr}${import_ui.reset} ${bar} ${ruleLabel}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const covered = Object.values(ruleCounts).filter((n) => n > 0).length;
|
|
196
|
+
console.log();
|
|
197
|
+
console.log(` ${import_ui.dim}Coverage: ${import_ui.reset}${import_ui.violet}${import_ui.bold}${covered}/10${import_ui.reset}${import_ui.dim} OWASP categories have at least one rule.${import_ui.reset}`);
|
|
198
|
+
if (covered < 10) {
|
|
199
|
+
console.log(` ${import_ui.dim}Add custom rules via patternLibraryPath to improve coverage.${import_ui.reset}`);
|
|
200
|
+
}
|
|
201
|
+
console.log();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
if (opts.saveBaseline !== void 0) {
|
|
205
|
+
const KiroGraphSB = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
206
|
+
if (!KiroGraphSB.isInitialized(target)) {
|
|
207
|
+
console.error(`
|
|
208
|
+
\x1B[31m\u2716 KiroGraph not initialized. Run: kirograph init${import_ui.reset}
|
|
209
|
+
`);
|
|
210
|
+
process.exit(1);
|
|
211
|
+
}
|
|
212
|
+
const configSB = await (0, import_config.loadConfig)(target).catch(() => null);
|
|
213
|
+
if (!configSB?.enablePatterns) {
|
|
214
|
+
console.error(`
|
|
215
|
+
\x1B[33m\u26A0 kirograph pattern --save-baseline requires enablePatterns: true.${import_ui.reset}`);
|
|
216
|
+
console.error(` ${import_ui.dim}Enable it in .kirograph/config.json:${import_ui.reset} ${import_ui.violet}${import_ui.bold}"enablePatterns": true${import_ui.reset}`);
|
|
217
|
+
console.error(` ${import_ui.dim}Then re-run:${import_ui.reset} ${import_ui.violet}${import_ui.bold}kirograph index${import_ui.reset}
|
|
218
|
+
`);
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
|
221
|
+
const sbLabel = typeof opts.saveBaseline === "string" && opts.saveBaseline ? opts.saveBaseline : "default";
|
|
222
|
+
const cg2 = await KiroGraphSB.open(target);
|
|
223
|
+
const rawDb2 = cg2.getDatabase().getRawDb();
|
|
224
|
+
const tableExists = rawDb2.get(
|
|
225
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='pattern_matches'"
|
|
226
|
+
);
|
|
227
|
+
if (!tableExists) {
|
|
228
|
+
cg2.close();
|
|
229
|
+
console.error(`
|
|
230
|
+
\x1B[31m\u2716 pattern_matches table not found. Run: kirograph index with enablePatterns: true${import_ui.reset}
|
|
231
|
+
`);
|
|
232
|
+
process.exit(1);
|
|
233
|
+
}
|
|
234
|
+
const rows = rawDb2.all(
|
|
235
|
+
"SELECT pattern_id, COUNT(*) as cnt FROM pattern_matches GROUP BY pattern_id"
|
|
236
|
+
);
|
|
237
|
+
const counts = {};
|
|
238
|
+
let totalMatches = 0;
|
|
239
|
+
for (const row of rows) {
|
|
240
|
+
counts[row.pattern_id] = row.cnt;
|
|
241
|
+
totalMatches += row.cnt;
|
|
242
|
+
}
|
|
243
|
+
cg2.close();
|
|
244
|
+
const kirographDir = path.join(target, ".kirograph");
|
|
245
|
+
const baselineFile = path.join(kirographDir, `pattern-baseline-${sbLabel}.json`);
|
|
246
|
+
const data = { savedAt: (/* @__PURE__ */ new Date()).toISOString(), counts, totalMatches };
|
|
247
|
+
fs.writeFileSync(baselineFile, JSON.stringify(data, null, 2), "utf8");
|
|
248
|
+
console.log(`
|
|
249
|
+
\x1B[32m\u2713${import_ui.reset} Baseline saved: ${import_ui.violet}${import_ui.bold}${sbLabel}${import_ui.reset}`);
|
|
250
|
+
console.log(` ${import_ui.dim}${totalMatches} total matches across ${Object.keys(counts).length} patterns${import_ui.reset}`);
|
|
251
|
+
console.log(` ${import_ui.dim}Saved to: ${baselineFile}${import_ui.reset}
|
|
252
|
+
`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (opts.diff !== void 0) {
|
|
256
|
+
const KiroGraphDiff = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
257
|
+
if (!KiroGraphDiff.isInitialized(target)) {
|
|
258
|
+
console.error(`
|
|
259
|
+
\x1B[31m\u2716 KiroGraph not initialized. Run: kirograph init${import_ui.reset}
|
|
260
|
+
`);
|
|
261
|
+
process.exit(1);
|
|
262
|
+
}
|
|
263
|
+
const configDiff = await (0, import_config.loadConfig)(target).catch(() => null);
|
|
264
|
+
if (!configDiff?.enablePatterns) {
|
|
265
|
+
console.error(`
|
|
266
|
+
\x1B[33m\u26A0 kirograph pattern --diff requires enablePatterns: true.${import_ui.reset}`);
|
|
267
|
+
console.error(` ${import_ui.dim}Enable it in .kirograph/config.json:${import_ui.reset} ${import_ui.violet}${import_ui.bold}"enablePatterns": true${import_ui.reset}`);
|
|
268
|
+
console.error(` ${import_ui.dim}Then re-run:${import_ui.reset} ${import_ui.violet}${import_ui.bold}kirograph index${import_ui.reset}
|
|
269
|
+
`);
|
|
270
|
+
process.exit(1);
|
|
271
|
+
}
|
|
272
|
+
const diffLabel = typeof opts.diff === "string" && opts.diff ? opts.diff : "default";
|
|
273
|
+
const kirographDir = path.join(target, ".kirograph");
|
|
274
|
+
const baselineFile = path.join(kirographDir, `pattern-baseline-${diffLabel}.json`);
|
|
275
|
+
if (!fs.existsSync(baselineFile)) {
|
|
276
|
+
const saveCmd = diffLabel !== "default" ? `kirograph pattern --save-baseline ${diffLabel}` : "kirograph pattern --save-baseline";
|
|
277
|
+
console.log(`
|
|
278
|
+
${import_ui.dim}No baseline found. Run: ${import_ui.reset}${import_ui.violet}${import_ui.bold}${saveCmd}${import_ui.reset}
|
|
279
|
+
`);
|
|
280
|
+
process.exit(0);
|
|
281
|
+
}
|
|
282
|
+
const baseline = JSON.parse(fs.readFileSync(baselineFile, "utf8"));
|
|
283
|
+
const cg2 = await KiroGraphDiff.open(target);
|
|
284
|
+
const rawDb2 = cg2.getDatabase().getRawDb();
|
|
285
|
+
const tableExists = rawDb2.get(
|
|
286
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name='pattern_matches'"
|
|
287
|
+
);
|
|
288
|
+
const currentRows = tableExists ? rawDb2.all("SELECT pattern_id, COUNT(*) as cnt FROM pattern_matches GROUP BY pattern_id") : [];
|
|
289
|
+
cg2.close();
|
|
290
|
+
const current = {};
|
|
291
|
+
for (const row of currentRows) current[row.pattern_id] = row.cnt;
|
|
292
|
+
const allKeys = /* @__PURE__ */ new Set([...Object.keys(baseline.counts), ...Object.keys(current)]);
|
|
293
|
+
const newFindings = [];
|
|
294
|
+
const resolved = [];
|
|
295
|
+
const unchanged = [];
|
|
296
|
+
for (const id of allKeys) {
|
|
297
|
+
const base = baseline.counts[id] ?? 0;
|
|
298
|
+
const curr = current[id] ?? 0;
|
|
299
|
+
const delta = curr - base;
|
|
300
|
+
if (delta > 0) newFindings.push({ id, baseCount: base, currCount: curr, delta });
|
|
301
|
+
else if (delta < 0) resolved.push({ id, baseCount: base, currCount: curr, delta });
|
|
302
|
+
else if (curr > 0) unchanged.push({ id, baseCount: base, currCount: curr, delta });
|
|
303
|
+
}
|
|
304
|
+
newFindings.sort((a, b) => b.delta - a.delta);
|
|
305
|
+
resolved.sort((a, b) => a.delta - b.delta);
|
|
306
|
+
const savedDate = baseline.savedAt.slice(0, 10);
|
|
307
|
+
const netDelta = newFindings.reduce((s, e) => s + e.delta, 0) + resolved.reduce((s, e) => s + e.delta, 0);
|
|
308
|
+
if (opts.format === "json") {
|
|
309
|
+
process.stdout.write(JSON.stringify({
|
|
310
|
+
baseline: { label: diffLabel, savedAt: baseline.savedAt, totalMatches: baseline.totalMatches },
|
|
311
|
+
new: newFindings.map((e) => ({ id: e.id, delta: e.delta, current: e.currCount })),
|
|
312
|
+
resolved: resolved.map((e) => ({ id: e.id, delta: e.delta, current: e.currCount })),
|
|
313
|
+
unchanged: unchanged.map((e) => ({ id: e.id, count: e.currCount })),
|
|
314
|
+
netDelta
|
|
315
|
+
}, null, 2) + "\n");
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
const allEntries = [...newFindings, ...resolved, ...unchanged];
|
|
319
|
+
const maxIdLen = allEntries.length > 0 ? Math.max(...allEntries.map((e) => e.id.length), 20) : 20;
|
|
320
|
+
console.log(`
|
|
321
|
+
${(0, import_ui.section)("Pattern Diff")} ${import_ui.dim}vs ${diffLabel} baseline (saved ${savedDate})${import_ui.reset}
|
|
322
|
+
`);
|
|
323
|
+
if (newFindings.length > 0) {
|
|
324
|
+
console.log(` \x1B[31m\u2716 NEW${import_ui.reset} ${import_ui.dim}(${newFindings.length} new finding${newFindings.length !== 1 ? "s" : ""})${import_ui.reset}`);
|
|
325
|
+
for (const e of newFindings) {
|
|
326
|
+
const idPad = e.id.padEnd(maxIdLen);
|
|
327
|
+
console.log(` ${import_ui.violet}${import_ui.bold}${idPad}${import_ui.reset} \x1B[31m+${e.delta} new match${e.delta !== 1 ? "es" : ""}${import_ui.reset}`);
|
|
328
|
+
}
|
|
329
|
+
console.log();
|
|
330
|
+
}
|
|
331
|
+
if (resolved.length > 0) {
|
|
332
|
+
console.log(` \x1B[32m\u2713 RESOLVED${import_ui.reset} ${import_ui.dim}(${resolved.length} resolved)${import_ui.reset}`);
|
|
333
|
+
for (const e of resolved) {
|
|
334
|
+
const idPad = e.id.padEnd(maxIdLen);
|
|
335
|
+
console.log(` ${import_ui.dim}${idPad}${import_ui.reset} \x1B[32m${e.delta} match${Math.abs(e.delta) !== 1 ? "es" : ""}${import_ui.reset}`);
|
|
336
|
+
}
|
|
337
|
+
console.log();
|
|
338
|
+
}
|
|
339
|
+
if (unchanged.length > 0) {
|
|
340
|
+
console.log(` ${import_ui.dim}= UNCHANGED${import_ui.reset}`);
|
|
341
|
+
for (const e of unchanged) {
|
|
342
|
+
const idPad = e.id.padEnd(maxIdLen);
|
|
343
|
+
console.log(` ${import_ui.dim}${idPad} ${e.currCount} match${e.currCount !== 1 ? "es" : ""} (no change)${import_ui.reset}`);
|
|
344
|
+
}
|
|
345
|
+
console.log();
|
|
346
|
+
}
|
|
347
|
+
if (allEntries.length === 0) {
|
|
348
|
+
console.log(` ${import_ui.dim}No pattern matches found in either baseline or current index.${import_ui.reset}
|
|
349
|
+
`);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const netLabel = netDelta > 0 ? `\x1B[31m+${netDelta}${import_ui.reset}` : netDelta < 0 ? `\x1B[32m${netDelta}${import_ui.reset}` : `${import_ui.dim}0${import_ui.reset}`;
|
|
353
|
+
console.log(` ${import_ui.dim}Net:${import_ui.reset} ${netLabel}${import_ui.dim} findings since baseline${import_ui.reset}
|
|
354
|
+
`);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
if (opts.fix && !opts.library) {
|
|
358
|
+
console.error(` ${"\x1B[31m"}\u2716 --fix requires --library <id>. Inline patterns do not support automatic fixes.${import_ui.reset}`);
|
|
359
|
+
process.exit(1);
|
|
360
|
+
}
|
|
361
|
+
const config = await (0, import_config.loadConfig)(target);
|
|
362
|
+
if (!config.enablePatterns) {
|
|
363
|
+
console.error(`
|
|
364
|
+
${"\x1B[31m"}\u2716 kirograph pattern requires enablePatterns: true in .kirograph/config.json${import_ui.reset}`);
|
|
365
|
+
console.error(` ${import_ui.dim}Enable it:${import_ui.reset} ${import_ui.violet}${import_ui.bold}"enablePatterns": true${import_ui.reset}`);
|
|
366
|
+
console.error(` ${import_ui.dim}Then install:${import_ui.reset} ${import_ui.violet}${import_ui.bold}npm install @ast-grep/napi${import_ui.reset}`);
|
|
367
|
+
console.error(` ${import_ui.dim}Then re-index:${import_ui.reset} ${import_ui.violet}${import_ui.bold}kirograph index${import_ui.reset}
|
|
368
|
+
`);
|
|
369
|
+
process.exit(2);
|
|
370
|
+
}
|
|
371
|
+
const { PatternRunner } = await Promise.resolve().then(() => require("../../patterns/runner.js"));
|
|
372
|
+
const runner = new PatternRunner();
|
|
373
|
+
if (!runner.isAvailable()) {
|
|
374
|
+
console.error(`
|
|
375
|
+
${"\x1B[31m"}\u2716 kirograph pattern requires @ast-grep/napi${import_ui.reset}`);
|
|
376
|
+
console.error(` ${import_ui.dim}Install it with:${import_ui.reset} ${import_ui.violet}${import_ui.bold}npm install @ast-grep/napi${import_ui.reset}
|
|
377
|
+
`);
|
|
378
|
+
process.exit(2);
|
|
379
|
+
}
|
|
380
|
+
if (!opts.library && patternArg) {
|
|
381
|
+
const { PatternLibraryLoader: AutoLoader } = await Promise.resolve().then(() => require("../../patterns/loader.js"));
|
|
382
|
+
const autoRules = new AutoLoader().load(resolveLibraryPath(), config.patternLibraryPath);
|
|
383
|
+
if (autoRules.some((r) => r.id === patternArg)) {
|
|
384
|
+
console.log(` ${import_ui.dim}Tip: '${patternArg}' is a library rule. Running as --library ${patternArg}${import_ui.reset}`);
|
|
385
|
+
opts.library = patternArg;
|
|
386
|
+
patternArg = void 0;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (opts.library) {
|
|
390
|
+
if (!require("../../index").default.isInitialized(target)) {
|
|
391
|
+
console.error(" \u2716 KiroGraph not initialized. Run: kirograph init");
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
const KiroGraph2 = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
395
|
+
const cg2 = await KiroGraph2.open(target);
|
|
396
|
+
const db2 = cg2.getDatabase();
|
|
397
|
+
const rawDb2 = db2.getRawDb();
|
|
398
|
+
const { PatternLibraryLoader } = await Promise.resolve().then(() => require("../../patterns/loader.js"));
|
|
399
|
+
const loader = new PatternLibraryLoader();
|
|
400
|
+
const libraryPath = resolveLibraryPath();
|
|
401
|
+
const customPath = config.patternLibraryPath;
|
|
402
|
+
const rules = loader.load(libraryPath, customPath);
|
|
403
|
+
const rule = rules.find((r) => r.id === opts.library);
|
|
404
|
+
if (!rule) {
|
|
405
|
+
console.error(` \u2716 Rule "${opts.library}" not found. Run: kirograph pattern --list`);
|
|
406
|
+
cg2.close();
|
|
407
|
+
process.exitCode = 1;
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
const langs = Array.isArray(rule.language) ? rule.language : [rule.language];
|
|
411
|
+
const placeholders = langs.map(() => "?").join(", ");
|
|
412
|
+
const files2 = rawDb2.all(
|
|
413
|
+
`SELECT path, language FROM files WHERE language IN (${placeholders}) LIMIT 5000`,
|
|
414
|
+
langs
|
|
415
|
+
);
|
|
416
|
+
const allMatches2 = [];
|
|
417
|
+
if (opts.fix) {
|
|
418
|
+
const { PatternRunner: FixPatternRunner } = await Promise.resolve().then(() => require("../../patterns/runner.js"));
|
|
419
|
+
const fixRunner = new FixPatternRunner();
|
|
420
|
+
if (!fixRunner.isAvailable()) {
|
|
421
|
+
console.error(` \x1B[31m\u2716 --fix requires @ast-grep/napi. Run: npm install @ast-grep/napi${import_ui.reset}`);
|
|
422
|
+
cg2.close?.();
|
|
423
|
+
process.exitCode = 2;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (!rule.fix) {
|
|
427
|
+
console.error(` ${"\x1B[31m"}\u2716 Rule "${rule.id}" does not have a fix: template defined.${import_ui.reset}`);
|
|
428
|
+
cg2.close();
|
|
429
|
+
process.exitCode = 1;
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
let fixedFiles = 0;
|
|
433
|
+
let totalChanges = 0;
|
|
434
|
+
for (const file of files2) {
|
|
435
|
+
let content;
|
|
436
|
+
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(target, file.path);
|
|
437
|
+
try {
|
|
438
|
+
content = fs.readFileSync(fullPath, "utf8");
|
|
439
|
+
} catch {
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
const matchesBefore = await fixRunner.runRule(rule, content, file.language);
|
|
443
|
+
if (matchesBefore.length === 0) continue;
|
|
444
|
+
const fixed = await fixRunner.applyFix(fullPath, content, file.language, rule);
|
|
445
|
+
if (fixed !== null && fixed !== content) {
|
|
446
|
+
fs.writeFileSync(fullPath, fixed, "utf8");
|
|
447
|
+
const relPath = path.relative(target, fullPath);
|
|
448
|
+
console.log(` \x1B[32m\u2713 Fixed\x1B[0m ${relPath} (${matchesBefore.length} change${matchesBefore.length !== 1 ? "s" : ""})`);
|
|
449
|
+
fixedFiles++;
|
|
450
|
+
totalChanges += matchesBefore.length;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
cg2.close();
|
|
454
|
+
console.log(`
|
|
455
|
+
Fixed ${fixedFiles} file${fixedFiles !== 1 ? "s" : ""}, ${totalChanges} total change${totalChanges !== 1 ? "s" : ""}
|
|
456
|
+
`);
|
|
457
|
+
process.exitCode = 0;
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
for (const file of files2) {
|
|
461
|
+
let content;
|
|
462
|
+
try {
|
|
463
|
+
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(target, file.path);
|
|
464
|
+
content = fs.readFileSync(fullPath, "utf8");
|
|
465
|
+
} catch {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
const matches = await runner.runRule(rule, content, file.language);
|
|
469
|
+
for (const m of matches) {
|
|
470
|
+
allMatches2.push({ filePath: file.path, line: m.line, matchText: m.matchText, context: m.context });
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
cg2.close();
|
|
474
|
+
const sev = opts.severity;
|
|
475
|
+
if (sev && SEVERITY_LEVELS.includes(sev)) {
|
|
476
|
+
if (SEVERITY_ORDER[rule.severity] < SEVERITY_ORDER[sev]) {
|
|
477
|
+
if (opts.format === "json") {
|
|
478
|
+
process.stdout.write(JSON.stringify([], null, 2) + "\n");
|
|
479
|
+
} else {
|
|
480
|
+
console.log(`
|
|
481
|
+
${import_ui.dim}No matches (rule severity "${rule.severity}" is below filter "${sev}").${import_ui.reset}
|
|
482
|
+
`);
|
|
483
|
+
}
|
|
484
|
+
process.exitCode = 0;
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (opts.format === "json") {
|
|
489
|
+
process.stdout.write(JSON.stringify(allMatches2.map((m) => ({
|
|
490
|
+
filePath: m.filePath,
|
|
491
|
+
line: m.line,
|
|
492
|
+
matchText: m.matchText,
|
|
493
|
+
rule: { id: rule.id, severity: rule.severity, owaspCategory: rule.owaspCategory, description: rule.description, fixHint: rule.fixHint }
|
|
494
|
+
})), null, 2) + "\n");
|
|
495
|
+
process.exitCode = allMatches2.length > 0 ? 1 : 0;
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
498
|
+
if (allMatches2.length === 0) {
|
|
499
|
+
console.log(`
|
|
500
|
+
${import_ui.dim}No matches for library rule '${rule.id}'.${import_ui.reset}
|
|
501
|
+
`);
|
|
502
|
+
process.exitCode = 0;
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
const sc = severityColor(rule.severity);
|
|
506
|
+
console.log(`
|
|
507
|
+
${(0, import_ui.section)(rule.description)}`);
|
|
508
|
+
console.log(` ${import_ui.dim}Rule:${import_ui.reset} ${import_ui.violet}${import_ui.bold}${rule.id}${import_ui.reset} ${sc}${rule.severity}${import_ui.reset} ${import_ui.dim}[${rule.owaspCategory}]${import_ui.reset}`);
|
|
509
|
+
console.log(` ${import_ui.dim}Fix:${import_ui.reset} ${rule.fixHint}`);
|
|
510
|
+
console.log(`
|
|
511
|
+
${allMatches2.length} match${allMatches2.length !== 1 ? "es" : ""}
|
|
512
|
+
`);
|
|
513
|
+
for (const m of allMatches2) {
|
|
514
|
+
const relPath = path.relative(target, path.isAbsolute(m.filePath) ? m.filePath : path.join(target, m.filePath));
|
|
515
|
+
console.log(` ${import_ui.violet}${import_ui.bold}${relPath}:${m.line}${import_ui.reset}`);
|
|
516
|
+
console.log(` ${import_ui.dim}${m.matchText}${import_ui.reset}`);
|
|
517
|
+
console.log(` ${"\u2500".repeat(17)}`);
|
|
518
|
+
}
|
|
519
|
+
console.log();
|
|
520
|
+
process.exitCode = 1;
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (!patternArg) {
|
|
524
|
+
console.error(" \u2716 Provide a pattern to search, or use --list / --library <id>");
|
|
525
|
+
process.exit(1);
|
|
526
|
+
}
|
|
527
|
+
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
528
|
+
if (!KiroGraph.isInitialized(target)) {
|
|
529
|
+
console.error(" \u2716 KiroGraph not initialized. Run: kirograph init");
|
|
530
|
+
process.exit(1);
|
|
531
|
+
}
|
|
532
|
+
const cg = await KiroGraph.open(target);
|
|
533
|
+
const db = cg.getDatabase();
|
|
534
|
+
const rawDb = db.getRawDb();
|
|
535
|
+
let files;
|
|
536
|
+
if (opts.lang) {
|
|
537
|
+
files = rawDb.all(
|
|
538
|
+
"SELECT path, language FROM files WHERE language = ? LIMIT 5000",
|
|
539
|
+
[opts.lang]
|
|
540
|
+
);
|
|
541
|
+
} else {
|
|
542
|
+
files = rawDb.all("SELECT path, language FROM files LIMIT 5000");
|
|
543
|
+
}
|
|
544
|
+
const allMatches = [];
|
|
545
|
+
for (const file of files) {
|
|
546
|
+
let content;
|
|
547
|
+
try {
|
|
548
|
+
const fullPath = path.isAbsolute(file.path) ? file.path : path.join(target, file.path);
|
|
549
|
+
content = fs.readFileSync(fullPath, "utf8");
|
|
550
|
+
} catch {
|
|
551
|
+
continue;
|
|
552
|
+
}
|
|
553
|
+
const matches = await runner.runInline(patternArg, file.language, content);
|
|
554
|
+
for (const m of matches) {
|
|
555
|
+
allMatches.push({ filePath: file.path, line: m.line, matchText: m.matchText, context: m.context, language: file.language });
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
cg.close();
|
|
559
|
+
if (opts.format === "json") {
|
|
560
|
+
process.stdout.write(JSON.stringify(allMatches.map((m) => ({
|
|
561
|
+
filePath: m.filePath,
|
|
562
|
+
line: m.line,
|
|
563
|
+
matchText: m.matchText,
|
|
564
|
+
language: m.language
|
|
565
|
+
})), null, 2) + "\n");
|
|
566
|
+
process.exitCode = allMatches.length > 0 ? 1 : 0;
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
const langLabel = opts.lang ? ` in ${opts.lang} files` : "";
|
|
570
|
+
console.log(`
|
|
571
|
+
${allMatches.length} match${allMatches.length !== 1 ? "es" : ""} for ${import_ui.violet}${import_ui.bold}'${patternArg}'${import_ui.reset}${langLabel}
|
|
572
|
+
`);
|
|
573
|
+
if (allMatches.length === 0) {
|
|
574
|
+
process.exitCode = 0;
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
for (const m of allMatches) {
|
|
578
|
+
const relPath = path.relative(target, path.isAbsolute(m.filePath) ? m.filePath : path.join(target, m.filePath));
|
|
579
|
+
console.log(` ${import_ui.violet}${import_ui.bold}${relPath}:${m.line}${import_ui.reset}`);
|
|
580
|
+
console.log(` ${import_ui.dim}${m.matchText}${import_ui.reset}`);
|
|
581
|
+
console.log(` ${"\u2500".repeat(17)}`);
|
|
582
|
+
}
|
|
583
|
+
console.log();
|
|
584
|
+
process.exitCode = 1;
|
|
585
|
+
return;
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
589
|
+
0 && (module.exports = {
|
|
590
|
+
register
|
|
591
|
+
});
|
|
592
|
+
//# sourceMappingURL=pattern.js.map
|