@cybedefend/vibedefend 1.8.3 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +135 -16
- package/dist/clients/antigravity.js +30 -6
- package/dist/clients/antigravity.js.map +1 -1
- package/dist/clients/claude-code.js +209 -17
- package/dist/clients/claude-code.js.map +1 -1
- package/dist/clients/codex.js +171 -11
- package/dist/clients/codex.js.map +1 -1
- package/dist/clients/cursor.js +149 -9
- package/dist/clients/cursor.js.map +1 -1
- package/dist/clients/dependency-check-wiring.js +24 -0
- package/dist/clients/dependency-check-wiring.js.map +1 -0
- package/dist/clients/opencode-plugin.js +905 -0
- package/dist/clients/opencode-plugin.js.map +1 -0
- package/dist/clients/opencode.js +653 -0
- package/dist/clients/opencode.js.map +1 -0
- package/dist/clients/registry.js +2 -0
- package/dist/clients/registry.js.map +1 -1
- package/dist/clients/vscode.js +106 -12
- package/dist/clients/vscode.js.map +1 -1
- package/dist/clients/windsurf.js +9 -1
- package/dist/clients/windsurf.js.map +1 -1
- package/dist/commands/mcp/index.js +11 -0
- package/dist/commands/mcp/index.js.map +1 -1
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/diagnostics.js +22 -3
- package/dist/diagnostics.js.map +1 -1
- package/dist/doctor.js +26 -1
- package/dist/doctor.js.map +1 -1
- package/dist/guards-evaluator/command-analysis.js +347 -86
- package/dist/guards-evaluator/command-analysis.js.map +1 -1
- package/dist/guards-evaluator/command-view.js +116 -16
- package/dist/guards-evaluator/command-view.js.map +1 -1
- package/dist/guards-evaluator/evaluate.js +185 -41
- package/dist/guards-evaluator/evaluate.js.map +1 -1
- package/dist/guards-evaluator/file-reads.js +202 -0
- package/dist/guards-evaluator/file-reads.js.map +1 -0
- package/dist/guards-evaluator/index.js +1 -1
- package/dist/guards-evaluator/index.js.map +1 -1
- package/dist/guards-evaluator/inline-danger.js +299 -0
- package/dist/guards-evaluator/inline-danger.js.map +1 -0
- package/dist/guards-evaluator/normalize.js +1186 -55
- package/dist/guards-evaluator/normalize.js.map +1 -1
- package/dist/guards-evaluator/regex.js +91 -4
- package/dist/guards-evaluator/regex.js.map +1 -1
- package/dist/guards-evaluator/shell-files.js +587 -0
- package/dist/guards-evaluator/shell-files.js.map +1 -0
- package/dist/guards-evaluator/triage.js +32 -2
- package/dist/guards-evaluator/triage.js.map +1 -1
- package/dist/hook-runner.js +25598 -5432
- package/dist/hooks/install.js +8 -3
- package/dist/hooks/install.js.map +1 -1
- package/dist/hooks/runtime/antigravity-session.js +109 -50
- package/dist/hooks/runtime/antigravity-session.js.map +1 -1
- package/dist/hooks/runtime/apply-patch.js +92 -0
- package/dist/hooks/runtime/apply-patch.js.map +1 -0
- package/dist/hooks/runtime/caller-gate.js +27 -0
- package/dist/hooks/runtime/caller-gate.js.map +1 -0
- package/dist/hooks/runtime/code-mode.js +259 -0
- package/dist/hooks/runtime/code-mode.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/api.js +179 -0
- package/dist/hooks/runtime/dependency-check/api.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/capabilities.js +99 -0
- package/dist/hooks/runtime/dependency-check/capabilities.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/checked-packages.js +48 -0
- package/dist/hooks/runtime/dependency-check/checked-packages.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/cwd.js +154 -0
- package/dist/hooks/runtime/dependency-check/commands/cwd.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/env.js +99 -0
- package/dist/hooks/runtime/dependency-check/commands/env.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/flags.js +164 -0
- package/dist/hooks/runtime/dependency-check/commands/flags.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/managers.js +418 -0
- package/dist/hooks/runtime/dependency-check/commands/managers.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/peel.js +111 -0
- package/dist/hooks/runtime/dependency-check/commands/peel.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/shell.js +217 -0
- package/dist/hooks/runtime/dependency-check/commands/shell.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands/types.js +4 -0
- package/dist/hooks/runtime/dependency-check/commands/types.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/commands.js +34 -0
- package/dist/hooks/runtime/dependency-check/commands.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/deadlines.js +69 -0
- package/dist/hooks/runtime/dependency-check/deadlines.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/dispatch.js +344 -0
- package/dist/hooks/runtime/dependency-check/dispatch.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/entering.js +63 -0
- package/dist/hooks/runtime/dependency-check/entering.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/exec-cache.js +36 -0
- package/dist/hooks/runtime/dependency-check/exec-cache.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/git-blob.js +116 -0
- package/dist/hooks/runtime/dependency-check/git-blob.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/hook.js +418 -0
- package/dist/hooks/runtime/dependency-check/hook.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/local-store.js +74 -0
- package/dist/hooks/runtime/dependency-check/local-store.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfile-walk.js +89 -0
- package/dist/hooks/runtime/dependency-check/lockfile-walk.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/bun.js +153 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/bun.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js +46 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/by-name.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js +91 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/cargo.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/composer.js +98 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/composer.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js +88 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/gemfile.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js +154 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/go-mod.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js +27 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/gradle-lockfile.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/graph.js +131 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/graph.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/npm.js +107 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/npm.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js +60 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/nuget-packages-lock.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pins.js +105 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pins.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js +34 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pip-report.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js +109 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/pnpm.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js +105 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/poetry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/uv.js +181 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/uv.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js +319 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yaml.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js +71 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yarn-berry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js +144 -0
- package/dist/hooks/runtime/dependency-check/lockfiles/yarn1.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/apply.js +110 -0
- package/dist/hooks/runtime/dependency-check/manifests/apply.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/diff.js +127 -0
- package/dist/hooks/runtime/dependency-check/manifests/diff.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/edit.js +259 -0
- package/dist/hooks/runtime/dependency-check/manifests/edit.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/json.js +109 -0
- package/dist/hooks/runtime/dependency-check/manifests/json.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/kind.js +40 -0
- package/dist/hooks/runtime/dependency-check/manifests/kind.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/patch.js +179 -0
- package/dist/hooks/runtime/dependency-check/manifests/patch.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/text.js +665 -0
- package/dist/hooks/runtime/dependency-check/manifests/text.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests/toml.js +350 -0
- package/dist/hooks/runtime/dependency-check/manifests/toml.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/manifests.js +14 -0
- package/dist/hooks/runtime/dependency-check/manifests.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/messages.js +270 -0
- package/dist/hooks/runtime/dependency-check/messages.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/net-baseline.js +157 -0
- package/dist/hooks/runtime/dependency-check/net-baseline.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/net-state.js +70 -0
- package/dist/hooks/runtime/dependency-check/net-state.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/pending-forces.js +54 -0
- package/dist/hooks/runtime/dependency-check/pending-forces.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/post-tool-use.js +108 -0
- package/dist/hooks/runtime/dependency-check/post-tool-use.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/ranges.js +369 -0
- package/dist/hooks/runtime/dependency-check/ranges.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/requirement-files.js +144 -0
- package/dist/hooks/runtime/dependency-check/requirement-files.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/bun.js +38 -0
- package/dist/hooks/runtime/dependency-check/resolvers/bun.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/bundler.js +218 -0
- package/dist/hooks/runtime/dependency-check/resolvers/bundler.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/cargo.js +303 -0
- package/dist/hooks/runtime/dependency-check/resolvers/cargo.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/composer.js +250 -0
- package/dist/hooks/runtime/dependency-check/resolvers/composer.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/config-files.js +27 -0
- package/dist/hooks/runtime/dependency-check/resolvers/config-files.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js +409 -0
- package/dist/hooks/runtime/dependency-check/resolvers/direct-only-registry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js +290 -0
- package/dist/hooks/runtime/dependency-check/resolvers/direct-only.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/gem.js +89 -0
- package/dist/hooks/runtime/dependency-check/resolvers/gem.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/go.js +313 -0
- package/dist/hooks/runtime/dependency-check/resolvers/go.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/npm.js +81 -0
- package/dist/hooks/runtime/dependency-check/resolvers/npm.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pip.js +229 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pip.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pipx.js +8 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pipx.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js +68 -0
- package/dist/hooks/runtime/dependency-check/resolvers/pnpm.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/poetry.js +70 -0
- package/dist/hooks/runtime/dependency-check/resolvers/poetry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/project.js +208 -0
- package/dist/hooks/runtime/dependency-check/resolvers/project.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/python-index.js +270 -0
- package/dist/hooks/runtime/dependency-check/resolvers/python-index.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/python.js +229 -0
- package/dist/hooks/runtime/dependency-check/resolvers/python.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/registry.js +221 -0
- package/dist/hooks/runtime/dependency-check/resolvers/registry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/shared.js +440 -0
- package/dist/hooks/runtime/dependency-check/resolvers/shared.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/tree.js +131 -0
- package/dist/hooks/runtime/dependency-check/resolvers/tree.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/uv.js +433 -0
- package/dist/hooks/runtime/dependency-check/resolvers/uv.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js +132 -0
- package/dist/hooks/runtime/dependency-check/resolvers/xml-lite.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js +106 -0
- package/dist/hooks/runtime/dependency-check/resolvers/yarn-berry.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/sandbox.js +328 -0
- package/dist/hooks/runtime/dependency-check/sandbox.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/specs.js +171 -0
- package/dist/hooks/runtime/dependency-check/specs.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/static-view.js +90 -0
- package/dist/hooks/runtime/dependency-check/static-view.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/stop-net.js +278 -0
- package/dist/hooks/runtime/dependency-check/stop-net.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/stop-wiring.js +94 -0
- package/dist/hooks/runtime/dependency-check/stop-wiring.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/tool-call.js +130 -0
- package/dist/hooks/runtime/dependency-check/tool-call.js.map +1 -0
- package/dist/hooks/runtime/dependency-check/types.js +96 -0
- package/dist/hooks/runtime/dependency-check/types.js.map +1 -0
- package/dist/hooks/runtime/emit.js +240 -52
- package/dist/hooks/runtime/emit.js.map +1 -1
- package/dist/hooks/runtime/exit-deadlock-guard.js +24 -8
- package/dist/hooks/runtime/exit-deadlock-guard.js.map +1 -1
- package/dist/hooks/runtime/fetch-rules.js +78 -29
- package/dist/hooks/runtime/fetch-rules.js.map +1 -1
- package/dist/hooks/runtime/grep-include.js +228 -0
- package/dist/hooks/runtime/grep-include.js.map +1 -0
- package/dist/hooks/runtime/pre-compact.js +1 -1
- package/dist/hooks/runtime/pre-compact.js.map +1 -1
- package/dist/hooks/runtime/pre-invocation.js +3 -3
- package/dist/hooks/runtime/pre-invocation.js.map +1 -1
- package/dist/hooks/runtime/repo-registry.js +72 -0
- package/dist/hooks/runtime/repo-registry.js.map +1 -0
- package/dist/hooks/runtime/repo-scope.js +75 -0
- package/dist/hooks/runtime/repo-scope.js.map +1 -0
- package/dist/hooks/runtime/resolve.js +11 -2
- package/dist/hooks/runtime/resolve.js.map +1 -1
- package/dist/hooks/runtime/runner-args.js +17 -2
- package/dist/hooks/runtime/runner-args.js.map +1 -1
- package/dist/hooks/runtime/script-resolve.js +21 -5
- package/dist/hooks/runtime/script-resolve.js.map +1 -1
- package/dist/hooks/runtime/session-activation.js +71 -18
- package/dist/hooks/runtime/session-activation.js.map +1 -1
- package/dist/hooks/runtime/session-review.js +136 -66
- package/dist/hooks/runtime/session-review.js.map +1 -1
- package/dist/hooks/runtime/session-start.js +68 -13
- package/dist/hooks/runtime/session-start.js.map +1 -1
- package/dist/hooks/runtime/session-writes.js +11 -5
- package/dist/hooks/runtime/session-writes.js.map +1 -1
- package/dist/hooks/runtime/shell-writes.js +7 -88
- package/dist/hooks/runtime/shell-writes.js.map +1 -1
- package/dist/hooks/runtime/sniff.js +227 -2
- package/dist/hooks/runtime/sniff.js.map +1 -1
- package/dist/hooks/runtime/target-resolve.js +32 -17
- package/dist/hooks/runtime/target-resolve.js.map +1 -1
- package/dist/hooks/runtime/unmapped-tools.js +77 -1
- package/dist/hooks/runtime/unmapped-tools.js.map +1 -1
- package/dist/hooks/runtime/user-prompt-submit.js +1 -1
- package/dist/hooks/runtime/user-prompt-submit.js.map +1 -1
- package/dist/hooks/runtime/work-dir.js +3 -0
- package/dist/hooks/runtime/work-dir.js.map +1 -1
- package/dist/hooks/shim.js +27 -20
- package/dist/hooks/shim.js.map +1 -1
- package/dist/index.js +40 -3
- package/dist/index.js.map +1 -1
- package/dist/install-scope.js +12 -0
- package/dist/install-scope.js.map +1 -0
- package/dist/install.js +188 -78
- package/dist/install.js.map +1 -1
- package/dist/link.js +55 -5
- package/dist/link.js.map +1 -1
- package/dist/mcp/config/hook.js +25 -0
- package/dist/mcp/config/hook.js.map +1 -1
- package/dist/org.js +3 -1
- package/dist/org.js.map +1 -1
- package/dist/prompts.js +96 -12
- package/dist/prompts.js.map +1 -1
- package/dist/refresh-hooks.js +67 -15
- package/dist/refresh-hooks.js.map +1 -1
- package/dist/repo/exclude-block.js +112 -0
- package/dist/repo/exclude-block.js.map +1 -0
- package/dist/repo/footer.js +93 -0
- package/dist/repo/footer.js.map +1 -0
- package/dist/repo/git-repo.js +77 -0
- package/dist/repo/git-repo.js.map +1 -0
- package/dist/repo/guarded-write.js +45 -0
- package/dist/repo/guarded-write.js.map +1 -0
- package/dist/repo/install-repo.js +508 -0
- package/dist/repo/install-repo.js.map +1 -0
- package/dist/repo/machine-wiring.js +122 -0
- package/dist/repo/machine-wiring.js.map +1 -0
- package/dist/repo/mcp-json.js +57 -0
- package/dist/repo/mcp-json.js.map +1 -0
- package/dist/repo/registry.js +53 -0
- package/dist/repo/registry.js.map +1 -0
- package/dist/repo/repo-mode-guard.js +83 -0
- package/dist/repo/repo-mode-guard.js.map +1 -0
- package/dist/repo/repo-setups.js +123 -0
- package/dist/repo/repo-setups.js.map +1 -0
- package/dist/repo/repo-status.js +283 -0
- package/dist/repo/repo-status.js.map +1 -0
- package/dist/repo/uninstall-repo.js +56 -0
- package/dist/repo/uninstall-repo.js.map +1 -0
- package/dist/repo/unsupported.js +14 -0
- package/dist/repo/unsupported.js.map +1 -0
- package/dist/shim.js +9 -7
- package/dist/status.js +53 -11
- package/dist/status.js.map +1 -1
- package/dist/uninstall.js +51 -3
- package/dist/uninstall.js.map +1 -1
- package/dist/update.js +6 -1
- package/dist/update.js.map +1 -1
- package/package.json +5 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dependency check's post-call step (BACK-262): when the developer
|
|
3
|
+
* accepted a blocked call (the client asked, the call ran), report the force
|
|
4
|
+
* for the check that asked, so the packages it flagged are excepted.
|
|
5
|
+
*
|
|
6
|
+
* The pre-call step (`hook.ts`) recorded a pending force under the client,
|
|
7
|
+
* the session and what pairs the two calls (E0 `pairKey`). Here the entry is
|
|
8
|
+
* taken, once, and reported: a call that ran, whether it succeeded or failed
|
|
9
|
+
* (`PostToolUseFailure`), was accepted. A refused call fires no post-call
|
|
10
|
+
* hook, so its entry expires unread.
|
|
11
|
+
*
|
|
12
|
+
* This hook never blocks and never prints: it exits 0 with nothing on
|
|
13
|
+
* stdout. A report that fails is silent and not retried (the entry is taken).
|
|
14
|
+
* It reports for the check that asked, never for packages it names itself.
|
|
15
|
+
*
|
|
16
|
+
* `index.ts` only dispatches here: it is outside the type check.
|
|
17
|
+
*/
|
|
18
|
+
import { loadRuntimeConfig, readStdinJson } from '../config.js';
|
|
19
|
+
import { resolveTokenWithRefresh } from '../resolve.js';
|
|
20
|
+
import { sessionIdOf } from '../session-activation.js';
|
|
21
|
+
import { detectClient } from '../sniff.js';
|
|
22
|
+
import { reportForce } from './api.js';
|
|
23
|
+
import { capabilitiesOf } from './capabilities.js';
|
|
24
|
+
import { makeCheckedPackages } from './checked-packages.js';
|
|
25
|
+
import { pairKeyOf } from './hook.js';
|
|
26
|
+
import { makePendingForces } from './pending-forces.js';
|
|
27
|
+
/** The report is one try, within this. */
|
|
28
|
+
export const FORCE_REPORT_TIMEOUT_MS = 5_000;
|
|
29
|
+
/** Runs the step and returns the exit code: always 0. Never throws, never prints. */
|
|
30
|
+
export async function runPostToolUseWith(run) {
|
|
31
|
+
try {
|
|
32
|
+
await reportPendingForce(run);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// A post-call hook never disturbs the agent.
|
|
36
|
+
}
|
|
37
|
+
return 0;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Production wiring: stdin and the real collaborators. `stdinEnvelope` is the
|
|
41
|
+
* payload the runner already read for its repo-mode caller gate (index.ts);
|
|
42
|
+
* stdin is read here only when none was.
|
|
43
|
+
*/
|
|
44
|
+
export async function runPostToolUseHook(stdinEnvelope) {
|
|
45
|
+
try {
|
|
46
|
+
const stdin = stdinEnvelope ?? (await readStdinJson());
|
|
47
|
+
return await runPostToolUseWith({ stdin, deps: productionDeps() });
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function productionDeps() {
|
|
54
|
+
return {
|
|
55
|
+
loadConfig: () => loadRuntimeConfig(),
|
|
56
|
+
resolveToken: (mcpName) => resolveTokenWithRefresh(mcpName),
|
|
57
|
+
report: (o) => reportForce(o),
|
|
58
|
+
pendingForces: makePendingForces(),
|
|
59
|
+
checkedPackages: makeCheckedPackages(),
|
|
60
|
+
capabilities: capabilitiesOf,
|
|
61
|
+
env: process.env,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async function reportPendingForce({ stdin, deps }) {
|
|
65
|
+
const client = detectClient(stdin);
|
|
66
|
+
if (client === 'unknown')
|
|
67
|
+
return;
|
|
68
|
+
const config = deps.loadConfig();
|
|
69
|
+
if (!config || config.hooks?.enablePackageCheck === false)
|
|
70
|
+
return;
|
|
71
|
+
const caps = deps.capabilities(client);
|
|
72
|
+
if (caps.postHook === null || caps.pairKey === null)
|
|
73
|
+
return;
|
|
74
|
+
const pairKey = pairKeyOf(caps.pairKey, stdin, shellCommandOf(stdin));
|
|
75
|
+
if (pairKey === null)
|
|
76
|
+
return;
|
|
77
|
+
const sessionId = sessionIdOf(stdin) ?? '';
|
|
78
|
+
const force = deps.pendingForces.take({ client, sessionId, pairKey });
|
|
79
|
+
if (force === null)
|
|
80
|
+
return;
|
|
81
|
+
const token = await deps.resolveToken(config.region.mcpName);
|
|
82
|
+
if (token) {
|
|
83
|
+
await deps.report({
|
|
84
|
+
apiBase: deps.env.CYBEDEFEND_API_BASE ?? force.apiBase ?? config.region.apiBase,
|
|
85
|
+
token,
|
|
86
|
+
projectId: force.projectId,
|
|
87
|
+
checkId: force.checkId,
|
|
88
|
+
timeoutMs: FORCE_REPORT_TIMEOUT_MS,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// The developer let the call run: what the forced check flagged entered
|
|
92
|
+
// with their say-so, so the Stop net does not check it again.
|
|
93
|
+
if (force.packages)
|
|
94
|
+
deps.checkedPackages.add(sessionId, force.packages);
|
|
95
|
+
}
|
|
96
|
+
/** The shell command a post-call payload carries (Cursor's `command`, or `tool_input.command`), else ''. */
|
|
97
|
+
function shellCommandOf(stdin) {
|
|
98
|
+
if (typeof stdin.command === 'string')
|
|
99
|
+
return stdin.command;
|
|
100
|
+
const input = stdin.tool_input;
|
|
101
|
+
if (typeof input === 'object' && input !== null) {
|
|
102
|
+
const command = input.command;
|
|
103
|
+
if (typeof command === 'string')
|
|
104
|
+
return command;
|
|
105
|
+
}
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=post-tool-use.js.map
|
|
@@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KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC7D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,mBAAmB,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO;YAC/E,KAAK;YACL,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,SAAS,EAAE,uBAAuB;SACnC,CAAC,CAAC;IACL,CAAC;IACD,wEAAwE;IACxE,8DAA8D;IAC9D,IAAI,KAAK,CAAC,QAAQ;QAAE,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,4GAA4G;AAC5G,SAAS,cAAc,CAAC,KAA8B;IACpD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC,OAAO,CAAC;IAC5D,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,OAAO,GAAI,KAAiC,CAAC,OAAO,CAAC;QAC3D,IAAI,OAAO,OAAO,KAAK,QAAQ;YAAE,OAAO,OAAO,CAAC;IAClD,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version ranges, read conservatively, for the managers that are checked on
|
|
3
|
+
* their direct packages only (`resolvers/direct-only.ts`). Pure.
|
|
4
|
+
*
|
|
5
|
+
* A matcher answers `true` (the range admits the version), `false`, or `null`
|
|
6
|
+
* when it does not understand the syntax: a caller treats `null` as "not
|
|
7
|
+
* verified", never as a guess. The same goes for a prerelease version, which
|
|
8
|
+
* only a range that itself names a prerelease of the same release admits.
|
|
9
|
+
*/
|
|
10
|
+
import { VERSION_MAX } from './types.js';
|
|
11
|
+
const VER_RE = /^v?(\d{1,9}(?:\.\d{1,9}){0,3})(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
12
|
+
export function parseVer(v) {
|
|
13
|
+
const m = VER_RE.exec(v.trim());
|
|
14
|
+
if (m === null)
|
|
15
|
+
return null;
|
|
16
|
+
return { nums: m[1].split('.').map(Number), pre: m[2] === undefined ? null : m[2].split('.') };
|
|
17
|
+
}
|
|
18
|
+
function comparePre(a, b) {
|
|
19
|
+
if (a === null || b === null)
|
|
20
|
+
return a === b ? 0 : a === null ? 1 : -1; // a release is above its prereleases
|
|
21
|
+
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
22
|
+
if (a[i] === undefined)
|
|
23
|
+
return -1;
|
|
24
|
+
if (b[i] === undefined)
|
|
25
|
+
return 1;
|
|
26
|
+
const an = /^\d+$/.test(a[i]);
|
|
27
|
+
const bn = /^\d+$/.test(b[i]);
|
|
28
|
+
if (an && bn) {
|
|
29
|
+
const d = Number(a[i]) - Number(b[i]);
|
|
30
|
+
if (d !== 0)
|
|
31
|
+
return d < 0 ? -1 : 1;
|
|
32
|
+
}
|
|
33
|
+
else if (an !== bn)
|
|
34
|
+
return an ? -1 : 1;
|
|
35
|
+
else if (a[i] !== b[i])
|
|
36
|
+
return a[i] < b[i] ? -1 : 1;
|
|
37
|
+
}
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
export function compareVer(a, b) {
|
|
41
|
+
for (let i = 0; i < Math.max(a.nums.length, b.nums.length); i++) {
|
|
42
|
+
const d = (a.nums[i] ?? 0) - (b.nums[i] ?? 0);
|
|
43
|
+
if (d !== 0)
|
|
44
|
+
return d < 0 ? -1 : 1;
|
|
45
|
+
}
|
|
46
|
+
return comparePre(a.pre, b.pre);
|
|
47
|
+
}
|
|
48
|
+
/** The highest of some version strings; null when one is not a version or the list is empty. */
|
|
49
|
+
export function highestVersion(versions) {
|
|
50
|
+
let best = null;
|
|
51
|
+
for (const text of versions) {
|
|
52
|
+
const v = parseVer(text);
|
|
53
|
+
if (v === null)
|
|
54
|
+
return null;
|
|
55
|
+
if (best === null || compareVer(v, best.v) > 0)
|
|
56
|
+
best = { text, v };
|
|
57
|
+
}
|
|
58
|
+
return best?.text ?? null;
|
|
59
|
+
}
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
// Exact versions, per ecosystem: the ones sent as they are
|
|
62
|
+
// ---------------------------------------------------------------------------
|
|
63
|
+
const SEMVER_EXACT_RE = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
64
|
+
const MAVEN_EXACT_RE = /^\d[0-9A-Za-z._-]*$/;
|
|
65
|
+
const NUGET_EXACT_RE = /^\d+(?:\.\d+){0,3}(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
66
|
+
const within = (v) => (v.length <= VERSION_MAX ? v : null);
|
|
67
|
+
/** npm and Pub: a bare `x.y.z`. */
|
|
68
|
+
export const semverExact = (range) => (range !== undefined && SEMVER_EXACT_RE.test(range) ? within(range) : null);
|
|
69
|
+
/** Maven and Gradle: a literal version; a dynamic one (`+`, `LATEST`, a snapshot) or a range is not. */
|
|
70
|
+
export function mavenExact(range) {
|
|
71
|
+
if (range === undefined || !MAVEN_EXACT_RE.test(range) || /snapshot|^(latest|release)$/i.test(range))
|
|
72
|
+
return null;
|
|
73
|
+
return within(range);
|
|
74
|
+
}
|
|
75
|
+
/** NuGet: `[x]` is exactly that version. A bare `x` is a minimum (`nugetMinimum`). */
|
|
76
|
+
export function nugetExact(range) {
|
|
77
|
+
const bare = range === undefined ? undefined : /^\[\s*([^,\s]+)\s*\]$/.exec(range)?.[1];
|
|
78
|
+
return bare !== undefined && NUGET_EXACT_RE.test(bare) ? within(bare) : null;
|
|
79
|
+
}
|
|
80
|
+
/** NuGet: a bare version is a minimum; with nothing pinned, the lowest applicable version, itself, is installed. */
|
|
81
|
+
export const nugetMinimum = (range) => (range !== undefined && NUGET_EXACT_RE.test(range) ? within(range) : null);
|
|
82
|
+
/** Hex: a bare version, or `== x.y.z` (a bare version in an Elixir requirement means `==`). */
|
|
83
|
+
export function hexExact(range) {
|
|
84
|
+
if (range === undefined)
|
|
85
|
+
return null;
|
|
86
|
+
const bare = /^==\s*(\S+)$/.exec(range)?.[1] ?? range;
|
|
87
|
+
return SEMVER_EXACT_RE.test(bare) ? within(bare) : null;
|
|
88
|
+
}
|
|
89
|
+
const PARTIAL_RE = /^v?(\d+|[xX*])(?:\.(\d+|[xX*]))?(?:\.(\d+|[xX*]))?(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
90
|
+
function parsePartial(text) {
|
|
91
|
+
if (text === '' || text === '*' || /^[xX]$/.test(text))
|
|
92
|
+
return { nums: [], pre: null };
|
|
93
|
+
const m = PARTIAL_RE.exec(text);
|
|
94
|
+
if (m === null)
|
|
95
|
+
return null;
|
|
96
|
+
const nums = [];
|
|
97
|
+
for (const part of [m[1], m[2], m[3]]) {
|
|
98
|
+
if (part === undefined || /^[xX*]$/.test(part))
|
|
99
|
+
break;
|
|
100
|
+
nums.push(Number(part));
|
|
101
|
+
}
|
|
102
|
+
return { nums, pre: m[4] === undefined ? null : m[4].split('.') };
|
|
103
|
+
}
|
|
104
|
+
const ver = (nums, pre = null) => ({ nums: [nums[0] ?? 0, nums[1] ?? 0, nums[2] ?? 0], pre });
|
|
105
|
+
/** The first version past everything that starts with the `nums` (`1.2` → `1.3.0`). */
|
|
106
|
+
const nextOf = (nums) => (nums.length === 0 ? ver([]) : ver([...nums.slice(0, -1), nums[nums.length - 1] + 1]));
|
|
107
|
+
function inInterval(i, v) {
|
|
108
|
+
if (i.lo !== undefined) {
|
|
109
|
+
const c = compareVer(v, i.lo.v);
|
|
110
|
+
if (c < 0 || (c === 0 && !i.lo.inclusive))
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (i.hi !== undefined) {
|
|
114
|
+
const c = compareVer(v, i.hi.v);
|
|
115
|
+
if (c > 0 || (c === 0 && !i.hi.inclusive))
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
/** One comparator (`^1.2.3`, `>=1`, `~1.2`, `1.x`) as an interval; null when it is not understood. */
|
|
121
|
+
function comparatorInterval(token, dialect) {
|
|
122
|
+
const m = /^(\^|~>?|>=|<=|>|<|=)?(.*)$/.exec(token);
|
|
123
|
+
if (m === null)
|
|
124
|
+
return null;
|
|
125
|
+
const op = m[1] ?? '';
|
|
126
|
+
const p = parsePartial(m[2]);
|
|
127
|
+
if (p === null)
|
|
128
|
+
return null;
|
|
129
|
+
if (dialect === 'dart' && (/[xX*]/.test(m[2]) || op === '~' || op === '~>' || op === '=' || m[2] === ''))
|
|
130
|
+
return null;
|
|
131
|
+
const full = p.nums.length === 3;
|
|
132
|
+
const low = ver(p.nums, p.pre);
|
|
133
|
+
const pre = p.pre === null ? null : low;
|
|
134
|
+
switch (op) {
|
|
135
|
+
case '':
|
|
136
|
+
case '=':
|
|
137
|
+
return { interval: full ? { lo: { v: low, inclusive: true }, hi: { v: low, inclusive: true } } : { lo: { v: low, inclusive: true }, hi: p.nums.length === 0 ? undefined : { v: nextOf(p.nums), inclusive: false } }, pre };
|
|
138
|
+
case '>=':
|
|
139
|
+
return { interval: { lo: { v: low, inclusive: true } }, pre };
|
|
140
|
+
case '>':
|
|
141
|
+
return { interval: full ? { lo: { v: low, inclusive: false } } : { lo: { v: nextOf(p.nums), inclusive: true } }, pre };
|
|
142
|
+
case '<':
|
|
143
|
+
return { interval: { hi: { v: low, inclusive: false } }, pre };
|
|
144
|
+
case '<=':
|
|
145
|
+
return { interval: full ? { hi: { v: low, inclusive: true } } : { hi: { v: nextOf(p.nums), inclusive: false } }, pre };
|
|
146
|
+
case '~':
|
|
147
|
+
case '~>': {
|
|
148
|
+
const upTo = p.nums.length >= 2 ? [p.nums[0], p.nums[1]] : p.nums.slice(0, 1);
|
|
149
|
+
return { interval: { lo: { v: low, inclusive: true }, hi: p.nums.length === 0 ? undefined : { v: nextOf(upTo), inclusive: false } }, pre };
|
|
150
|
+
}
|
|
151
|
+
case '^': {
|
|
152
|
+
const [a = 0, b, c] = p.nums;
|
|
153
|
+
let hi;
|
|
154
|
+
if (p.nums.length === 0)
|
|
155
|
+
hi = undefined;
|
|
156
|
+
else if (a > 0 || b === undefined)
|
|
157
|
+
hi = ver([a + 1]);
|
|
158
|
+
else if (b > 0 || c === undefined)
|
|
159
|
+
hi = ver([0, b + 1]);
|
|
160
|
+
else
|
|
161
|
+
hi = ver([0, 0, c + 1]);
|
|
162
|
+
return { interval: { lo: { v: low, inclusive: true }, hi: hi === undefined ? undefined : { v: hi, inclusive: false } }, pre };
|
|
163
|
+
}
|
|
164
|
+
default:
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/** Splits a set of comparators; a hyphen range (`1.2.3 - 2.3.4`) is turned into its two bounds. */
|
|
169
|
+
function comparatorsOf(set) {
|
|
170
|
+
const hyphen = /^(\S+)\s+-\s+(\S+)$/.exec(set.trim());
|
|
171
|
+
if (hyphen !== null) {
|
|
172
|
+
const lo = parsePartial(hyphen[1]);
|
|
173
|
+
const hi = parsePartial(hyphen[2]);
|
|
174
|
+
if (lo === null || hi === null || lo.nums.length === 0)
|
|
175
|
+
return null;
|
|
176
|
+
return [`>=${hyphen[1]}`, hi.nums.length === 3 ? `<=${hyphen[2]}` : `<${nextOf(hi.nums).nums.join('.')}`];
|
|
177
|
+
}
|
|
178
|
+
const joined = set.trim().replace(/(\^|~>?|>=|<=|>|<|=)\s+/g, '$1');
|
|
179
|
+
return joined === '' ? [''] : joined.split(/\s+/);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Whether an npm range (node-semver: `^`, `~`, comparators, `x` wildcards,
|
|
183
|
+
* `||`, hyphen ranges) or a Pub constraint (`^`, comparators) admits the
|
|
184
|
+
* version. A prerelease version needs a comparator of the same release that
|
|
185
|
+
* names a prerelease, as node-semver does.
|
|
186
|
+
*/
|
|
187
|
+
export function npmAdmits(range, version, dialect = 'npm') {
|
|
188
|
+
const v = parseVer(version);
|
|
189
|
+
if (v === null || v.nums.length > 3)
|
|
190
|
+
return null;
|
|
191
|
+
const sets = dialect === 'dart' ? [range] : range.split('||');
|
|
192
|
+
if (dialect === 'dart' && range.includes('||'))
|
|
193
|
+
return null;
|
|
194
|
+
let understood = true;
|
|
195
|
+
for (const set of sets) {
|
|
196
|
+
const tokens = comparatorsOf(set);
|
|
197
|
+
if (tokens === null) {
|
|
198
|
+
understood = false;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const parsed = tokens.map((t) => comparatorInterval(t, dialect));
|
|
202
|
+
if (parsed.some((p) => p === null)) {
|
|
203
|
+
understood = false;
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const ok = parsed.every((p) => inInterval(p.interval, v));
|
|
207
|
+
if (!ok)
|
|
208
|
+
continue;
|
|
209
|
+
if (v.pre !== null && !parsed.some((p) => p.pre !== null && [0, 1, 2].every((i) => p.pre.nums[i] === v.nums[i])))
|
|
210
|
+
continue;
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
return understood ? false : null;
|
|
214
|
+
}
|
|
215
|
+
// ---------------------------------------------------------------------------
|
|
216
|
+
// Maven, Gradle and NuGet interval notation
|
|
217
|
+
// ---------------------------------------------------------------------------
|
|
218
|
+
/** `[1.0,2.0)`, `(,1.0]`, `[1.0]`, and several of them separated by a comma. */
|
|
219
|
+
function intervalsOf(range) {
|
|
220
|
+
const text = range.replace(/\s+/g, '');
|
|
221
|
+
const out = [];
|
|
222
|
+
const re = /([[(])([^[\]()]*)([\])])(?:,(?=[[(])|$)/y;
|
|
223
|
+
let at = 0;
|
|
224
|
+
while (at < text.length) {
|
|
225
|
+
re.lastIndex = at;
|
|
226
|
+
const m = re.exec(text);
|
|
227
|
+
if (m === null)
|
|
228
|
+
return null;
|
|
229
|
+
at = re.lastIndex;
|
|
230
|
+
const [, open, body, close] = m;
|
|
231
|
+
const parts = body.split(',');
|
|
232
|
+
if (parts.length === 1) {
|
|
233
|
+
const exact = parseVer(parts[0]);
|
|
234
|
+
if (exact === null || open !== '[' || close !== ']')
|
|
235
|
+
return null;
|
|
236
|
+
out.push({ lo: { v: exact, inclusive: true }, hi: { v: exact, inclusive: true } });
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (parts.length !== 2)
|
|
240
|
+
return null;
|
|
241
|
+
const lo = parts[0] === '' ? undefined : parseVer(parts[0]);
|
|
242
|
+
const hi = parts[1] === '' ? undefined : parseVer(parts[1]);
|
|
243
|
+
if (lo === null || hi === null)
|
|
244
|
+
return null;
|
|
245
|
+
out.push({
|
|
246
|
+
lo: lo === undefined ? undefined : { v: lo, inclusive: open === '[' },
|
|
247
|
+
hi: hi === undefined ? undefined : { v: hi, inclusive: close === ']' },
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return out.length === 0 ? null : out;
|
|
251
|
+
}
|
|
252
|
+
/** A floating version: `1.+` or `1.2.+` (Gradle), `1.*` or `*` (NuGet): the versions that start with its numbers. */
|
|
253
|
+
function floatingPrefix(range, wildcard) {
|
|
254
|
+
if (range === wildcard)
|
|
255
|
+
return [];
|
|
256
|
+
const m = new RegExp(`^(\\d+(?:\\.\\d+){0,2})\\.\\${wildcard}$`).exec(range);
|
|
257
|
+
return m === null ? null : m[1].split('.').map(Number);
|
|
258
|
+
}
|
|
259
|
+
const startsWith = (v, prefix) => prefix.every((n, i) => v.nums[i] === n);
|
|
260
|
+
/** Whether a Gradle version range (`[a,b)`, `1.+`) admits the version; a plain version is a literal one. */
|
|
261
|
+
export function gradleAdmits(range, version) {
|
|
262
|
+
const v = parseVer(version);
|
|
263
|
+
if (v === null || v.pre !== null)
|
|
264
|
+
return null;
|
|
265
|
+
const prefix = floatingPrefix(range, '+');
|
|
266
|
+
if (prefix !== null)
|
|
267
|
+
return startsWith(v, prefix);
|
|
268
|
+
const intervals = intervalsOf(range);
|
|
269
|
+
return intervals === null ? null : intervals.some((i) => inInterval(i, v));
|
|
270
|
+
}
|
|
271
|
+
/** Whether a NuGet version range admits the version: `[a,b)`, `1.*`, or a plain version, which is a minimum. */
|
|
272
|
+
export function nugetAdmits(range, version) {
|
|
273
|
+
const v = parseVer(version);
|
|
274
|
+
if (v === null || v.pre !== null)
|
|
275
|
+
return null;
|
|
276
|
+
const prefix = floatingPrefix(range, '*');
|
|
277
|
+
if (prefix !== null)
|
|
278
|
+
return startsWith(v, prefix);
|
|
279
|
+
const plain = parseVer(range);
|
|
280
|
+
if (plain !== null && !/^[[(]/.test(range))
|
|
281
|
+
return inInterval({ lo: { v: plain, inclusive: true } }, v);
|
|
282
|
+
const intervals = intervalsOf(range);
|
|
283
|
+
return intervals === null ? null : intervals.some((i) => inInterval(i, v));
|
|
284
|
+
}
|
|
285
|
+
// ---------------------------------------------------------------------------
|
|
286
|
+
// Hex (Elixir requirements)
|
|
287
|
+
// ---------------------------------------------------------------------------
|
|
288
|
+
const HEX_CLAUSE_RE = /^(==|!=|>=|<=|>|<|~>)?\s*(\d+(?:\.\d+){0,2}(?:-[0-9A-Za-z.-]+)?)$/;
|
|
289
|
+
/** The clauses of one alternative: its words split at `and`, each clause's words joined. */
|
|
290
|
+
function clausesOf(words) {
|
|
291
|
+
const out = [''];
|
|
292
|
+
for (const w of words) {
|
|
293
|
+
if (w === 'and')
|
|
294
|
+
out.push('');
|
|
295
|
+
else
|
|
296
|
+
out[out.length - 1] = out[out.length - 1] === '' ? w : `${out[out.length - 1]} ${w}`;
|
|
297
|
+
}
|
|
298
|
+
return out;
|
|
299
|
+
}
|
|
300
|
+
/** Whether an Elixir `Version` requirement (`~> 1.2`, `>= 1.0.0 and < 2.0.0`, `or`) admits the version. */
|
|
301
|
+
export function hexAdmits(requirement, version) {
|
|
302
|
+
const v = parseVer(version);
|
|
303
|
+
if (v === null || v.nums.length !== 3)
|
|
304
|
+
return null;
|
|
305
|
+
let understood = true;
|
|
306
|
+
// Words, not a pattern over the whole text: `or` separates alternatives, `and` clauses.
|
|
307
|
+
const words = requirement.trim().split(/\s+/);
|
|
308
|
+
const alternatives = [[]];
|
|
309
|
+
for (const w of words) {
|
|
310
|
+
if (w === 'or')
|
|
311
|
+
alternatives.push([]);
|
|
312
|
+
else
|
|
313
|
+
alternatives[alternatives.length - 1].push(w);
|
|
314
|
+
}
|
|
315
|
+
for (const altWords of alternatives) {
|
|
316
|
+
const alt = altWords.join(' ');
|
|
317
|
+
let all = true;
|
|
318
|
+
let preNamed = false;
|
|
319
|
+
for (const clause of clausesOf(altWords)) {
|
|
320
|
+
const m = HEX_CLAUSE_RE.exec(clause.trim());
|
|
321
|
+
if (m === null)
|
|
322
|
+
return null;
|
|
323
|
+
const op = m[1] ?? '==';
|
|
324
|
+
const target = parseVer(m[2]);
|
|
325
|
+
if (target === null)
|
|
326
|
+
return null;
|
|
327
|
+
if (target.pre !== null)
|
|
328
|
+
preNamed = true;
|
|
329
|
+
const c = compareVer(v, { nums: [target.nums[0], target.nums[1] ?? 0, target.nums[2] ?? 0], pre: target.pre });
|
|
330
|
+
let ok;
|
|
331
|
+
switch (op) {
|
|
332
|
+
case '==':
|
|
333
|
+
ok = c === 0;
|
|
334
|
+
break;
|
|
335
|
+
case '!=':
|
|
336
|
+
ok = c !== 0;
|
|
337
|
+
break;
|
|
338
|
+
case '>=':
|
|
339
|
+
ok = c >= 0;
|
|
340
|
+
break;
|
|
341
|
+
case '<=':
|
|
342
|
+
ok = c <= 0;
|
|
343
|
+
break;
|
|
344
|
+
case '>':
|
|
345
|
+
ok = c > 0;
|
|
346
|
+
break;
|
|
347
|
+
case '<':
|
|
348
|
+
ok = c < 0;
|
|
349
|
+
break;
|
|
350
|
+
default: {
|
|
351
|
+
// `~> 2.0` allows up to 3.0.0; `~> 2.1.2` up to 2.2.0; `~> 2` is not a requirement.
|
|
352
|
+
if (target.nums.length < 2) {
|
|
353
|
+
understood = false;
|
|
354
|
+
ok = false;
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
const upper = target.nums.length === 2 ? ver([target.nums[0] + 1]) : ver([target.nums[0], target.nums[1] + 1]);
|
|
358
|
+
ok = c >= 0 && compareVer(v, upper) < 0;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (!ok)
|
|
362
|
+
all = false;
|
|
363
|
+
}
|
|
364
|
+
if (all && (v.pre === null || preNamed))
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
return understood ? false : null;
|
|
368
|
+
}
|
|
369
|
+
//# sourceMappingURL=ranges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ranges.js","sourceRoot":"","sources":["../../../../src/hooks/runtime/dependency-check/ranges.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAYzC,MAAM,MAAM,GAAG,4EAA4E,CAAC;AAE5F,MAAM,UAAU,QAAQ,CAAC,CAAS;IAChC,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI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KAAK,GAAG;oBAAE,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;oBAAC,MAAM;gBAC5B,OAAO,CAAC,CAAC,CAAC;oBACR,oFAAoF;oBACpF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC3B,UAAU,GAAG,KAAK,CAAC;wBACnB,EAAE,GAAG,KAAK,CAAC;wBACX,MAAM;oBACR,CAAC;oBACD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAC/G,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;gBAC1C,CAAC;YACH,CAAC;YACD,IAAI,CAAC,EAAE;gBAAE,GAAG,GAAG,KAAK,CAAC;QACvB,CAAC;QACD,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,IAAI,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;IACvD,CAAC;IACD,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `pip install -r <file>` (and `uv pip install -r <file>`, `uv pip sync
|
|
3
|
+
* <file>`) brings that was not there before: the file's registry lines added
|
|
4
|
+
* or changed since the last commit (BACK-262).
|
|
5
|
+
*
|
|
6
|
+
* A requirements file has no lockfile, so a requirement the agent added by an
|
|
7
|
+
* edit is checked on its own name and version only (an edit runs no
|
|
8
|
+
* interpreter), and its transitive dependencies enter with the next install.
|
|
9
|
+
* That install is the last chance to check them: its file's new lines become
|
|
10
|
+
* the command's specs, resolved with the command's own manager (pip's dry run
|
|
11
|
+
* with the user's interpreter, as for `pip install <spec>`). An unchanged
|
|
12
|
+
* file adds nothing and starts nothing.
|
|
13
|
+
*
|
|
14
|
+
* - The committed version is read with `git-blob.ts` (`git cat-file`, never a
|
|
15
|
+
* command the repository can configure). A file git does not hold
|
|
16
|
+
* (untracked, ignored, outside any repository), or one git could not
|
|
17
|
+
* answer for, counts as new: every line.
|
|
18
|
+
* - Files it includes (`-r`, `-c`) are never read: each is told as not
|
|
19
|
+
* verified (`include_not_followed`), changed or not, since what it holds
|
|
20
|
+
* may have changed too.
|
|
21
|
+
* - An index or a links location named in the file (`--index-url`, `-f`,
|
|
22
|
+
* `--no-index`) puts the packages on another registry: the command is then
|
|
23
|
+
* checked on its direct packages (`custom_registry`), as for an index named
|
|
24
|
+
* on the command line.
|
|
25
|
+
*
|
|
26
|
+
* - Only a `.txt` or `.in` file whose real path stays inside the project (the
|
|
27
|
+
* repository the command runs in, else its folder) is read. Any other file
|
|
28
|
+
* the command names is told as not verified and never read, so nothing of
|
|
29
|
+
* a file elsewhere on the machine is sent or shown.
|
|
30
|
+
*
|
|
31
|
+
* Nothing here writes, logs, or runs anything but that one git read per file.
|
|
32
|
+
*/
|
|
33
|
+
import { realpathSync, statSync, readFileSync } from 'node:fs';
|
|
34
|
+
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
35
|
+
import { MAX_BLOB_BYTES, findRepoRoot, readHeadBlob } from './git-blob.js';
|
|
36
|
+
import { directChanges } from './manifests.js';
|
|
37
|
+
import { longOptionPrefixes } from './manifests/text.js';
|
|
38
|
+
import { LINKS_OPTION_RE } from './resolvers/pip.js';
|
|
39
|
+
import { dedupe } from './resolvers/shared.js';
|
|
40
|
+
/** Time one `git cat-file` may take. */
|
|
41
|
+
const GIT_READ_MS = 5_000;
|
|
42
|
+
/** `-r`, `-c` and their long forms (an unambiguous prefix, as pip reads them), the file attached or not. */
|
|
43
|
+
const INCLUDE_RE = new RegExp(`^(?:-r|-c|${longOptionPrefixes('--requirement', '--requirem')}(?![\\w-])|${longOptionPrefixes('--constraint', '--cons')}(?![\\w-]))(?:\\s*=\\s*|\\s+|(?=[^\\s=-]))(\\S+)`);
|
|
44
|
+
/** Only a requirements file is read as one (`pip install -r pyproject.toml` is not a list of lines). */
|
|
45
|
+
const REQUIREMENTS_FILE_RE = /\.(txt|in)$/i;
|
|
46
|
+
const realOrNull = (path) => {
|
|
47
|
+
try {
|
|
48
|
+
return realpathSync(path);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/** True when `path` lies inside `root`, both compared by their real paths. */
|
|
55
|
+
function inside(root, path) {
|
|
56
|
+
const rel = relative(root, path);
|
|
57
|
+
return rel === '' || (!rel.startsWith(`..${sep}`) && rel !== '..' && !isAbsolute(rel));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A regular file's text within the readers' cap, following links as pip does,
|
|
61
|
+
* but only when its real path stays inside `boundary`: a file elsewhere on the
|
|
62
|
+
* machine (`-r /etc/hosts`, `-r ../other/x.txt`, a link leading out) is never
|
|
63
|
+
* read, so none of its lines is ever sent or told. Null otherwise.
|
|
64
|
+
*/
|
|
65
|
+
function readFile(path, boundary) {
|
|
66
|
+
if (!REQUIREMENTS_FILE_RE.test(path))
|
|
67
|
+
return null;
|
|
68
|
+
const real = realOrNull(path);
|
|
69
|
+
const realBoundary = realOrNull(boundary);
|
|
70
|
+
if (real === null || realBoundary === null || !inside(realBoundary, real))
|
|
71
|
+
return null;
|
|
72
|
+
try {
|
|
73
|
+
const st = statSync(real);
|
|
74
|
+
if (!st.isFile() || st.size > MAX_BLOB_BYTES)
|
|
75
|
+
return null;
|
|
76
|
+
return readFileSync(real, 'utf8');
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/** The file as committed; null when git holds none, or cannot say. */
|
|
83
|
+
async function committed(path, deadlineMs, spawnImpl) {
|
|
84
|
+
const root = findRepoRoot(dirname(path));
|
|
85
|
+
if (root === null)
|
|
86
|
+
return null;
|
|
87
|
+
const rel = relative(root, path).split(sep).join('/');
|
|
88
|
+
if (rel === '' || rel.startsWith('../') || isAbsolute(rel))
|
|
89
|
+
return null;
|
|
90
|
+
const head = await readHeadBlob(root, rel, { deadlineMs: Math.max(0, Math.min(GIT_READ_MS, deadlineMs)), spawnImpl });
|
|
91
|
+
return head.kind === 'blob' ? head.text : null;
|
|
92
|
+
}
|
|
93
|
+
/** The files a requirements file includes, as written. */
|
|
94
|
+
export function includedFiles(text) {
|
|
95
|
+
const out = [];
|
|
96
|
+
let buf = '';
|
|
97
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
98
|
+
if (/\\\s*$/.test(raw)) {
|
|
99
|
+
buf += raw.replace(/\\\s*$/, ' ');
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const line = (buf + raw).replace(/(^|\s)#.*$/, '$1').trim();
|
|
103
|
+
buf = '';
|
|
104
|
+
const m = INCLUDE_RE.exec(line);
|
|
105
|
+
if (m)
|
|
106
|
+
out.push(m[1]);
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
}
|
|
110
|
+
/** The new lines of each file, relative to `cwd`. Never throws. */
|
|
111
|
+
export async function requirementFileChanges(files, cwd, opts) {
|
|
112
|
+
const now = opts.now ?? Date.now;
|
|
113
|
+
const startedAt = now();
|
|
114
|
+
const left = () => opts.deadlineMs - (now() - startedAt);
|
|
115
|
+
const specs = [];
|
|
116
|
+
const notVerified = [];
|
|
117
|
+
let customRegistry = false;
|
|
118
|
+
// The project: the repository the command runs in, else its folder.
|
|
119
|
+
const boundary = findRepoRoot(cwd) ?? cwd;
|
|
120
|
+
for (const file of files) {
|
|
121
|
+
const path = resolve(cwd, file);
|
|
122
|
+
const text = readFile(path, boundary);
|
|
123
|
+
if (text === null) {
|
|
124
|
+
notVerified.push({ name: file, reason: 'resolution_failed' });
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
let before;
|
|
128
|
+
try {
|
|
129
|
+
before = await committed(path, left(), opts.spawnImpl);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
before = null;
|
|
133
|
+
}
|
|
134
|
+
const changes = directChanges('requirements*.txt', before, text);
|
|
135
|
+
specs.push(...changes.specs);
|
|
136
|
+
notVerified.push(...changes.notVerified);
|
|
137
|
+
for (const included of includedFiles(text))
|
|
138
|
+
notVerified.push({ name: included, reason: 'include_not_followed' });
|
|
139
|
+
if (changes.specs.some((s) => s.registry === 'custom') || LINKS_OPTION_RE.test(text))
|
|
140
|
+
customRegistry = true;
|
|
141
|
+
}
|
|
142
|
+
return { specs, notVerified: dedupe(notVerified), customRegistry };
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=requirement-files.js.map
|