@feiyoug/skill-lab 0.0.0 → 0.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/README.md +73 -0
- package/esm/analyzer/astgrep/client.d.ts +20 -8
- package/esm/analyzer/astgrep/client.d.ts.map +1 -1
- package/esm/analyzer/astgrep/client.js +58 -31
- package/esm/analyzer/config/default.d.ts +8 -0
- package/esm/analyzer/config/default.d.ts.map +1 -0
- package/esm/analyzer/config/default.js +91 -0
- package/esm/analyzer/config/helpers.d.ts +8 -0
- package/esm/analyzer/config/helpers.d.ts.map +1 -0
- package/esm/analyzer/config/helpers.js +72 -0
- package/esm/analyzer/config/mod.d.ts +4 -0
- package/esm/analyzer/config/mod.d.ts.map +1 -0
- package/esm/analyzer/config/mod.js +3 -0
- package/esm/analyzer/config/types.d.ts +58 -0
- package/esm/analyzer/config/types.d.ts.map +1 -0
- package/esm/analyzer/{config.js → config/types.js} +0 -28
- package/esm/analyzer/logging.d.ts +3 -0
- package/esm/analyzer/logging.d.ts.map +1 -0
- package/esm/analyzer/logging.js +6 -0
- package/esm/analyzer/mod.d.ts +12 -5
- package/esm/analyzer/mod.d.ts.map +1 -1
- package/esm/analyzer/mod.js +25 -12
- package/esm/analyzer/result.d.ts +35 -0
- package/esm/analyzer/result.d.ts.map +1 -0
- package/esm/analyzer/result.js +311 -0
- package/esm/analyzer/rules/bash/commands/mod.d.ts +1 -0
- package/esm/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/commands/mod.js +3 -0
- package/esm/analyzer/rules/bash/commands/pip.d.ts +3 -0
- package/esm/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
- package/esm/analyzer/rules/bash/commands/pip.js +14 -0
- package/esm/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
- package/esm/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/extractFileRefs.js +2 -2
- package/esm/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
- package/esm/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/inline-command-classifier.js +4 -4
- package/esm/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
- package/esm/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/javascript/extractFileRefs.js +3 -4
- package/esm/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
- package/esm/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
- package/esm/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/markdown/extractFileRefs.js +2 -0
- package/esm/analyzer/rules/python/extractFileRefs.d.ts +1 -1
- package/esm/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/python/extractFileRefs.js +2 -2
- package/esm/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
- package/esm/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
- package/esm/analyzer/steps/001-discovery/discover-files.js +18 -2
- package/esm/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/001-discovery/mod.js +39 -9
- package/esm/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/002-permissions/mod.js +156 -73
- package/esm/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
- package/esm/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
- package/esm/analyzer/steps/002-permissions/scan-file.js +40 -5
- package/esm/analyzer/steps/002-permissions/seed-frontmatter.js +2 -2
- package/esm/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
- package/esm/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
- package/esm/analyzer/steps/003-risks/dep-risks.js +74 -0
- package/esm/analyzer/steps/003-risks/helpers.d.ts +1 -0
- package/esm/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/helpers.js +1 -0
- package/esm/analyzer/steps/003-risks/mod.d.ts +3 -2
- package/esm/analyzer/steps/003-risks/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/mod.js +41 -4
- package/esm/analyzer/steps/003-risks/policy.d.ts +7 -0
- package/esm/analyzer/steps/003-risks/policy.d.ts.map +1 -0
- package/esm/analyzer/steps/003-risks/policy.js +23 -0
- package/esm/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
- package/esm/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/rule-mapped.js +83 -2
- package/esm/analyzer/steps/003-risks/scoring.d.ts +9 -1
- package/esm/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/scoring.js +55 -42
- package/esm/analyzer/treesitter/client.d.ts +31 -0
- package/esm/analyzer/treesitter/client.d.ts.map +1 -0
- package/esm/analyzer/{treesiter → treesitter}/client.js +43 -39
- package/esm/analyzer/treesitter/registry.d.ts +73 -0
- package/esm/analyzer/treesitter/registry.d.ts.map +1 -0
- package/esm/analyzer/treesitter/registry.js +165 -0
- package/esm/analyzer/types.d.ts +14 -28
- package/esm/analyzer/types.d.ts.map +1 -1
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +3 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +297 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +268 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.js +45 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.js +903 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.js +15 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.js +61 -0
- package/esm/shared/deep_merge.d.ts +12 -0
- package/esm/shared/deep_merge.d.ts.map +1 -0
- package/esm/shared/deep_merge.js +49 -0
- package/esm/shared/mod.d.ts +1 -0
- package/esm/shared/mod.d.ts.map +1 -1
- package/esm/shared/mod.js +1 -0
- package/esm/shared/types/filetypes.d.ts +2 -2
- package/esm/shared/types/filetypes.d.ts.map +1 -1
- package/esm/shared/types/permissions.d.ts +1 -1
- package/esm/shared/types/permissions.d.ts.map +1 -1
- package/esm/shared/types/risks.d.ts +4 -1
- package/esm/shared/types/risks.d.ts.map +1 -1
- package/esm/skillreader/types.d.ts +2 -2
- package/esm/skillreader/types.d.ts.map +1 -1
- package/esm/skillreader/types.js +2 -2
- package/package.json +1 -1
- package/script/analyzer/astgrep/client.d.ts +20 -8
- package/script/analyzer/astgrep/client.d.ts.map +1 -1
- package/script/analyzer/astgrep/client.js +58 -64
- package/script/analyzer/config/default.d.ts +8 -0
- package/script/analyzer/config/default.d.ts.map +1 -0
- package/script/analyzer/config/default.js +94 -0
- package/script/analyzer/config/helpers.d.ts +8 -0
- package/script/analyzer/config/helpers.d.ts.map +1 -0
- package/script/analyzer/config/helpers.js +76 -0
- package/script/analyzer/config/mod.d.ts +4 -0
- package/script/analyzer/config/mod.d.ts.map +1 -0
- package/script/analyzer/config/mod.js +21 -0
- package/script/analyzer/config/types.d.ts +58 -0
- package/script/analyzer/config/types.d.ts.map +1 -0
- package/script/analyzer/{config.js → config/types.js} +1 -29
- package/script/analyzer/logging.d.ts +3 -0
- package/script/analyzer/logging.d.ts.map +1 -0
- package/script/analyzer/logging.js +9 -0
- package/script/analyzer/mod.d.ts +12 -5
- package/script/analyzer/mod.d.ts.map +1 -1
- package/script/analyzer/mod.js +35 -20
- package/script/analyzer/result.d.ts +35 -0
- package/script/analyzer/result.d.ts.map +1 -0
- package/script/analyzer/result.js +315 -0
- package/script/analyzer/rules/bash/commands/mod.d.ts +1 -0
- package/script/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
- package/script/analyzer/rules/bash/commands/mod.js +3 -0
- package/script/analyzer/rules/bash/commands/pip.d.ts +3 -0
- package/script/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
- package/script/analyzer/rules/bash/commands/pip.js +17 -0
- package/script/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
- package/script/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/bash/extractFileRefs.js +2 -2
- package/script/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
- package/script/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
- package/script/analyzer/rules/bash/inline-command-classifier.js +4 -4
- package/script/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
- package/script/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/javascript/extractFileRefs.js +3 -4
- package/script/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
- package/script/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
- package/script/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/markdown/extractFileRefs.js +2 -0
- package/script/analyzer/rules/python/extractFileRefs.d.ts +1 -1
- package/script/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/python/extractFileRefs.js +2 -2
- package/script/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
- package/script/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
- package/script/analyzer/steps/001-discovery/discover-files.js +18 -2
- package/script/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
- package/script/analyzer/steps/001-discovery/mod.js +77 -11
- package/script/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
- package/script/analyzer/steps/002-permissions/mod.js +194 -75
- package/script/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
- package/script/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
- package/script/analyzer/steps/002-permissions/scan-file.js +40 -5
- package/script/analyzer/steps/002-permissions/seed-frontmatter.js +3 -3
- package/script/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
- package/script/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
- package/script/analyzer/steps/003-risks/dep-risks.js +77 -0
- package/script/analyzer/steps/003-risks/helpers.d.ts +1 -0
- package/script/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/helpers.js +1 -0
- package/script/analyzer/steps/003-risks/mod.d.ts +3 -2
- package/script/analyzer/steps/003-risks/mod.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/mod.js +77 -4
- package/script/analyzer/steps/003-risks/policy.d.ts +7 -0
- package/script/analyzer/steps/003-risks/policy.d.ts.map +1 -0
- package/script/analyzer/steps/003-risks/policy.js +29 -0
- package/script/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
- package/script/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/rule-mapped.js +83 -2
- package/script/analyzer/steps/003-risks/scoring.d.ts +9 -1
- package/script/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/scoring.js +55 -42
- package/script/analyzer/treesitter/client.d.ts +31 -0
- package/script/analyzer/treesitter/client.d.ts.map +1 -0
- package/script/analyzer/treesitter/client.js +136 -0
- package/script/analyzer/treesitter/registry.d.ts +73 -0
- package/script/analyzer/treesitter/registry.d.ts.map +1 -0
- package/script/analyzer/treesitter/registry.js +206 -0
- package/script/analyzer/types.d.ts +14 -28
- package/script/analyzer/types.d.ts.map +1 -1
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +10 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +334 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +305 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.js +48 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.js +986 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.js +18 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.js +65 -0
- package/script/shared/deep_merge.d.ts +12 -0
- package/script/shared/deep_merge.d.ts.map +1 -0
- package/script/shared/deep_merge.js +53 -0
- package/script/shared/mod.d.ts +1 -0
- package/script/shared/mod.d.ts.map +1 -1
- package/script/shared/mod.js +1 -0
- package/script/shared/types/filetypes.d.ts +2 -2
- package/script/shared/types/filetypes.d.ts.map +1 -1
- package/script/shared/types/permissions.d.ts +1 -1
- package/script/shared/types/permissions.d.ts.map +1 -1
- package/script/shared/types/risks.d.ts +4 -1
- package/script/shared/types/risks.d.ts.map +1 -1
- package/script/skillreader/types.d.ts +2 -2
- package/script/skillreader/types.d.ts.map +1 -1
- package/script/skillreader/types.js +2 -2
- package/src/_dnt.polyfills.ts +27 -0
- package/src/_dnt.shims.ts +64 -0
- package/src/analyzer/astgrep/client.ts +184 -0
- package/src/analyzer/astgrep/mod.ts +2 -0
- package/src/analyzer/config/default.ts +98 -0
- package/src/analyzer/config/helpers.ts +107 -0
- package/src/analyzer/config/mod.ts +3 -0
- package/src/analyzer/config/types.ts +103 -0
- package/src/analyzer/logging.ts +8 -0
- package/src/analyzer/mod.ts +118 -0
- package/src/analyzer/result.ts +393 -0
- package/src/analyzer/rules/bash/astTypes.ts +5 -0
- package/src/analyzer/rules/bash/commands/bd.ts +23 -0
- package/src/analyzer/rules/bash/commands/cron.ts +21 -0
- package/src/analyzer/rules/bash/commands/docker.ts +37 -0
- package/src/analyzer/rules/bash/commands/eval.ts +52 -0
- package/src/analyzer/rules/bash/commands/generic.ts +16 -0
- package/src/analyzer/rules/bash/commands/gh.ts +21 -0
- package/src/analyzer/rules/bash/commands/git.ts +28 -0
- package/src/analyzer/rules/bash/commands/mod.ts +38 -0
- package/src/analyzer/rules/bash/commands/node.ts +64 -0
- package/src/analyzer/rules/bash/commands/openspec.ts +16 -0
- package/src/analyzer/rules/bash/commands/pip.ts +16 -0
- package/src/analyzer/rules/bash/commands/sudo.ts +21 -0
- package/src/analyzer/rules/bash/destructive.ts +28 -0
- package/src/analyzer/rules/bash/extractFileRefs.ts +101 -0
- package/src/analyzer/rules/bash/filesystem.ts +50 -0
- package/src/analyzer/rules/bash/injection.ts +21 -0
- package/src/analyzer/rules/bash/inline-command-classifier.ts +94 -0
- package/src/analyzer/rules/bash/mod.ts +23 -0
- package/src/analyzer/rules/bash/network.ts +64 -0
- package/src/analyzer/rules/bash/secret-detection.ts +43 -0
- package/src/analyzer/rules/javascript/astTypes.ts +8 -0
- package/src/analyzer/rules/javascript/extractFileRefs.ts +131 -0
- package/src/analyzer/rules/javascript/filesystem.ts +28 -0
- package/src/analyzer/rules/javascript/injection.ts +21 -0
- package/src/analyzer/rules/javascript/mod.ts +26 -0
- package/src/analyzer/rules/javascript/network.ts +27 -0
- package/src/analyzer/rules/javascript/secret-detection.ts +68 -0
- package/src/analyzer/rules/javascript/subprocess.ts +16 -0
- package/src/analyzer/rules/markdown/astTypes.ts +35 -0
- package/src/analyzer/rules/markdown/extractCodeBlocks.ts +101 -0
- package/src/analyzer/rules/markdown/extractFileRefs.ts +179 -0
- package/src/analyzer/rules/markdown/mod.ts +12 -0
- package/src/analyzer/rules/mod.ts +77 -0
- package/src/analyzer/rules/python/astTypes.ts +9 -0
- package/src/analyzer/rules/python/extractFileRefs.ts +92 -0
- package/src/analyzer/rules/python/mod.ts +15 -0
- package/src/analyzer/rules/python/network.ts +26 -0
- package/src/analyzer/rules/python/secret-detection.ts +30 -0
- package/src/analyzer/rules/shared/file-refs.ts +38 -0
- package/src/analyzer/rules/shared/network-evaluators.ts +107 -0
- package/src/analyzer/rules/shared/prompt-injection.ts +48 -0
- package/src/analyzer/rules/shared/secret-evaluators.ts +13 -0
- package/src/analyzer/rules/text/mod.ts +12 -0
- package/src/analyzer/rules/typescript/mod.ts +7 -0
- package/src/analyzer/steps/001-discovery/discover-files.ts +211 -0
- package/src/analyzer/steps/001-discovery/filter-files.ts +72 -0
- package/src/analyzer/steps/001-discovery/mod.ts +103 -0
- package/src/analyzer/steps/002-permissions/mod.ts +329 -0
- package/src/analyzer/steps/002-permissions/scan-file.ts +258 -0
- package/src/analyzer/steps/002-permissions/seed-frontmatter.ts +66 -0
- package/src/analyzer/steps/002-permissions/synthesize.ts +42 -0
- package/src/analyzer/steps/003-risks/dep-risks.ts +89 -0
- package/src/analyzer/steps/003-risks/helpers.ts +41 -0
- package/src/analyzer/steps/003-risks/mod.ts +86 -0
- package/src/analyzer/steps/003-risks/policy.ts +38 -0
- package/src/analyzer/steps/003-risks/rule-mapped.ts +206 -0
- package/src/analyzer/steps/003-risks/scoring.ts +117 -0
- package/src/analyzer/steps/mod.ts +3 -0
- package/src/analyzer/treesitter/client.ts +120 -0
- package/src/analyzer/treesitter/registry.ts +198 -0
- package/src/analyzer/types.ts +78 -0
- package/src/analyzer/utils/code-block-path.ts +33 -0
- package/src/analyzer/utils/id-generator.ts +59 -0
- package/src/analyzer/utils/secret-validator.ts +29 -0
- package/src/analyzer/utils/url-parser.ts +25 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/deps.ts +3 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/mod.ts +265 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/multi.ts +250 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/time.ts +69 -0
- package/src/deps/jsr.io/@std/fmt/1.0.3/colors.ts +1004 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/_os.ts +15 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/os.ts +7 -0
- package/src/deps/jsr.io/@std/io/0.225.0/types.ts +157 -0
- package/src/deps/jsr.io/@std/io/0.225.0/write_all.ts +65 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/assert_path.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/basename.ts +53 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/common.ts +26 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/constants.ts +49 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/dirname.ts +9 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/format.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.ts +12 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.ts +295 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize.ts +9 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.ts +74 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/relative.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.ts +17 -0
- package/src/deps/jsr.io/@std/path/1.1.4/basename.ts +37 -0
- package/src/deps/jsr.io/@std/path/1.1.4/common.ts +35 -0
- package/src/deps/jsr.io/@std/path/1.1.4/constants.ts +18 -0
- package/src/deps/jsr.io/@std/path/1.1.4/dirname.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/extname.ts +29 -0
- package/src/deps/jsr.io/@std/path/1.1.4/format.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/from_file_url.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.ts +94 -0
- package/src/deps/jsr.io/@std/path/1.1.4/is_absolute.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/is_glob.ts +49 -0
- package/src/deps/jsr.io/@std/path/1.1.4/join.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/join_globs.ts +42 -0
- package/src/deps/jsr.io/@std/path/1.1.4/mod.ts +217 -0
- package/src/deps/jsr.io/@std/path/1.1.4/normalize.ts +33 -0
- package/src/deps/jsr.io/@std/path/1.1.4/normalize_glob.ts +45 -0
- package/src/deps/jsr.io/@std/path/1.1.4/parse.ts +44 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/_util.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/basename.ts +62 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/constants.ts +15 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/dirname.ts +72 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/extname.ts +96 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/format.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.ts +94 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/join.ts +46 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/join_globs.ts +45 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize.ts +63 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.ts +43 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/parse.ts +121 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/relative.ts +103 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/resolve.ts +71 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.ts +21 -0
- package/src/deps/jsr.io/@std/path/1.1.4/relative.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/resolve.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/to_file_url.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/types.ts +40 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/_util.ts +28 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/basename.ts +54 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/constants.ts +15 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/dirname.ts +118 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/extname.ts +90 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/format.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.ts +34 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.ts +92 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.ts +40 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/join.ts +78 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/join_globs.ts +46 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize.ts +136 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.ts +43 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/parse.ts +184 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/relative.ts +128 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/resolve.ts +178 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.ts +38 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.ts +60 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_chars.ts +55 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.ts +841 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_loader_state.ts +1780 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_schema.ts +183 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/binary.ts +127 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/bool.ts +37 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/float.ts +112 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/int.ts +174 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/map.ts +17 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/merge.ts +13 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/nil.ts +27 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/omap.ts +30 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.ts +22 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.ts +33 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/seq.ts +13 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/set.ts +17 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/str.ts +12 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.ts +101 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.ts +23 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type.ts +49 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_utils.ts +16 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/mod.ts +54 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/parse.ts +128 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/stringify.ts +118 -0
- package/src/shared/deep_merge.ts +73 -0
- package/src/shared/mod.ts +2 -0
- package/src/shared/types/filetypes.ts +101 -0
- package/src/shared/types/findings.ts +7 -0
- package/src/shared/types/mod.ts +6 -0
- package/src/shared/types/permissions.ts +17 -0
- package/src/shared/types/references.ts +62 -0
- package/src/shared/types/risks.ts +72 -0
- package/src/shared/types/syntaxNode.ts +7 -0
- package/src/skillreader/cloudStorage/mod.ts +170 -0
- package/src/skillreader/factory.ts +71 -0
- package/src/skillreader/fs/git.ts +153 -0
- package/src/skillreader/fs/mod.ts +84 -0
- package/src/skillreader/github/base.ts +162 -0
- package/src/skillreader/github/githubApi.ts +40 -0
- package/src/skillreader/github/githubRaw.ts +24 -0
- package/src/skillreader/github/mod.ts +45 -0
- package/src/skillreader/github/utils.ts +40 -0
- package/src/skillreader/manifest.ts +67 -0
- package/src/skillreader/mod.ts +26 -0
- package/src/skillreader/types.ts +150 -0
- package/src/skillreader/utils/frontmatter-parser.ts +72 -0
- package/src/skillreader/utils/http-range.ts +38 -0
- package/src/skillreader/utils/mod.ts +12 -0
- package/esm/analyzer/astgrep/registry.d.ts +0 -18
- package/esm/analyzer/astgrep/registry.d.ts.map +0 -1
- package/esm/analyzer/astgrep/registry.js +0 -71
- package/esm/analyzer/config.d.ts +0 -27
- package/esm/analyzer/config.d.ts.map +0 -1
- package/esm/analyzer/steps/003-risks/output.d.ts +0 -3
- package/esm/analyzer/steps/003-risks/output.d.ts.map +0 -1
- package/esm/analyzer/steps/003-risks/output.js +0 -16
- package/esm/analyzer/treesiter/client.d.ts +0 -26
- package/esm/analyzer/treesiter/client.d.ts.map +0 -1
- package/script/analyzer/astgrep/registry.d.ts +0 -18
- package/script/analyzer/astgrep/registry.d.ts.map +0 -1
- package/script/analyzer/astgrep/registry.js +0 -109
- package/script/analyzer/config.d.ts +0 -27
- package/script/analyzer/config.d.ts.map +0 -1
- package/script/analyzer/steps/003-risks/output.d.ts +0 -3
- package/script/analyzer/steps/003-risks/output.d.ts.map +0 -1
- package/script/analyzer/steps/003-risks/output.js +0 -19
- package/script/analyzer/treesiter/client.d.ts +0 -26
- package/script/analyzer/treesiter/client.d.ts.map +0 -1
- package/script/analyzer/treesiter/client.js +0 -165
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractFileRefs.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/rules/python/extractFileRefs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,
|
|
1
|
+
{"version":3,"file":"extractFileRefs.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/rules/python/extractFileRefs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGxE,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,GAChB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAwE7B"}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { isHostFsPath, isUrl } from "../shared/file-refs.js";
|
|
13
13
|
import { PYTHON_NODE } from "./astTypes.js";
|
|
14
|
-
export function extractPythonFileRefs(context, content) {
|
|
14
|
+
export async function extractPythonFileRefs(context, content) {
|
|
15
15
|
const refs = [];
|
|
16
|
-
const ast = context.astgrepClient.parse("python", content);
|
|
16
|
+
const ast = await context.astgrepClient.parse("python", content);
|
|
17
17
|
const root = ast.root();
|
|
18
18
|
// ── import_statement (e.g. `import os`, `import os.path`) ───────────────
|
|
19
19
|
const importNodes = root.findAll({ rule: { kind: PYTHON_NODE.IMPORT_STATEMENT } });
|
|
@@ -21,6 +21,10 @@ export declare function discoverReferencedFiles(context: AnalyzerContext, input:
|
|
|
21
21
|
allFiles: SkillFile[];
|
|
22
22
|
readTextFile: (path: string) => Promise<string | null>;
|
|
23
23
|
maxScanDepth: number;
|
|
24
|
+
onDiscover?: (progress: {
|
|
25
|
+
scannedCount: number;
|
|
26
|
+
discoveredCount: number;
|
|
27
|
+
}) => void;
|
|
24
28
|
}): Promise<FileReference[]>;
|
|
25
29
|
export type { FileRefDiscovery };
|
|
26
30
|
//# sourceMappingURL=discover-files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-files.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/001-discovery/discover-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGvE,KAAK,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAEhF;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE;IACH,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"discover-files.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/001-discovery/discover-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAG7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGvE,KAAK,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,SAAS,CAAA;CAAE,CAAC;AAEhF;;;;;;;;GAQG;AACH,wBAAsB,uBAAuB,CACzC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE;IACH,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACtF,GACF,OAAO,CAAC,aAAa,EAAE,CAAC,CA8K1B;AAMD,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -14,6 +14,8 @@ import { encodeCodeBlockPath } from "../../utils/code-block-path.js";
|
|
|
14
14
|
export async function discoverReferencedFiles(context, input) {
|
|
15
15
|
const discovered = new Map();
|
|
16
16
|
const queue = [...input.startQueue];
|
|
17
|
+
let scannedCount = 0;
|
|
18
|
+
let discoveredCount = 0;
|
|
17
19
|
// A set of file paths which have been processed
|
|
18
20
|
const processed = new Set();
|
|
19
21
|
const startPaths = new Set(input.startQueue.map((item) => normalizePath(item.path)));
|
|
@@ -24,6 +26,7 @@ export async function discoverReferencedFiles(context, input) {
|
|
|
24
26
|
if (processed.has(current.path) || current.depth > input.maxScanDepth)
|
|
25
27
|
continue;
|
|
26
28
|
processed.add(current.path);
|
|
29
|
+
input.onDiscover?.({ scannedCount: scannedCount++, discoveredCount });
|
|
27
30
|
const content = await input.readTextFile(current.path);
|
|
28
31
|
if (!content)
|
|
29
32
|
continue;
|
|
@@ -77,6 +80,7 @@ export async function discoverReferencedFiles(context, input) {
|
|
|
77
80
|
depth: current.depth + 1,
|
|
78
81
|
referencedBy: localEntry.referencedBy,
|
|
79
82
|
});
|
|
83
|
+
input.onDiscover?.({ scannedCount, discoveredCount: discoveredCount++ });
|
|
80
84
|
}
|
|
81
85
|
continue;
|
|
82
86
|
}
|
|
@@ -104,11 +108,23 @@ export async function discoverReferencedFiles(context, input) {
|
|
|
104
108
|
});
|
|
105
109
|
continue;
|
|
106
110
|
}
|
|
107
|
-
if (absoluteRef.via === "import"
|
|
111
|
+
if (absoluteRef.via === "import") {
|
|
108
112
|
discovered.set(normalizedPath, {
|
|
109
113
|
path: normalizedPath,
|
|
110
114
|
sourceType: "external",
|
|
111
|
-
fileType:
|
|
115
|
+
fileType: block.language,
|
|
116
|
+
role: "library",
|
|
117
|
+
depth: current.depth + 1,
|
|
118
|
+
discoveryMethod: absoluteRef.via,
|
|
119
|
+
referencedBy: referenceFromCurrent,
|
|
120
|
+
});
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (absoluteRef.via === "source") {
|
|
124
|
+
discovered.set(normalizedPath, {
|
|
125
|
+
path: normalizedPath,
|
|
126
|
+
sourceType: "external",
|
|
127
|
+
fileType: block.language,
|
|
112
128
|
role: "library",
|
|
113
129
|
depth: current.depth + 1,
|
|
114
130
|
discoveryMethod: absoluteRef.via,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/001-discovery/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/001-discovery/mod.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIrE,wBAAsB,eAAe,CACjC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,eAAe,GACzB,OAAO,CAAC,aAAa,CAAC,CAwFxB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
import ProgressBar from "../../../deps/jsr.io/@deno-library/progress/1.5.1/mod.js";
|
|
3
|
+
import { DEFAULT_ANALYZER_CONFIG, DEFAULT_SKILL_VERSION, FRONTMATTER_SUPPORTED_FIELDS, } from "../../config/mod.js";
|
|
2
4
|
import { discoverReferencedFiles } from "./discover-files.js";
|
|
3
5
|
import { filterScanQueue } from "./filter-files.js";
|
|
4
6
|
export async function run001Discovery(state, context) {
|
|
@@ -20,12 +22,40 @@ export async function run001Discovery(state, context) {
|
|
|
20
22
|
nextState.warnings.push(`Unknown frontmatter field '${field}' - analysis not supported yet`);
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const shouldLogProgress = (context.showProgressBar ?? false) && dntShim.Deno.stderr.isTerminal();
|
|
26
|
+
const maxScanDepth = state.metadata.config.maxScanDepth ??
|
|
27
|
+
DEFAULT_ANALYZER_CONFIG.scan?.maxScanDepth ?? 5;
|
|
28
|
+
const maxFileCount = state.metadata.config.maxFileCount ??
|
|
29
|
+
DEFAULT_ANALYZER_CONFIG.scan?.maxFileCount ?? 100;
|
|
30
|
+
const maxFileSize = state.metadata.config.maxFileSize ??
|
|
31
|
+
DEFAULT_ANALYZER_CONFIG.scan?.maxFileSize ?? 1_000_000;
|
|
32
|
+
const discoveryBar = shouldLogProgress
|
|
33
|
+
? new ProgressBar({
|
|
34
|
+
total: files.length,
|
|
35
|
+
clear: true,
|
|
36
|
+
output: dntShim.Deno.stderr,
|
|
37
|
+
complete: "=",
|
|
38
|
+
incomplete: "-",
|
|
39
|
+
display: "Readings skills [:bar] :percent ETA :eta",
|
|
40
|
+
})
|
|
41
|
+
: null;
|
|
42
|
+
let discovered = [];
|
|
43
|
+
try {
|
|
44
|
+
discovered = await discoverReferencedFiles(context, {
|
|
45
|
+
startQueue: [{ path: skillMdPath, depth: 0 }],
|
|
46
|
+
allFiles: files,
|
|
47
|
+
readTextFile: (path) => context.skillReader.readTextFile(path),
|
|
48
|
+
maxScanDepth,
|
|
49
|
+
onDiscover: (progress) => {
|
|
50
|
+
discoveryBar?.render(progress.scannedCount, {
|
|
51
|
+
total: progress.discoveredCount + 1,
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
discoveryBar?.end();
|
|
58
|
+
}
|
|
29
59
|
discovered.push({
|
|
30
60
|
path: skillMdPath,
|
|
31
61
|
sourceType: "local",
|
|
@@ -36,8 +66,8 @@ export async function run001Discovery(state, context) {
|
|
|
36
66
|
const filtered = filterScanQueue({
|
|
37
67
|
queue: discovered,
|
|
38
68
|
allFiles: files,
|
|
39
|
-
maxFileCount
|
|
40
|
-
maxFileSize
|
|
69
|
+
maxFileCount,
|
|
70
|
+
maxFileSize,
|
|
41
71
|
});
|
|
42
72
|
return {
|
|
43
73
|
...nextState,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/002-permissions/mod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/002-permissions/mod.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAcrE,wBAAsB,iBAAiB,CACnC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,eAAe,GACzB,OAAO,CAAC,aAAa,CAAC,CAsGxB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
import ProgressBar from "../../../deps/jsr.io/@deno-library/progress/1.5.1/mod.js";
|
|
1
3
|
import { PROMPT_REGEX_RULES } from "../../rules/mod.js";
|
|
2
4
|
import { RULES_BY_FILETYPE } from "../../rules/mod.js";
|
|
3
5
|
import { isLikelyInlineBashCommand } from "../../rules/bash/inline-command-classifier.js";
|
|
@@ -6,86 +8,98 @@ import { generatePermissionId } from "../../utils/id-generator.js";
|
|
|
6
8
|
import { scanFileForPermissions } from "./scan-file.js";
|
|
7
9
|
import { seedPermissionsFromFrontmatter } from "./seed-frontmatter.js";
|
|
8
10
|
import { synthesizePermissions } from "./synthesize.js";
|
|
11
|
+
const ANSI_SHOW_CURSOR = "\x1b[?25h";
|
|
12
|
+
const ENCODER = new TextEncoder();
|
|
9
13
|
export async function run002Permissions(state, context) {
|
|
10
14
|
const skillMdPath = state.scanQueue.find((file) => file.role === "entrypoint")?.path ??
|
|
11
15
|
"SKILL.md";
|
|
12
16
|
let next = state;
|
|
13
17
|
next = seedPermissionsFromFrontmatter(next, skillMdPath);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fileRef.discoveryMethod === undefined) {
|
|
38
|
-
next = {
|
|
39
|
-
...next,
|
|
40
|
-
warnings: [
|
|
41
|
-
...next.warnings,
|
|
42
|
-
`External reference not analyzed yet: ${fileRef.path}`,
|
|
43
|
-
],
|
|
44
|
-
metadata: {
|
|
45
|
-
...next.metadata,
|
|
46
|
-
skippedFiles: [...next.metadata.skippedFiles, {
|
|
47
|
-
path: fileRef.path,
|
|
48
|
-
reason: "external_reference",
|
|
49
|
-
referenceBy: fileRef.referencedBy,
|
|
50
|
-
}],
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
const scanTargets = await resolveScanTargets(fileRef, context);
|
|
57
|
-
if (scanTargets.length === 0)
|
|
58
|
-
continue;
|
|
59
|
-
if (!RULES_BY_FILETYPE[fileRef.fileType]) {
|
|
60
|
-
next = {
|
|
61
|
-
...next,
|
|
62
|
-
warnings: [
|
|
63
|
-
...next.warnings,
|
|
64
|
-
`File type '${fileRef.fileType}' is not supported yet for analysis: ${fileRef.path}`,
|
|
65
|
-
],
|
|
66
|
-
metadata: {
|
|
67
|
-
...next.metadata,
|
|
68
|
-
skippedFiles: [...next.metadata.skippedFiles, {
|
|
18
|
+
const shouldRenderProgress = (context.showProgressBar ?? false) && dntShim.Deno.stderr.isTerminal();
|
|
19
|
+
const scanBar = shouldRenderProgress
|
|
20
|
+
? new ProgressBar({
|
|
21
|
+
total: Math.max(1, next.scanQueue.length),
|
|
22
|
+
clear: true,
|
|
23
|
+
output: dntShim.Deno.stderr,
|
|
24
|
+
complete: "=",
|
|
25
|
+
incomplete: "-",
|
|
26
|
+
display: "Scanning skills [:bar] :percent ETA :eta",
|
|
27
|
+
})
|
|
28
|
+
: null;
|
|
29
|
+
let processed = 0;
|
|
30
|
+
try {
|
|
31
|
+
await scanBar?.render(processed);
|
|
32
|
+
for (const fileRef of next.scanQueue) {
|
|
33
|
+
try {
|
|
34
|
+
if (fileRef.sourceType === "external") {
|
|
35
|
+
if (fileRef.role === "host-fs") {
|
|
36
|
+
next = addHostFsPermission(next, fileRef.path, fileRef.referencedBy);
|
|
37
|
+
}
|
|
38
|
+
else if (fileRef.discoveryMethod === "import") {
|
|
39
|
+
next = addImportDependencyPermission(next, fileRef);
|
|
40
|
+
next = appendSkippedFile(next, {
|
|
69
41
|
path: fileRef.path,
|
|
70
|
-
reason:
|
|
42
|
+
reason: "external_library_dependency",
|
|
71
43
|
referenceBy: fileRef.referencedBy,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
next = addExternalReferencePermission(next, fileRef);
|
|
48
|
+
const reason = fileRef.role === "library"
|
|
49
|
+
? "external_library_dependency"
|
|
50
|
+
: "external_reference";
|
|
51
|
+
next = appendSkippedFile(next, {
|
|
52
|
+
path: fileRef.path,
|
|
53
|
+
reason,
|
|
54
|
+
referenceBy: fileRef.referencedBy,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const scanTargets = await resolveScanTargets(fileRef, context);
|
|
60
|
+
if (scanTargets.length === 0)
|
|
61
|
+
continue;
|
|
62
|
+
if (!RULES_BY_FILETYPE[fileRef.fileType]) {
|
|
63
|
+
next = {
|
|
64
|
+
...next,
|
|
65
|
+
warnings: [
|
|
66
|
+
...next.warnings,
|
|
67
|
+
`File type '${fileRef.fileType}' is not supported yet for analysis: ${fileRef.path}`,
|
|
68
|
+
],
|
|
69
|
+
metadata: {
|
|
70
|
+
...next.metadata,
|
|
71
|
+
skippedFiles: [...next.metadata.skippedFiles, {
|
|
72
|
+
path: fileRef.path,
|
|
73
|
+
reason: `unsupported_type_${fileRef.fileType}`,
|
|
74
|
+
referenceBy: fileRef.referencedBy,
|
|
75
|
+
}],
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
for (const scanTarget of scanTargets) {
|
|
81
|
+
next = await scanFileForPermissions(context, {
|
|
82
|
+
state: next,
|
|
83
|
+
fileRef,
|
|
84
|
+
scanPath: scanTarget.scanPath,
|
|
85
|
+
content: scanTarget.content,
|
|
86
|
+
lineOffset: scanTarget.lineOffset,
|
|
87
|
+
referenceType: scanTarget.referenceType,
|
|
88
|
+
});
|
|
89
|
+
if (scanTarget.referenceType === "content") {
|
|
90
|
+
next = applyPromptRegexFindings(next, scanTarget.scanPath, scanTarget.content, scanTarget.lineOffset, fileRef.referencedBy);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
88
93
|
}
|
|
94
|
+
finally {
|
|
95
|
+
await scanBar?.render(++processed);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
finally {
|
|
100
|
+
await scanBar?.end();
|
|
101
|
+
if (shouldRenderProgress && dntShim.Deno.stderr.isTerminal()) {
|
|
102
|
+
dntShim.Deno.stderr.writeSync(ENCODER.encode(ANSI_SHOW_CURSOR));
|
|
89
103
|
}
|
|
90
104
|
}
|
|
91
105
|
return synthesizePermissions(next);
|
|
@@ -113,7 +127,8 @@ async function resolveScanTargets(fileRef, context) {
|
|
|
113
127
|
if (referenceType === "inline") {
|
|
114
128
|
const line = lines[decoded.startLine - 1] ?? "";
|
|
115
129
|
const snippets = extractInlineSnippets(line);
|
|
116
|
-
const
|
|
130
|
+
const likelyCommandFlags = await Promise.all(snippets.map((snippet) => isLikelyInlineBashCommand(context, { snippet, lineContext: line })));
|
|
131
|
+
const likelyCommands = snippets.filter((_, i) => likelyCommandFlags[i]);
|
|
117
132
|
return likelyCommands.map((snippet) => ({
|
|
118
133
|
scanPath: decoded.parentPath,
|
|
119
134
|
content: snippet,
|
|
@@ -161,6 +176,74 @@ function applyPromptRegexFindings(state, filePath, content, lineOffset, referenc
|
|
|
161
176
|
}
|
|
162
177
|
return { ...state, findings };
|
|
163
178
|
}
|
|
179
|
+
function appendSkippedFile(state, skipped) {
|
|
180
|
+
return {
|
|
181
|
+
...state,
|
|
182
|
+
metadata: {
|
|
183
|
+
...state.metadata,
|
|
184
|
+
skippedFiles: [...state.metadata.skippedFiles, skipped],
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function addImportDependencyPermission(state, fileRef) {
|
|
189
|
+
const language = fileRef.fileType;
|
|
190
|
+
const importName = fileRef.path;
|
|
191
|
+
const metadata = {
|
|
192
|
+
language,
|
|
193
|
+
discoveryMethod: fileRef.discoveryMethod,
|
|
194
|
+
};
|
|
195
|
+
const permission = {
|
|
196
|
+
id: generatePermissionId("dep-import", [language, importName]),
|
|
197
|
+
tool: language,
|
|
198
|
+
scope: "dep",
|
|
199
|
+
permission: "import",
|
|
200
|
+
args: [importName],
|
|
201
|
+
metadata,
|
|
202
|
+
references: [toPermissionReference(fileRef)],
|
|
203
|
+
source: "inferred",
|
|
204
|
+
risks: [],
|
|
205
|
+
};
|
|
206
|
+
if (state.permissions.some((p) => p.id === permission.id))
|
|
207
|
+
return state;
|
|
208
|
+
return {
|
|
209
|
+
...state,
|
|
210
|
+
permissions: [...state.permissions, permission],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function addExternalReferencePermission(state, fileRef) {
|
|
214
|
+
const path = fileRef.path;
|
|
215
|
+
const language = fileRef.fileType ?? "unknown";
|
|
216
|
+
const metadata = {
|
|
217
|
+
language,
|
|
218
|
+
discoveryMethod: fileRef.discoveryMethod,
|
|
219
|
+
};
|
|
220
|
+
const permission = {
|
|
221
|
+
id: generatePermissionId("dep-externalreference", [language, path]),
|
|
222
|
+
tool: language,
|
|
223
|
+
scope: "dep",
|
|
224
|
+
permission: "externalreference",
|
|
225
|
+
args: [path],
|
|
226
|
+
metadata,
|
|
227
|
+
references: [toPermissionReference(fileRef)],
|
|
228
|
+
source: "inferred",
|
|
229
|
+
risks: [],
|
|
230
|
+
};
|
|
231
|
+
if (state.permissions.some((p) => p.id === permission.id))
|
|
232
|
+
return state;
|
|
233
|
+
return {
|
|
234
|
+
...state,
|
|
235
|
+
permissions: [...state.permissions, permission],
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function toPermissionReference(fileRef) {
|
|
239
|
+
return {
|
|
240
|
+
file: fileRef.referencedBy?.file ?? fileRef.path,
|
|
241
|
+
line: fileRef.referencedBy?.line ?? 1,
|
|
242
|
+
lineEnd: fileRef.referencedBy?.lineEnd,
|
|
243
|
+
type: fileRef.referencedBy?.type ?? "content",
|
|
244
|
+
referencedBy: fileRef.referencedBy?.referencedBy,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
164
247
|
function addHostFsPermission(state, path, referencedBy) {
|
|
165
248
|
const reference = {
|
|
166
249
|
file: referencedBy?.file ?? "SKILL.md",
|
|
@@ -10,5 +10,5 @@ export declare function scanFileForPermissions(context: AnalyzerContext, input:
|
|
|
10
10
|
content: string;
|
|
11
11
|
lineOffset?: number;
|
|
12
12
|
referenceType?: "content" | "script" | "inline";
|
|
13
|
-
}): AnalyzerState
|
|
13
|
+
}): Promise<AnalyzerState>;
|
|
14
14
|
//# sourceMappingURL=scan-file.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan-file.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/002-permissions/scan-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,wBAAwB,CAAC;AAsCzF;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"scan-file.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/002-permissions/scan-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAA+B,MAAM,wBAAwB,CAAC;AAsCzF;;GAEG;AACH,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,eAAe,EACxB,KAAK,EAAE;IACH,KAAK,EAAE,aAAa,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACnD,GACF,OAAO,CAAC,aAAa,CAAC,CAiFxB"}
|
|
@@ -35,7 +35,7 @@ const SHELL_RESERVED_WORDS = new Set([
|
|
|
35
35
|
/**
|
|
36
36
|
* Scans a text-like file and returns updated state with permissions and findings.
|
|
37
37
|
*/
|
|
38
|
-
export function scanFileForPermissions(context, input) {
|
|
38
|
+
export async function scanFileForPermissions(context, input) {
|
|
39
39
|
const { state, fileRef, scanPath, content, lineOffset = 0, referenceType = "content", } = input;
|
|
40
40
|
const permissions = [];
|
|
41
41
|
const findings = [...state.findings];
|
|
@@ -46,15 +46,16 @@ export function scanFileForPermissions(context, input) {
|
|
|
46
46
|
...state,
|
|
47
47
|
metadata: {
|
|
48
48
|
...state.metadata,
|
|
49
|
-
scannedFiles: [...state.metadata.scannedFiles, scanPath],
|
|
49
|
+
scannedFiles: new Set([...state.metadata.scannedFiles, scanPath]),
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
const scanLanguage = rules[0].grammar;
|
|
54
|
-
const matches = context.astgrepClient.scanWithRules(content, scanLanguage, rules);
|
|
54
|
+
const matches = await context.astgrepClient.scanWithRules(content, scanLanguage, rules);
|
|
55
55
|
const lines = content.split("\n");
|
|
56
56
|
const filteredMatches = matches.filter((match) => shouldKeepMatchForBlock(match, lineOffset + 1, lines));
|
|
57
|
-
const
|
|
57
|
+
const deconflictedMatches = dropGenericShellDuplicates(filteredMatches, rules);
|
|
58
|
+
const blockFindings = context.astgrepClient.matchesToFindings(scanPath, referenceType, deconflictedMatches.map((match) => ({
|
|
58
59
|
...match,
|
|
59
60
|
line: match.line + lineOffset,
|
|
60
61
|
lineEnd: (match.lineEnd ?? match.line) + lineOffset,
|
|
@@ -91,7 +92,7 @@ export function scanFileForPermissions(context, input) {
|
|
|
91
92
|
metadata: {
|
|
92
93
|
...state.metadata,
|
|
93
94
|
rulesUsed,
|
|
94
|
-
scannedFiles: [...state.metadata.scannedFiles, scanPath],
|
|
95
|
+
scannedFiles: new Set([...state.metadata.scannedFiles, scanPath]),
|
|
95
96
|
},
|
|
96
97
|
};
|
|
97
98
|
}
|
|
@@ -187,3 +188,37 @@ function buildPermissionArgs(metadata, detectedTool) {
|
|
|
187
188
|
}
|
|
188
189
|
return args;
|
|
189
190
|
}
|
|
191
|
+
function dropGenericShellDuplicates(matches, rules) {
|
|
192
|
+
const ruleById = new Map(rules.map((rule) => [rule.id, rule]));
|
|
193
|
+
const specificToolAtLine = new Set();
|
|
194
|
+
for (const match of matches) {
|
|
195
|
+
if (match.ruleId === GENERIC_SHELL_RULE_ID)
|
|
196
|
+
continue;
|
|
197
|
+
const rule = ruleById.get(match.ruleId);
|
|
198
|
+
if (!rule)
|
|
199
|
+
continue;
|
|
200
|
+
const tool = resolveToolForMatch(rule.permission.tool, match.extracted);
|
|
201
|
+
if (!tool)
|
|
202
|
+
continue;
|
|
203
|
+
specificToolAtLine.add(`${match.line}:${tool}`);
|
|
204
|
+
}
|
|
205
|
+
return matches.filter((match) => {
|
|
206
|
+
if (match.ruleId !== GENERIC_SHELL_RULE_ID)
|
|
207
|
+
return true;
|
|
208
|
+
const rule = ruleById.get(match.ruleId);
|
|
209
|
+
if (!rule)
|
|
210
|
+
return true;
|
|
211
|
+
const tool = resolveToolForMatch(rule.permission.tool, match.extracted);
|
|
212
|
+
if (!tool)
|
|
213
|
+
return true;
|
|
214
|
+
return !specificToolAtLine.has(`${match.line}:${tool}`);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
function resolveToolForMatch(ruleTool, extracted) {
|
|
218
|
+
if (ruleTool !== "detected")
|
|
219
|
+
return ruleTool.toLowerCase();
|
|
220
|
+
const tool = extracted.tool;
|
|
221
|
+
if (typeof tool !== "string" || !tool.trim())
|
|
222
|
+
return null;
|
|
223
|
+
return tool.trim().toLowerCase();
|
|
224
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALLOWED_TOOLS_MAPPING } from "../../config.js";
|
|
1
|
+
import { ALLOWED_TOOLS_MAPPING } from "../../config/mod.js";
|
|
2
2
|
import { generatePermissionId } from "../../utils/id-generator.js";
|
|
3
3
|
export function seedPermissionsFromFrontmatter(state, skillMdPath) {
|
|
4
4
|
const rawAllowed = state.frontmatter["allowed-tools"];
|
|
@@ -9,7 +9,7 @@ export function seedPermissionsFromFrontmatter(state, skillMdPath) {
|
|
|
9
9
|
const baseRef = {
|
|
10
10
|
file: skillMdPath,
|
|
11
11
|
line: 1,
|
|
12
|
-
lineEnd: state.frontmatter.
|
|
12
|
+
lineEnd: state.frontmatter.endLineNumber,
|
|
13
13
|
type: "frontmatter",
|
|
14
14
|
};
|
|
15
15
|
const permissions = parsed.map((tool) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dep-risks.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/003-risks/dep-risks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAOrE,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC,GACzC,aAAa,CAgEf"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { addRisk } from "./helpers.js";
|
|
2
|
+
import { isAllowed, isDenied } from "./policy.js";
|
|
3
|
+
import { GRAMMAR_SPECS } from "../../treesitter/registry.js";
|
|
4
|
+
export function analyzeDependencyRisks(state, context) {
|
|
5
|
+
let next = state;
|
|
6
|
+
for (const permission of next.permissions) {
|
|
7
|
+
if (permission.scope !== "dep")
|
|
8
|
+
continue;
|
|
9
|
+
if (permission.permission === "import") {
|
|
10
|
+
const grammar = resolveGrammar(permission.tool);
|
|
11
|
+
const importName = permission.args?.[0]?.trim();
|
|
12
|
+
if (!importName)
|
|
13
|
+
continue;
|
|
14
|
+
const groupKey = `DEPENDENCY:external_import:${grammar ?? "unknown"}`;
|
|
15
|
+
if (grammar && isDenied(context.config, grammar, importName)) {
|
|
16
|
+
next = addRisk(next, {
|
|
17
|
+
type: "DEPENDENCY:external_import",
|
|
18
|
+
groupKey,
|
|
19
|
+
severity: "critical",
|
|
20
|
+
message: `Import '${importName}' is denied by config for ${grammar} and may execute untrusted dependency code.`,
|
|
21
|
+
permissionIds: [permission.id],
|
|
22
|
+
reference: resolvePrimaryReference(permission),
|
|
23
|
+
metadata: { policy: { language: { grammar, importName, source: "denylist" } } },
|
|
24
|
+
});
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (grammar && isAllowed(context.config, grammar, importName)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
next = addRisk(next, {
|
|
31
|
+
type: "DEPENDENCY:external_import",
|
|
32
|
+
groupKey,
|
|
33
|
+
severity: "warning",
|
|
34
|
+
message: `External import not explicitly configured: ${importName}`,
|
|
35
|
+
permissionIds: [permission.id],
|
|
36
|
+
reference: resolvePrimaryReference(permission),
|
|
37
|
+
metadata: grammar
|
|
38
|
+
? { policy: { language: { grammar, importName, source: "default" } } }
|
|
39
|
+
: undefined,
|
|
40
|
+
});
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (permission.permission === "externalreference") {
|
|
44
|
+
const discoveryMethod = permission.metadata?.discoveryMethod;
|
|
45
|
+
const path = permission.args?.[0] ?? permission.tool;
|
|
46
|
+
const isSourceInclude = discoveryMethod === "source";
|
|
47
|
+
next = addRisk(next, {
|
|
48
|
+
type: "REFERENCE:external_file",
|
|
49
|
+
groupKey: `REFERENCE:external_file:${permission.tool}`,
|
|
50
|
+
severity: "warning",
|
|
51
|
+
message: isSourceInclude
|
|
52
|
+
? `Sourced external file not analyzed yet: ${path}`
|
|
53
|
+
: `External reference not analyzed yet: ${path}`,
|
|
54
|
+
permissionIds: [permission.id],
|
|
55
|
+
reference: resolvePrimaryReference(permission),
|
|
56
|
+
metadata: isSourceInclude ? { discoveryMethod: "source" } : undefined,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
function resolveGrammar(tool) {
|
|
63
|
+
return tool in GRAMMAR_SPECS ? tool : null;
|
|
64
|
+
}
|
|
65
|
+
function resolvePrimaryReference(permission) {
|
|
66
|
+
const reference = permission.references[0];
|
|
67
|
+
if (reference)
|
|
68
|
+
return reference;
|
|
69
|
+
return {
|
|
70
|
+
file: "SKILL.md",
|
|
71
|
+
line: 1,
|
|
72
|
+
type: "content",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { AnalyzerState } from "../../types.js";
|
|
|
2
2
|
import type { RiskCode, Severity } from "../../../shared/mod.js";
|
|
3
3
|
export declare function addRisk(state: AnalyzerState, input: {
|
|
4
4
|
type: RiskCode;
|
|
5
|
+
groupKey?: string;
|
|
5
6
|
severity: Severity;
|
|
6
7
|
message: string;
|
|
7
8
|
permissionIds: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/003-risks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAQ,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvE,wBAAgB,OAAO,CACnB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GACF,aAAa,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/analyzer/steps/003-risks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAQ,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGvE,wBAAgB,OAAO,CACnB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE;IACH,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GACF,aAAa,CAyBf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { SkillAnalyzerResult } from "../../result.js";
|
|
2
|
+
import type { AnalyzerContext, AnalyzerState } from "../../types.js";
|
|
3
|
+
export declare function run003Risks(state: AnalyzerState, context?: Pick<AnalyzerContext, "showProgressBar" | "config">): Promise<SkillAnalyzerResult>;
|
|
3
4
|
//# sourceMappingURL=mod.d.ts.map
|