@lobu/runtime-device 21.2.1 → 23.0.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/dist/component.json +1 -1
- package/dist/dependencies.bun.lock +91 -83
- package/npm-shrinkwrap.json +492 -438
- package/package.json +12 -2
- package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
- package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
- package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
- package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
- package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
- package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
- package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
- package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
- package/vendor/cli/dist/commands/init.d.ts +0 -2
- package/vendor/cli/dist/commands/init.js +0 -27
- package/vendor/cli/dist/commands/login.d.ts +17 -0
- package/vendor/cli/dist/commands/login.js +43 -17
- package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
- package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
- package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
- package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
- package/vendor/cli/dist/config/define.d.ts +21 -15
- package/vendor/cli/dist/config/define.js +2 -2
- package/vendor/cli/dist/connectors/README.md +21 -6
- package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
- package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
- package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
- package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
- package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
- package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
- package/vendor/cli/dist/connectors/agentid.ts +43 -0
- package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
- package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
- package/vendor/cli/dist/connectors/github-identity.ts +28 -3
- package/vendor/cli/dist/connectors/github.ts +101 -59
- package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
- package/vendor/cli/dist/connectors/google_drive.ts +16 -2
- package/vendor/cli/dist/connectors/google_gmail.ts +52 -33
- package/vendor/cli/dist/connectors/herdr.ts +406 -0
- package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
- package/vendor/cli/dist/connectors/jira.ts +35 -227
- package/vendor/cli/dist/connectors/linear.ts +7 -4
- package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
- package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
- package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
- package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
- package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
- package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
- package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
- package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
- package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
- package/vendor/cli/dist/connectors/postgres.ts +27 -2
- package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
- package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
- package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
- package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
- package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
- package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
- package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
- package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
- package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
- package/vendor/cli/dist/connectors/x-identity.ts +31 -2
- package/vendor/cli/dist/connectors/x.ts +539 -253
- package/vendor/cli/dist/index.js +1 -37
- package/vendor/cli/dist/internal/context.d.ts +10 -0
- package/vendor/cli/dist/internal/context.js +26 -16
- package/vendor/cli/dist/internal/node-version.d.ts +1 -1
- package/vendor/cli/dist/internal/node-version.js +1 -1
- package/vendor/cli/dist/internal/oauth.d.ts +3 -1
- package/vendor/cli/dist/internal/oauth.js +4 -3
- package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
- package/vendor/cli/dist/internal/runtime-components.js +67 -2
- package/vendor/cli/dist/mac-auth.js +17 -1
- package/vendor/cli/dist/providers.json +1 -1
- package/vendor/cli/dist/runtime-components.json +4 -4
- package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
- package/vendor/cli/dist/templates/README.md.tmpl +1 -1
- package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
- package/vendor/cli/dist/vendor/ora/index.js +424 -0
- package/vendor/cli/dist/vendor/ora/license +9 -0
- package/vendor/cli/dist/vendor/ora/package.json +64 -0
- package/vendor/cli/dist/vendor/ora/readme.md +329 -0
- package/vendor/cli/package.json +2 -2
- package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
- package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
- package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
- package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
- package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
- package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
- package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
- package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
- package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
- package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
- package/vendor/connector-sdk/dist/define-connector.js +3 -0
- package/vendor/connector-sdk/dist/index.d.ts +8 -2
- package/vendor/connector-sdk/dist/index.js +3 -0
- package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
- package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
- package/vendor/connector-sdk/package.json +13 -1
- package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
- package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
- package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
- package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
- package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
- package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
- package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
- package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
- package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
- package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
- package/vendor/connector-worker/dist/daemon/automation.js +6 -6
- package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
- package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
- package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
- package/vendor/connector-worker/dist/daemon/client.d.ts +6 -4
- package/vendor/connector-worker/dist/daemon/client.js +3 -3
- package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
- package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
- package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/executor.js +48 -120
- package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
- package/vendor/connector-worker/dist/daemon/log.js +23 -2
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +23 -6
- package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
- package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
- package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +29 -25
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
- package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
- package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
- package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
- package/vendor/connector-worker/dist/daemon/start.js +15 -20
- package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
- package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
- package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
- package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
- package/vendor/connector-worker/dist/executor/isolate.js +66 -15
- package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
- package/vendor/connector-worker/dist/executor/redact.js +97 -26
- package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
- package/vendor/connector-worker/dist/executor/runtime.js +26 -0
- package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
- package/vendor/connector-worker/dist/mac-device-daemon.js +24 -29
- package/vendor/connector-worker/package.json +2 -2
- package/vendor/core/dist/agent-policy.js +1 -1
- package/vendor/core/dist/agent-store.d.ts +2 -0
- package/vendor/core/dist/agent-tooling.d.ts +1 -1
- package/vendor/core/dist/agent-tooling.js +1 -1
- package/vendor/core/dist/capabilities.d.ts +1 -1
- package/vendor/core/dist/capabilities.js +2 -1
- package/vendor/core/dist/connector-query-errors.d.ts +32 -0
- package/vendor/core/dist/connector-query-errors.js +41 -1
- package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
- package/vendor/core/dist/contracts/agent-settings.js +1 -7
- package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
- package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
- package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
- package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
- package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
- package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
- package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
- package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
- package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
- package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
- package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
- package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
- package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
- package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
- package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
- package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
- package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
- package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
- package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
- package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
- package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
- package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
- package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
- package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
- package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
- package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
- package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
- package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
- package/vendor/core/dist/contracts/worker/protocol.js +88 -76
- package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
- package/vendor/core/dist/device-pin-tombstones.js +57 -0
- package/vendor/core/dist/index.d.ts +5 -5
- package/vendor/core/dist/index.js +4 -6
- package/vendor/core/dist/json-template.d.ts +6 -10
- package/vendor/core/dist/json-template.js +5 -9
- package/vendor/core/dist/logger.js +17 -26
- package/vendor/core/dist/shell-safety.d.ts +9 -0
- package/vendor/core/dist/shell-safety.js +154 -0
- package/vendor/core/dist/suggestions.d.ts +1 -1
- package/vendor/core/dist/suggestions.js +1 -1
- package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
- package/vendor/core/dist/tool-trace-summary.js +1 -1
- package/vendor/core/dist/types.d.ts +1 -3
- package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
- package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
- package/vendor/core/dist/worker/auth.d.ts +44 -6
- package/vendor/core/dist/worker/auth.js +44 -11
- package/vendor/core/dist/worker/wire.d.ts +0 -10
- package/vendor/core/package.json +20 -11
- package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
- package/vendor/ora/index.d.ts +332 -0
- package/vendor/ora/index.js +424 -0
- package/vendor/ora/license +9 -0
- package/vendor/ora/package.json +53 -0
- package/vendor/ora/readme.md +329 -0
- package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
- package/vendor/cli/dist/commands/telemetry.js +0 -66
- package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
- package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
- package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
- package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
- package/vendor/core/dist/sentry.d.ts +0 -26
- package/vendor/core/dist/sentry.js +0 -133
- package/vendor/core/dist/tool-policy.d.ts +0 -74
- package/vendor/core/dist/tool-policy.js +0 -305
- package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
- package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advisory package-install detector shared by local and remote bash. The local
|
|
3
|
+
* isolate has no package managers registered; this check supplies an actionable
|
|
4
|
+
* error and runs before remote dispatch too. It is conservative text matching,
|
|
5
|
+
* not a shell security boundary: quoted/path-qualified executables and wrappers
|
|
6
|
+
* can evade it. Package availability and remote sandbox policy remain separate.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isDirectPackageInstallCommand(command: string): boolean;
|
|
9
|
+
//# sourceMappingURL=shell-safety.d.ts.map
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isDirectPackageInstallCommand = isDirectPackageInstallCommand;
|
|
4
|
+
/** Fixed shell protections shared by the isolate and remote workspace tools. */
|
|
5
|
+
const bash_command_parser_1 = require("./bash-command-parser");
|
|
6
|
+
const PACKAGE_MANAGER_DENY_PREFIXES = [
|
|
7
|
+
"apt ",
|
|
8
|
+
"apt-get ",
|
|
9
|
+
"yum ",
|
|
10
|
+
"dnf ",
|
|
11
|
+
"apk ",
|
|
12
|
+
"pacman ",
|
|
13
|
+
"zypper ",
|
|
14
|
+
"brew ",
|
|
15
|
+
"nix-shell ",
|
|
16
|
+
"nix-env ",
|
|
17
|
+
// New-style nix CLI. `nix shell`/`run`/`develop` put arbitrary packages on
|
|
18
|
+
// PATH or fetch-and-execute them and `nix build`/`nix-store` realise arbitrary
|
|
19
|
+
// derivations — the same capability the old-style commands above already
|
|
20
|
+
// denied. A bare `nix ` prefix covers every subcommand (conservative, like
|
|
21
|
+
// `brew `); `nixfmt` and friends keep working because the prefix needs the
|
|
22
|
+
// trailing space. This matcher only recognizes the honestly-typed leading
|
|
23
|
+
// command; what actually contains a package manager differs per backend —
|
|
24
|
+
// see the header on isDirectPackageInstallCommand.
|
|
25
|
+
"nix ",
|
|
26
|
+
"nix-build ",
|
|
27
|
+
"nix-store ",
|
|
28
|
+
"nix-channel ",
|
|
29
|
+
"nix-instantiate ",
|
|
30
|
+
"nix-prefetch-url ",
|
|
31
|
+
"nix-collect-garbage ",
|
|
32
|
+
"nix-copy-closure ",
|
|
33
|
+
// Ad-hoc package runners: fetch-and-run a tool that is not installed.
|
|
34
|
+
// `npx`/`bunx` are absent — they prefer already-installed local binaries.
|
|
35
|
+
"uvx ",
|
|
36
|
+
"uv tool install ",
|
|
37
|
+
"uv tool run ",
|
|
38
|
+
"uv tool upgrade ",
|
|
39
|
+
"uv add ",
|
|
40
|
+
"pipx install ",
|
|
41
|
+
"pipx run ",
|
|
42
|
+
"pipx upgrade ",
|
|
43
|
+
"pipx upgrade-all ",
|
|
44
|
+
"pipx inject ",
|
|
45
|
+
"pipx reinstall ",
|
|
46
|
+
"pipx reinstall-all ",
|
|
47
|
+
"pipx runpip ",
|
|
48
|
+
"pnpm dlx ",
|
|
49
|
+
"yarn dlx ",
|
|
50
|
+
"sudo apt ",
|
|
51
|
+
"sudo apt-get ",
|
|
52
|
+
"sudo yum ",
|
|
53
|
+
"sudo dnf ",
|
|
54
|
+
"sudo apk ",
|
|
55
|
+
"sudo pacman ",
|
|
56
|
+
"sudo zypper ",
|
|
57
|
+
"sudo brew ",
|
|
58
|
+
"sudo nix-shell ",
|
|
59
|
+
"sudo nix-env ",
|
|
60
|
+
"sudo nix ",
|
|
61
|
+
"sudo nix-build ",
|
|
62
|
+
"sudo nix-store ",
|
|
63
|
+
"sudo nix-channel ",
|
|
64
|
+
"sudo nix-instantiate ",
|
|
65
|
+
"sudo nix-prefetch-url ",
|
|
66
|
+
"sudo nix-collect-garbage ",
|
|
67
|
+
"sudo nix-copy-closure ",
|
|
68
|
+
"pip install ",
|
|
69
|
+
"pip3 install ",
|
|
70
|
+
"uv pip install ",
|
|
71
|
+
"npm install ",
|
|
72
|
+
"npm i ",
|
|
73
|
+
"pnpm install ",
|
|
74
|
+
"pnpm add ",
|
|
75
|
+
"yarn install ",
|
|
76
|
+
"yarn add ",
|
|
77
|
+
"bun install ",
|
|
78
|
+
"bun add ",
|
|
79
|
+
"cargo install ",
|
|
80
|
+
"go install ",
|
|
81
|
+
"gem install ",
|
|
82
|
+
"poetry add ",
|
|
83
|
+
"composer require ",
|
|
84
|
+
];
|
|
85
|
+
const DIRECT_PACKAGE_INSTALL_PATTERNS = [
|
|
86
|
+
/(^|[\s;|&()])(?:sudo\s+)?(?:apt|apt-get|yum|dnf|apk|pacman|zypper|brew)\s+(?:install|upgrade|add)\b/i,
|
|
87
|
+
/(^|[\s;|&()])(?:sudo\s+)?(?:nix-shell|nix-env)\b/i,
|
|
88
|
+
// New-style nix subcommands and the nix-* helpers, recognized after a shell
|
|
89
|
+
// operator or `sudo` (leading forms are already covered by the prefix list).
|
|
90
|
+
/(^|[\s;|&()])(?:sudo\s+)?nix\s+(?:profile|shell|run|develop|build|eval|flake|store|copy|bundle|repl|search|edit|print-dev-env|why-depends|derivation|realisation|registry|upgrade-nix)\b/i,
|
|
91
|
+
/(^|[\s;|&()])(?:sudo\s+)?nix-(?:build|store|channel|instantiate|prefetch-url|collect-garbage|copy-closure)\b/i,
|
|
92
|
+
/(^|[\s;|&()])(?:pip|pip3)\s+install\b/i,
|
|
93
|
+
/(^|[\s;|&()])uv\s+pip\s+install\b/i,
|
|
94
|
+
/(^|[\s;|&()])uv\s+(?:tool\s+(?:install|run|upgrade)|add)\b/i,
|
|
95
|
+
/(^|[\s;|&()])uvx\b/i,
|
|
96
|
+
/(^|[\s;|&()])pipx\s+(?:install|run|upgrade|upgrade-all|inject|reinstall|reinstall-all|runpip)\b/i,
|
|
97
|
+
/(^|[\s;|&()])npm\s+(?:install|i)\b/i,
|
|
98
|
+
/(^|[\s;|&()])pnpm\s+(?:install|add|dlx)\b/i,
|
|
99
|
+
/(^|[\s;|&()])yarn\s+(?:install|add|global\s+add|dlx)\b/i,
|
|
100
|
+
/(^|[\s;|&()])bun\s+(?:install|add)\b/i,
|
|
101
|
+
/(^|[\s;|&()])cargo\s+install\b/i,
|
|
102
|
+
/(^|[\s;|&()])go\s+install\b/i,
|
|
103
|
+
/(^|[\s;|&()])gem\s+install\b/i,
|
|
104
|
+
/(^|[\s;|&()])poetry\s+add\b/i,
|
|
105
|
+
/(^|[\s;|&()])composer\s+require\b/i,
|
|
106
|
+
];
|
|
107
|
+
/**
|
|
108
|
+
* Longest command this matcher will scan. Past it the command is treated as an
|
|
109
|
+
* install attempt rather than parsed: the scan is superlinear in the command
|
|
110
|
+
* length and the caller does not control the input.
|
|
111
|
+
*/
|
|
112
|
+
const MAX_SCANNED_COMMAND_LENGTH = 8192;
|
|
113
|
+
/**
|
|
114
|
+
* Advisory package-install detector shared by local and remote bash. The local
|
|
115
|
+
* isolate has no package managers registered; this check supplies an actionable
|
|
116
|
+
* error and runs before remote dispatch too. It is conservative text matching,
|
|
117
|
+
* not a shell security boundary: quoted/path-qualified executables and wrappers
|
|
118
|
+
* can evade it. Package availability and remote sandbox policy remain separate.
|
|
119
|
+
*/
|
|
120
|
+
function isDirectPackageInstallCommand(command) {
|
|
121
|
+
const trimmed = command.trim().toLowerCase();
|
|
122
|
+
if (!trimmed) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
// The interpreter-body regex backtracks quadratically on adversarial option
|
|
126
|
+
// clusters (`sh -` repeated), and on the isolate lane the model writes this
|
|
127
|
+
// string, so an unbounded scan would block the guest's only thread for
|
|
128
|
+
// seconds. No honest install command is anywhere near this long, and the
|
|
129
|
+
// matcher's documented bias is to fail toward flagging.
|
|
130
|
+
if (trimmed.length > MAX_SCANNED_COMMAND_LENGTH) {
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
// Keep the platform's fixed prefix guard on every shell segment; this was
|
|
134
|
+
// previously transported in each turn's configurable bash policy.
|
|
135
|
+
if ((0, bash_command_parser_1.splitShellCommands)(command).some((segment) => PACKAGE_MANAGER_DENY_PREFIXES.some((prefix) => segment.toLowerCase().startsWith(prefix.toLowerCase()))))
|
|
136
|
+
return true;
|
|
137
|
+
const matches = (text) => PACKAGE_MANAGER_DENY_PREFIXES.some((prefix) => text.startsWith(prefix.toLowerCase())) || DIRECT_PACKAGE_INSTALL_PATTERNS.some((pattern) => pattern.test(text));
|
|
138
|
+
// Scan the command with quoted DATA blanked out and each data word's operands
|
|
139
|
+
// dropped, so a manager merely NAMED cannot match. Both scrubs are advisory
|
|
140
|
+
// and fail toward flagging: whatever they cannot prove to be data is matched.
|
|
141
|
+
if ((0, bash_command_parser_1.matchesBeforeArgumentData)((0, bash_command_parser_1.blankQuotedSpans)(trimmed), matches)) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
// Then scan `sh -c '…'` bodies, where the quoted text IS a command.
|
|
145
|
+
bash_command_parser_1.INTERPRETER_DASH_C.lastIndex = 0;
|
|
146
|
+
for (const m of trimmed.matchAll(bash_command_parser_1.INTERPRETER_DASH_C)) {
|
|
147
|
+
const body = m[2]?.trim();
|
|
148
|
+
if (body && (0, bash_command_parser_1.matchesBeforeArgumentData)((0, bash_command_parser_1.blankQuotedSpans)(body), matches)) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=shell-safety.js.map
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Split out of `types.ts` because this cluster is PURE: no import, no Node
|
|
5
5
|
* builtin, no logger. That is what lets the isolate guest reach it through
|
|
6
6
|
* `@lobu/core/agent-tooling` while `types.ts` itself keeps pulling the rest of
|
|
7
|
-
* core in. Same rule as `
|
|
7
|
+
* core in. Same rule as `shell-safety.ts`: never grow a Node import or a root
|
|
8
8
|
* `@lobu/core` import here.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Split out of `types.ts` because this cluster is PURE: no import, no Node
|
|
6
6
|
* builtin, no logger. That is what lets the isolate guest reach it through
|
|
7
7
|
* `@lobu/core/agent-tooling` while `types.ts` itself keeps pulling the rest of
|
|
8
|
-
* core in. Same rule as `
|
|
8
|
+
* core in. Same rule as `shell-safety.ts`: never grow a Node import or a root
|
|
9
9
|
* `@lobu/core` import here.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Pure by construction: no Node builtin, no `@lobu/core` barrel import. The
|
|
11
11
|
* isolate lane bundles this into its guest, under the same standing rule as
|
|
12
|
-
* `agent-tooling.ts` and `
|
|
12
|
+
* `agent-tooling.ts` and `shell-safety.ts`.
|
|
13
13
|
*/
|
|
14
14
|
/** Retrieval evidence a client can join back to the agent's answer. */
|
|
15
15
|
export interface ToolTraceSummary {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Pure by construction: no Node builtin, no `@lobu/core` barrel import. The
|
|
12
12
|
* isolate lane bundles this into its guest, under the same standing rule as
|
|
13
|
-
* `agent-tooling.ts` and `
|
|
13
|
+
* `agent-tooling.ts` and `shell-safety.ts`.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.isRetrievalTool = isRetrievalTool;
|
|
@@ -128,8 +128,6 @@ export interface AgentOptions {
|
|
|
128
128
|
model?: string;
|
|
129
129
|
maxTokens?: number;
|
|
130
130
|
temperature?: number;
|
|
131
|
-
allowedTools?: string | string[];
|
|
132
|
-
disallowedTools?: string | string[];
|
|
133
131
|
timeoutMinutes?: number | string;
|
|
134
132
|
compaction?: AgentCompactionOptions;
|
|
135
133
|
networkConfig?: Record<string, unknown>;
|
|
@@ -293,5 +291,5 @@ export interface RegistryEntry {
|
|
|
293
291
|
type: string;
|
|
294
292
|
apiUrl: string;
|
|
295
293
|
}
|
|
296
|
-
export type { AgentInlineGuardrail, NetworkConfig, NixConfig, SkillConfig, SkillsConfig, ThinkingLevel,
|
|
294
|
+
export type { AgentInlineGuardrail, NetworkConfig, NixConfig, SkillConfig, SkillsConfig, ThinkingLevel, } from "./contracts/agent-settings";
|
|
297
295
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively remove credential material from diagnostic values.
|
|
3
|
+
* This is deliberately defensive: telemetry must never make an unusual
|
|
4
|
+
* application value or a circular error object throw another error.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scrubDiagnosticValue(value: unknown): unknown;
|
|
7
|
+
//# sourceMappingURL=diagnostic-scrubber.d.ts.map
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.scrubDiagnosticValue = scrubDiagnosticValue;
|
|
4
|
+
const secret_redaction_1 = require("./secret-redaction");
|
|
5
|
+
/**
|
|
6
|
+
* Secret as a QUERY PARAMETER name, and only there. `code` is an OAuth
|
|
7
|
+
* authorization code in `?code=…` but a Node/Postgres error code
|
|
8
|
+
* (`ECONNREFUSED`, `23505`) as an object key; `state` and `key` are the same
|
|
9
|
+
* story. Context decides, so this stays separate from the shared key denylist
|
|
10
|
+
* rather than widening it — redacting these as object keys would blank the
|
|
11
|
+
* fields triage actually reads.
|
|
12
|
+
*/
|
|
13
|
+
const SECRET_QUERY_PARAMS = new Set(["state", "code", "key"]);
|
|
14
|
+
/**
|
|
15
|
+
* Credential key names the shared config denylist has no reason to carry:
|
|
16
|
+
* request signatures reach telemetry (webhook headers, presigned URLs) but
|
|
17
|
+
* never appear in connector config, and that denylist also feeds the CLI's
|
|
18
|
+
* deployment manifest hash — widening it there would change hashes.
|
|
19
|
+
*/
|
|
20
|
+
const SECRET_KEY_SEGMENTS = new Set(["signature", "sig"]);
|
|
21
|
+
/**
|
|
22
|
+
* Whole (squashed) key names the shared denylist does not classify. Carried
|
|
23
|
+
* over from the bespoke sanitizer this module replaced: `verifier` and `state`
|
|
24
|
+
* are far too broad as segments (`freshness_state`, `run_state`), so these two
|
|
25
|
+
* are matched only as complete names. `authorizationheader` is the same story:
|
|
26
|
+
* HTTP client options carry it camel-cased (`authorizationHeader`), which the
|
|
27
|
+
* shared suffix denylist never sees, while `authorization` alone as a segment
|
|
28
|
+
* would sweep up `authorization_mode` and `authorization_policy`.
|
|
29
|
+
* `authorizationcode` is the OAuth code in any casing or separator style.
|
|
30
|
+
*/
|
|
31
|
+
const SECRET_KEY_EXACT = new Set([
|
|
32
|
+
"codeverifier",
|
|
33
|
+
"sessionstate",
|
|
34
|
+
"authorizationheader",
|
|
35
|
+
"authorizationcode",
|
|
36
|
+
]);
|
|
37
|
+
/**
|
|
38
|
+
* Concatenated credential names the separator-based rules never see:
|
|
39
|
+
* `PGPASSWORD`, `clientsecret`, `customapikey`, `myauthtoken` (the shared
|
|
40
|
+
* denylist has no `auth_?token` form), `idtoken`, and any other bare
|
|
41
|
+
* `*token` compound (`csrftoken`, `githubtoken`). Matched as a bare ending
|
|
42
|
+
* (case-insensitive, separator-free) so `tokenizer` and `keyboard` stay
|
|
43
|
+
* readable. Bare `token_count`-style usage keys stay readable because the
|
|
44
|
+
* benign-usage exemption runs before every classification below.
|
|
45
|
+
*/
|
|
46
|
+
const BARE_CREDENTIAL_SUFFIXES = [
|
|
47
|
+
"password",
|
|
48
|
+
"passwd",
|
|
49
|
+
"secret",
|
|
50
|
+
"apikey",
|
|
51
|
+
"token",
|
|
52
|
+
"authtoken",
|
|
53
|
+
"idtoken",
|
|
54
|
+
];
|
|
55
|
+
function hasBareCredentialSuffix(key, allowEqual = false) {
|
|
56
|
+
const flat = key.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
57
|
+
return BARE_CREDENTIAL_SUFFIXES.some((suffix) => flat.endsWith(suffix) && (allowEqual || flat.length > suffix.length));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Split-form credential names the whole/suffix rules miss. Case boundaries
|
|
61
|
+
* are split before lowercasing (mirroring `normalizeKey` in secret-redaction,
|
|
62
|
+
* including its acronym run), so camelCase compounds pin correctly.
|
|
63
|
+
* Separator-less all-lowercase compounds fall through to the bare-suffix
|
|
64
|
+
* rule above.
|
|
65
|
+
*/
|
|
66
|
+
function splitKeySegments(key) {
|
|
67
|
+
return key
|
|
68
|
+
.replace(/([A-Z])(?=[A-Z][a-z])/g, "$1_")
|
|
69
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
70
|
+
.replace(/[^a-z0-9]+/gi, "_")
|
|
71
|
+
.toLowerCase()
|
|
72
|
+
.split("_")
|
|
73
|
+
.filter((segment) => segment.length > 0);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* An `authorization` segment anywhere near the front names a header or an
|
|
77
|
+
* auth credential (`x-authorization`, `requestAuthorizationValue`,
|
|
78
|
+
* `proxy_authorization_value`, `authorizationJson`): trailing (after an
|
|
79
|
+
* optional `header`/`headers`) it is a header and collapses; followed by
|
|
80
|
+
* anything but pure config qualifiers it is a credential container;
|
|
81
|
+
* followed only by config qualifiers (`authorization_mode`,
|
|
82
|
+
* `authorization_policy`) it stays readable.
|
|
83
|
+
*
|
|
84
|
+
* A leading credential run names a credential CONTAINER
|
|
85
|
+
* (`credentials_json`, `credentialsByName`, `password_confirmation`,
|
|
86
|
+
* `secret_value`, `oauthCredentialsJson`, `token_value`,
|
|
87
|
+
* `accessTokenValue`, `api_key_value`, `authtoken`, `csrftoken`,
|
|
88
|
+
* `githubtoken`, `clientsecretvalue`). The head must classify under the
|
|
89
|
+
* shared suffix rules, read as a suffix term, or end with a bare credential
|
|
90
|
+
* term the shared rules miss — a whole-name exact match never seeds one
|
|
91
|
+
* (`cookie`, `authorization`, `auth`, `bearer`), so `cookie-policy` stays
|
|
92
|
+
* readable. A two-segment usage metric (`token_count`, `token_total`,
|
|
93
|
+
* `max_tokens`, `totalTokens`) is exempt everywhere: usage metadata stays
|
|
94
|
+
* readable per the logger contract. Only the leading run (bounded below)
|
|
95
|
+
* is scanned, so pathological keys stay linear. Container semantics live in
|
|
96
|
+
* the walk: a scalar beneath one IS the serialized credential and collapses,
|
|
97
|
+
* while a structured value beneath one recurses with every descendant
|
|
98
|
+
* treated as credential-adjacent (a map's leaves cannot be trusted by key
|
|
99
|
+
* name alone — `credentialsByName.github` proves it).
|
|
100
|
+
*/
|
|
101
|
+
/** Qualifiers that mark a key as usage metadata, never a credential. */
|
|
102
|
+
const BENIGN_COUNT_QUALIFIERS = new Set([
|
|
103
|
+
"count",
|
|
104
|
+
"counts",
|
|
105
|
+
"total",
|
|
106
|
+
"totals",
|
|
107
|
+
"used",
|
|
108
|
+
"usage",
|
|
109
|
+
"remaining",
|
|
110
|
+
"limit",
|
|
111
|
+
"limits",
|
|
112
|
+
"max",
|
|
113
|
+
"quota",
|
|
114
|
+
"quotas",
|
|
115
|
+
]);
|
|
116
|
+
/** Config qualifiers that keep an `authorization` key readable. */
|
|
117
|
+
const AUTH_CONFIG_QUALIFIERS = new Set(["mode", "modes", "policy", "policies"]);
|
|
118
|
+
/**
|
|
119
|
+
* Whether a key segment run reads as a credential SUFFIX term rather than
|
|
120
|
+
* merely a whole name: `x_token` still classifies, so `token` seeds
|
|
121
|
+
* compounds, while `x_cookie`, `x_auth` and `x_bearer` have no credential
|
|
122
|
+
* reading, so those whole names never seed one.
|
|
123
|
+
*/
|
|
124
|
+
function isSuffixTerm(head) {
|
|
125
|
+
return (0, secret_redaction_1.isSecretKey)(`x_${head}`) || (0, secret_redaction_1.isSecretKey)(squashKey(`x_${head}`));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Whether a head classifies solely as a whole name (the shared exact set:
|
|
129
|
+
* `cookie`, `authorization`, `auth`, `bearer`) rather than as a suffix term
|
|
130
|
+
* or bare compound. Whole-name heads never seed a compound.
|
|
131
|
+
*/
|
|
132
|
+
function isWholeNameOnly(head) {
|
|
133
|
+
const whole = (0, secret_redaction_1.isSecretKey)(head) || (0, secret_redaction_1.isSecretKey)(squashKey(head));
|
|
134
|
+
if (!whole)
|
|
135
|
+
return false;
|
|
136
|
+
return !isSuffixTerm(head) && !hasBareCredentialSuffix(head, true);
|
|
137
|
+
}
|
|
138
|
+
/** Two-segment usage metrics (`token_count`, `max_tokens`, `totalTokens`). */
|
|
139
|
+
function isBenignUsageKey(key) {
|
|
140
|
+
const segments = splitKeySegments(key);
|
|
141
|
+
if (segments.length !== 2)
|
|
142
|
+
return false;
|
|
143
|
+
const [first, second] = segments;
|
|
144
|
+
const isTokenWord = (segment) => segment === "token" || segment === "tokens";
|
|
145
|
+
return ((isTokenWord(first) && BENIGN_COUNT_QUALIFIERS.has(second)) ||
|
|
146
|
+
(BENIGN_COUNT_QUALIFIERS.has(first) && isTokenWord(second)));
|
|
147
|
+
}
|
|
148
|
+
/** Longest credential-name prefix worth testing; real compounds are short. */
|
|
149
|
+
const MAX_CREDENTIAL_PREFIX_PARTS = 8;
|
|
150
|
+
function classifyAuthorization(key) {
|
|
151
|
+
const segments = splitKeySegments(key);
|
|
152
|
+
const limit = Math.min(segments.length, MAX_CREDENTIAL_PREFIX_PARTS);
|
|
153
|
+
for (let index = 0; index < limit; index++) {
|
|
154
|
+
if (segments[index] !== "authorization")
|
|
155
|
+
continue;
|
|
156
|
+
const tail = segments
|
|
157
|
+
.slice(index + 1)
|
|
158
|
+
.filter((segment) => segment !== "header" && segment !== "headers");
|
|
159
|
+
if (tail.length === 0)
|
|
160
|
+
return "strong";
|
|
161
|
+
if (tail.every((segment) => AUTH_CONFIG_QUALIFIERS.has(segment)))
|
|
162
|
+
continue;
|
|
163
|
+
return "container";
|
|
164
|
+
}
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
function hasCredentialSegment(key) {
|
|
168
|
+
if (isBenignUsageKey(key))
|
|
169
|
+
return false;
|
|
170
|
+
if (classifyAuthorization(key) === "container")
|
|
171
|
+
return true;
|
|
172
|
+
const segments = splitKeySegments(key);
|
|
173
|
+
// Bounded lookahead: real credential compounds are short
|
|
174
|
+
// (`access_token`, `oauth_credentials`); scanning an unbounded prefix run
|
|
175
|
+
// turns a pathological key into quadratic work.
|
|
176
|
+
const end = Math.min(segments.length, MAX_CREDENTIAL_PREFIX_PARTS);
|
|
177
|
+
for (let length = 1; length <= end; length++) {
|
|
178
|
+
const head = segments.slice(0, length).join("_");
|
|
179
|
+
if (isWholeNameOnly(head))
|
|
180
|
+
continue;
|
|
181
|
+
const qualifies = (0, secret_redaction_1.isSecretKey)(head) ||
|
|
182
|
+
(0, secret_redaction_1.isSecretKey)(squashKey(head)) ||
|
|
183
|
+
hasBareCredentialSuffix(head, true);
|
|
184
|
+
if (!qualifies)
|
|
185
|
+
continue;
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
// Separator-free compounds with the credential term in the middle
|
|
189
|
+
// (`clientsecretvalue`): the shared rules and split segment tests never
|
|
190
|
+
// see them. `token` and bare `key` stay out here — `tokenizer`,
|
|
191
|
+
// `keyboard` and usage counters stay readable.
|
|
192
|
+
const flat = squashKey(key);
|
|
193
|
+
return SUBSTRING_CREDENTIALS.some((term) => flat.includes(term));
|
|
194
|
+
}
|
|
195
|
+
/** Credential terms matched as substrings of separator-free compounds. */
|
|
196
|
+
const SUBSTRING_CREDENTIALS = [
|
|
197
|
+
"secret",
|
|
198
|
+
"password",
|
|
199
|
+
"passwd",
|
|
200
|
+
"credential",
|
|
201
|
+
"credentials",
|
|
202
|
+
"apikey",
|
|
203
|
+
];
|
|
204
|
+
/** Bound recursive work on diagnostic values. */
|
|
205
|
+
const MAX_DEPTH = 8;
|
|
206
|
+
const MAX_ENTRIES = 1000;
|
|
207
|
+
/** Separator/case-squashed form, for keys core's camel-case split can't read. */
|
|
208
|
+
function squashKey(key) {
|
|
209
|
+
return key.replace(/[^a-z0-9]/gi, "").toLowerCase();
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Object and header keys. Core's normalizer splits on case boundaries, so an
|
|
213
|
+
* arbitrarily-cased header (`CoOkIe`) normalizes to `co_ok_ie` and misses;
|
|
214
|
+
* test the squashed form too.
|
|
215
|
+
*/
|
|
216
|
+
function isSecretObjectKey(key) {
|
|
217
|
+
if (isBenignUsageKey(key))
|
|
218
|
+
return false;
|
|
219
|
+
return isStrongSecretKey(key) || hasCredentialSegment(key);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The collapsing half of key classification: a key whose NAME alone proves
|
|
223
|
+
* the value is a credential, so the whole value is replaced without
|
|
224
|
+
* inspection. Credential CONTAINERS (`hasCredentialSegment`) are deliberately
|
|
225
|
+
* excluded — their collapse rule depends on the value type (see the walk),
|
|
226
|
+
* and collapsing a map parent would destroy surviving key names the Loki
|
|
227
|
+
* connector pre-redacted.
|
|
228
|
+
*/
|
|
229
|
+
function isStrongSecretKey(key) {
|
|
230
|
+
if (isBenignUsageKey(key))
|
|
231
|
+
return false;
|
|
232
|
+
if ((0, secret_redaction_1.isSecretKey)(key))
|
|
233
|
+
return true;
|
|
234
|
+
if ((0, secret_redaction_1.isSecretKey)(squashKey(key)))
|
|
235
|
+
return true;
|
|
236
|
+
if (SECRET_KEY_EXACT.has(squashKey(key)))
|
|
237
|
+
return true;
|
|
238
|
+
if (classifyAuthorization(key) === "strong")
|
|
239
|
+
return true;
|
|
240
|
+
if (hasBareCredentialSuffix(key))
|
|
241
|
+
return true;
|
|
242
|
+
// Matched per separated segment, not against the squashed whole:
|
|
243
|
+
// `X-Hub-Signature-256` squashes to `xhubsignature256`, which no exact set
|
|
244
|
+
// can ever hold, so every real signature header would slip through.
|
|
245
|
+
// Segment-matched signature headers collapse like any other proven key.
|
|
246
|
+
return key
|
|
247
|
+
.replace(/[^a-z0-9]+/gi, "_")
|
|
248
|
+
.toLowerCase()
|
|
249
|
+
.split("_")
|
|
250
|
+
.some((segment) => SECRET_KEY_SEGMENTS.has(segment));
|
|
251
|
+
}
|
|
252
|
+
const URL_PATTERN = /https?:\/\/[^\s"'<>]+/gi;
|
|
253
|
+
/**
|
|
254
|
+
* A relative URL (`/api/v1/files/a?token=…`) and a raw
|
|
255
|
+
* `request.query_string` (`token=…`, no scheme and no path) never match
|
|
256
|
+
* URL_PATTERN, so the signed-download token would survive a URL-only scrub.
|
|
257
|
+
* The separator absorbs trailing whitespace because cookie serialization is
|
|
258
|
+
* `a=b; c=d`: without it every pair after the first space goes unredacted.
|
|
259
|
+
*/
|
|
260
|
+
const QUERY_PAIR_PATTERN = /([?&;]\s*|^)([A-Za-z0-9_.\-%[\]]+)=("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^&;\s"'<>]*)/g;
|
|
261
|
+
function decodeKey(raw) {
|
|
262
|
+
try {
|
|
263
|
+
return decodeURIComponent(raw);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return raw;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function isSecretQueryParam(name) {
|
|
270
|
+
const key = decodeKey(name);
|
|
271
|
+
return isSecretObjectKey(key) || SECRET_QUERY_PARAMS.has(squashKey(key));
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Object keys are data too: attribution and cache maps keyed by URL or raw
|
|
275
|
+
* `name=value` diagnostics carry credentials in the KEY text, where
|
|
276
|
+
* value-side redaction never reaches. Redact the secret portion while keeping
|
|
277
|
+
* the key identifiable. Clean keys (the common case) return untouched; two
|
|
278
|
+
* distinct keys that scrub identically collapse, last wins.
|
|
279
|
+
*/
|
|
280
|
+
function scrubKey(key) {
|
|
281
|
+
if (!key.includes("?") &&
|
|
282
|
+
!key.includes(";") &&
|
|
283
|
+
!key.includes("=") &&
|
|
284
|
+
!key.includes("://")) {
|
|
285
|
+
return key;
|
|
286
|
+
}
|
|
287
|
+
return scrubString(key);
|
|
288
|
+
}
|
|
289
|
+
function scrubString(value) {
|
|
290
|
+
// `postgres://user:pa55@host/db` carries its credential in the userinfo, not
|
|
291
|
+
// in a query pair or a secret-named key, so neither pass below would see it.
|
|
292
|
+
const withoutUriCredentials = (0, secret_redaction_1.redactUriCredentials)(value);
|
|
293
|
+
// Scrub quoted query values before URL matching stops at their opening quote
|
|
294
|
+
// and removes the key that identifies the remaining text as a credential.
|
|
295
|
+
const withoutQueries = withoutUriCredentials.replace(QUERY_PAIR_PATTERN, (match, lead, name, raw) => isSecretQueryParam(name)
|
|
296
|
+
? `${lead}${name}=[REDACTED]${raw.match(/[),.;]+$/)?.[0] ?? ""}`
|
|
297
|
+
: match);
|
|
298
|
+
const withoutUrlQueries = withoutQueries.replace(URL_PATTERN, (candidate) => {
|
|
299
|
+
// Trailing sentence punctuation is not part of the URL, but it is part of
|
|
300
|
+
// the message: strip it to parse, then put it back.
|
|
301
|
+
const trailing = candidate.match(/[),.;]+$/)?.[0] ?? "";
|
|
302
|
+
const bare = trailing ? candidate.slice(0, -trailing.length) : candidate;
|
|
303
|
+
try {
|
|
304
|
+
const url = new URL(bare);
|
|
305
|
+
return `${url.origin}${url.pathname}${trailing}`;
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return candidate;
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
// Error messages can embed key=value diagnostics outside a URL. Keep codes
|
|
312
|
+
// and states useful there; only credential-named assignments are sensitive.
|
|
313
|
+
return withoutUrlQueries.replace(/(\s)([A-Za-z0-9_.%-]+)=("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[^&;\s"'<>]*)/g, (match, lead, name) => isSecretObjectKey(decodeKey(name)) ? `${lead}${name}=[REDACTED]` : match);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Recursively remove credential material from diagnostic values.
|
|
317
|
+
* This is deliberately defensive: telemetry must never make an unusual
|
|
318
|
+
* application value or a circular error object throw another error.
|
|
319
|
+
*/
|
|
320
|
+
function scrubDiagnosticValue(value) {
|
|
321
|
+
const seen = new WeakSet();
|
|
322
|
+
function scrub(current, depth = 0, underCredentialContainer = false) {
|
|
323
|
+
if (typeof current === "string")
|
|
324
|
+
return underCredentialContainer ? "[REDACTED]" : scrubString(current);
|
|
325
|
+
// A copied toJSON hook could reintroduce secrets after this walk finishes.
|
|
326
|
+
if (typeof current === "function")
|
|
327
|
+
return "[Function]";
|
|
328
|
+
if (current === null || typeof current !== "object")
|
|
329
|
+
return underCredentialContainer ? "[REDACTED]" : current;
|
|
330
|
+
if (seen.has(current))
|
|
331
|
+
return "[CIRCULAR]";
|
|
332
|
+
// Bound deeply nested values before cloning them on the logging hot path.
|
|
333
|
+
if (depth >= MAX_DEPTH)
|
|
334
|
+
return "[TRUNCATED]";
|
|
335
|
+
// Tracks the current PATH, not every node ever visited. Two siblings may
|
|
336
|
+
// legitimately hold the same reference, and reporting the second one as
|
|
337
|
+
// [CIRCULAR] would corrupt the event; only an ancestor is a real cycle.
|
|
338
|
+
seen.add(current);
|
|
339
|
+
try {
|
|
340
|
+
return walk(current, depth, underCredentialContainer);
|
|
341
|
+
}
|
|
342
|
+
finally {
|
|
343
|
+
seen.delete(current);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function walk(current, depth, underCredentialContainer) {
|
|
347
|
+
// An Error carries name/message/stack on its prototype, so Object.keys
|
|
348
|
+
// returns nothing and a plain walk would flatten it to `{}` — discarding
|
|
349
|
+
// the only part of the event worth reading.
|
|
350
|
+
if (current instanceof Error) {
|
|
351
|
+
// message/stack are scrubbed as text; under a credential container
|
|
352
|
+
// they ARE the credential and collapse instead. The name always gets
|
|
353
|
+
// text scrubbing but stays readable: a custom (even non-enumerable)
|
|
354
|
+
// name can carry `password=...`, which key-based redaction never sees,
|
|
355
|
+
// while the error class itself is triage payload.
|
|
356
|
+
const serialized = {
|
|
357
|
+
name: scrubString(String(current.name ?? "")),
|
|
358
|
+
message: underCredentialContainer
|
|
359
|
+
? "[REDACTED]"
|
|
360
|
+
: scrubString(current.message),
|
|
361
|
+
};
|
|
362
|
+
if (current.stack)
|
|
363
|
+
serialized.stack = underCredentialContainer
|
|
364
|
+
? "[REDACTED]"
|
|
365
|
+
: scrubString(current.stack);
|
|
366
|
+
if (current.cause !== undefined)
|
|
367
|
+
serialized.cause = scrub(current.cause, depth + 1, underCredentialContainer);
|
|
368
|
+
// AggregateError.errors is non-enumerable, just like cause and stack.
|
|
369
|
+
// Reuse the same walk so nested failures keep their codes without
|
|
370
|
+
// bypassing credential redaction, depth limits, or cycle detection.
|
|
371
|
+
if ("errors" in current && Array.isArray(current.errors))
|
|
372
|
+
serialized.errors = scrub(current.errors, depth + 1, underCredentialContainer);
|
|
373
|
+
for (const key of Object.keys(current)) {
|
|
374
|
+
const outKey = scrubKey(key);
|
|
375
|
+
if (isStrongSecretKey(key)) {
|
|
376
|
+
serialized[outKey] = "[REDACTED]";
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
// Container adjacency propagates: scalars beneath one collapse,
|
|
380
|
+
// structured values recurse with the flag set. Usage-metric keys
|
|
381
|
+
// never start adjacency themselves (an inherited flag still applies).
|
|
382
|
+
const childContainer = underCredentialContainer ||
|
|
383
|
+
(!isBenignUsageKey(key) && hasCredentialSegment(key));
|
|
384
|
+
const value = current[key];
|
|
385
|
+
serialized[outKey] = scrub(value, depth + 1, childContainer);
|
|
386
|
+
}
|
|
387
|
+
return serialized;
|
|
388
|
+
}
|
|
389
|
+
// Built-ins whose state is not enumerable: walking them as plain objects
|
|
390
|
+
// yields `{}` (Date, Map, Set, RegExp) or one key per byte (Buffer). A
|
|
391
|
+
// readable summary costs less payload and tells triage strictly more.
|
|
392
|
+
// A RegExp source can itself embed a credential (`/password=.../`),
|
|
393
|
+
// so it takes the same string scrubbing as any other message text.
|
|
394
|
+
if (current instanceof Date)
|
|
395
|
+
return current.toISOString();
|
|
396
|
+
if (current instanceof RegExp)
|
|
397
|
+
return underCredentialContainer
|
|
398
|
+
? "[REDACTED]"
|
|
399
|
+
: scrubString(String(current));
|
|
400
|
+
if (ArrayBuffer.isView(current)) {
|
|
401
|
+
return `[${current.constructor.name} ${current.byteLength} bytes]`;
|
|
402
|
+
}
|
|
403
|
+
if (current instanceof Map)
|
|
404
|
+
return `[Map ${current.size} entries]`;
|
|
405
|
+
if (current instanceof Set)
|
|
406
|
+
return `[Set ${current.size} items]`;
|
|
407
|
+
if (Array.isArray(current)) {
|
|
408
|
+
return current
|
|
409
|
+
.slice(0, MAX_ENTRIES)
|
|
410
|
+
.map((item) => scrub(item, depth + 1, underCredentialContainer));
|
|
411
|
+
}
|
|
412
|
+
const result = {};
|
|
413
|
+
try {
|
|
414
|
+
for (const key of Object.keys(current).slice(0, MAX_ENTRIES)) {
|
|
415
|
+
const outKey = scrubKey(key);
|
|
416
|
+
if (isStrongSecretKey(key)) {
|
|
417
|
+
result[outKey] = "[REDACTED]";
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
const childContainer = underCredentialContainer ||
|
|
421
|
+
(!isBenignUsageKey(key) && hasCredentialSegment(key));
|
|
422
|
+
try {
|
|
423
|
+
result[outKey] = scrub(current[key], depth + 1, childContainer);
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
result[outKey] = "[UNREADABLE]";
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
return "[UNREADABLE]";
|
|
432
|
+
}
|
|
433
|
+
return result;
|
|
434
|
+
}
|
|
435
|
+
return scrub(value);
|
|
436
|
+
}
|
|
437
|
+
//# sourceMappingURL=diagnostic-scrubber.js.map
|