@blogic-cz/agent-tools 1.10.1 → 1.12.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 +21 -44
- package/dist/credential-guard/bash.d.ts +3 -0
- package/dist/credential-guard/bash.d.ts.map +1 -0
- package/dist/credential-guard/claude-hook.d.ts.map +1 -1
- package/dist/credential-guard/engine.test.d.ts +5 -0
- package/dist/credential-guard/engine.test.d.ts.map +1 -0
- package/dist/credential-guard/index.d.ts +8 -35
- package/dist/credential-guard/index.d.ts.map +1 -1
- package/dist/credential-guard/ir.d.ts +150 -0
- package/dist/credential-guard/ir.d.ts.map +1 -0
- package/dist/credential-guard/literal-output.d.ts +2 -0
- package/dist/credential-guard/literal-output.d.ts.map +1 -0
- package/dist/credential-guard/passive-awk.d.ts +2 -0
- package/dist/credential-guard/passive-awk.d.ts.map +1 -0
- package/dist/credential-guard/passive-jq.d.ts.map +1 -1
- package/dist/credential-guard/passive-sed.d.ts +2 -0
- package/dist/credential-guard/passive-sed.d.ts.map +1 -0
- package/dist/credential-guard/passive.test.d.ts +2 -0
- package/dist/credential-guard/passive.test.d.ts.map +1 -0
- package/dist/credential-guard/paths.d.ts +14 -0
- package/dist/credential-guard/paths.d.ts.map +1 -0
- package/dist/credential-guard/policy.d.ts +47 -0
- package/dist/credential-guard/policy.d.ts.map +1 -0
- package/dist/credential-guard/powershell.d.ts +3 -0
- package/dist/credential-guard/powershell.d.ts.map +1 -0
- package/dist/credential-guard/registry.d.ts +89 -0
- package/dist/credential-guard/registry.d.ts.map +1 -0
- package/dist/credential-guard/review4.test.d.ts +2 -0
- package/dist/credential-guard/review4.test.d.ts.map +1 -0
- package/dist/credential-guard/review7.test.d.ts +2 -0
- package/dist/credential-guard/review7.test.d.ts.map +1 -0
- package/dist/credential-guard/shell-oracle.d.ts +2 -0
- package/dist/credential-guard/shell-oracle.d.ts.map +1 -0
- package/dist/credential-guard/xargs.d.ts +7 -0
- package/dist/credential-guard/xargs.d.ts.map +1 -0
- package/dist/db-tool/service.d.ts +2 -1
- package/dist/db-tool/service.d.ts.map +1 -1
- package/dist/db-tool/sql-client.d.ts +1 -0
- package/dist/db-tool/sql-client.d.ts.map +1 -1
- package/dist/gh-tool/pr/commands.d.ts.map +1 -1
- package/dist/gh-tool/read/api.d.ts +8 -0
- package/dist/gh-tool/read/api.d.ts.map +1 -1
- package/dist/gh-tool/read/cache.d.ts.map +1 -1
- package/dist/gh-tool/read/commands.d.ts +5 -0
- package/dist/gh-tool/read/commands.d.ts.map +1 -1
- package/dist/gh-tool/read/reads.d.ts +38 -0
- package/dist/gh-tool/read/reads.d.ts.map +1 -1
- package/dist/gh-tool/read/telemetry-command.d.ts +7 -0
- package/dist/gh-tool/read/telemetry-command.d.ts.map +1 -0
- package/dist/gh-tool/read/telemetry-store.d.ts +3 -0
- package/dist/gh-tool/read/telemetry-store.d.ts.map +1 -0
- package/dist/gh-tool/read/telemetry.d.ts +59 -0
- package/dist/gh-tool/read/telemetry.d.ts.map +1 -0
- package/dist/gh-tool/read/transport.d.ts.map +1 -1
- package/dist/observability-tool/logs.d.ts +1 -1
- package/dist/observability-tool/logs.d.ts.map +1 -1
- package/dist/observability-tool/metrics.d.ts +1 -1
- package/dist/observability-tool/metrics.d.ts.map +1 -1
- package/dist/observability-tool/shared.d.ts +2 -1
- package/dist/observability-tool/shared.d.ts.map +1 -1
- package/dist/observability-tool/trace.d.ts +1 -1
- package/dist/observability-tool/trace.d.ts.map +1 -1
- package/dist/shared/content-security.d.ts +3 -1
- package/dist/shared/content-security.d.ts.map +1 -1
- package/dist/shared/secret-env.d.ts +22 -0
- package/dist/shared/secret-env.d.ts.map +1 -0
- package/package.json +2 -1
- package/schemas/agent-tools.schema.json +1 -1
- package/src/credential-guard/bash.ts +769 -0
- package/src/credential-guard/claude-hook.ts +14 -14
- package/src/credential-guard/engine.test.ts +2050 -0
- package/src/credential-guard/index.ts +285 -4268
- package/src/credential-guard/ir.ts +139 -0
- package/src/credential-guard/literal-output.ts +8 -0
- package/src/credential-guard/passive-awk.ts +239 -0
- package/src/credential-guard/passive-jq.ts +183 -24
- package/src/credential-guard/passive-sed.ts +78 -0
- package/src/credential-guard/passive.test.ts +141 -0
- package/src/credential-guard/paths.ts +108 -0
- package/src/credential-guard/policy.ts +1576 -0
- package/src/credential-guard/powershell.ts +220 -0
- package/src/credential-guard/registry.ts +4720 -0
- package/src/credential-guard/review4.test.ts +83 -0
- package/src/credential-guard/review7.test.ts +51 -0
- package/src/credential-guard/rg-types.json +389 -0
- package/src/credential-guard/shell-oracle.ts +187 -0
- package/src/credential-guard/xargs.ts +65 -0
- package/src/db-tool/main.ts +2 -0
- package/src/db-tool/service.ts +122 -140
- package/src/db-tool/sql-client.ts +7 -4
- package/src/gh-tool/main.ts +30 -6
- package/src/gh-tool/pr/commands.ts +9 -2
- package/src/gh-tool/pr/core.ts +2 -2
- package/src/gh-tool/read/api.ts +73 -6
- package/src/gh-tool/read/cache.ts +13 -4
- package/src/gh-tool/read/commands.ts +17 -1
- package/src/gh-tool/read/reads.ts +84 -1
- package/src/gh-tool/read/telemetry-command.ts +45 -0
- package/src/gh-tool/read/telemetry-store.ts +85 -0
- package/src/gh-tool/read/telemetry.ts +191 -0
- package/src/gh-tool/read/transport.ts +10 -5
- package/src/gh-tool/workflow.ts +2 -2
- package/src/observability-tool/main.ts +7 -1
- package/src/observability-tool/shared.ts +20 -14
- package/src/shared/content-security.ts +7 -2
- package/src/shared/secret-env.ts +230 -0
package/README.md
CHANGED
|
@@ -230,6 +230,10 @@ bun run agent-tools/example-tool/index.ts ping
|
|
|
230
230
|
3. Run tools:
|
|
231
231
|
|
|
232
232
|
```bash
|
|
233
|
+
bun gh-tool rate-limit # Inspect all GitHub API rate-limit resources
|
|
234
|
+
bun gh-tool rate-limit --resource core # Inspect one resource
|
|
235
|
+
bun gh-tool telemetry # Report direct HTTP requests, gh invocations and ReadCache hits
|
|
236
|
+
bun gh-tool telemetry --hours 24 --format json # Report one day of telemetry
|
|
233
237
|
bun gh-tool pr status
|
|
234
238
|
bun observability-tool trace get 0b7bdf0dde1c55458364ba5588a8075e --env local
|
|
235
239
|
bun observability-tool trace search '{ status = error }' --env local --start now-6h
|
|
@@ -437,7 +441,7 @@ bun audit-tool list --limit 50 --format json
|
|
|
437
441
|
bun audit-tool list --tool gh
|
|
438
442
|
|
|
439
443
|
# Filter by project directory
|
|
440
|
-
bun audit-tool list --project /
|
|
444
|
+
bun audit-tool list --project /home/user/my-repo
|
|
441
445
|
|
|
442
446
|
# Purge entries older than 30 days
|
|
443
447
|
bun audit-tool purge --days 30
|
|
@@ -547,6 +551,8 @@ Each tool uses its own auth method — no unified token store:
|
|
|
547
551
|
| `api-tool` | Caller capability and proxy HTTPS origin in client configuration |
|
|
548
552
|
| `api-proxy` | Private operator store and policy under a separated service identity |
|
|
549
553
|
|
|
554
|
+
Set `tokenEnvVar` and `passwordEnvVar` to names that match `^[A-Z_][A-Z0-9_]*$`.
|
|
555
|
+
|
|
550
556
|
The REST proxy uses its separate private operator store described in [REST proxy setup](docs/rest-api-proxy.md). Other tool configs reference credential sources. Provider secrets are **never** stored in the caller client config file. The `db-tool` config references env var **names** only:
|
|
551
557
|
|
|
552
558
|
```json5
|
|
@@ -574,7 +580,8 @@ These are **overrides with fallback**, not requirements — the opposite of `pas
|
|
|
574
580
|
- variable unset or empty → the literal `host` / `port` in the config is used, and no error is raised;
|
|
575
581
|
- `portEnvVar` set to something that is not an integer between 1 and 65535 → the command **fails**. It never falls back to the literal, because that would query a different database while you believe the override applied.
|
|
576
582
|
|
|
577
|
-
The variable is read from the process environment first (Bun loads `.env` files into it), then from
|
|
583
|
+
The variable is read from the process environment first (Bun loads `.env` files into it), then from the interactive zsh environment.
|
|
584
|
+
The zsh child receives only `PATH`, `HOME`, `USER`, `LOGNAME`, `SHELL`, `TERM`, `LANG`, `LC_ALL`, `TMPDIR`, `XDG_CONFIG_HOME`, and `ZDOTDIR`. If an rc file needs another parent process variable to select or load a value, that value will not resolve.
|
|
578
585
|
|
|
579
586
|
The typical use is a repository where every git worktree runs its own database container on its own host port, published by that worktree's `.env`:
|
|
580
587
|
|
|
@@ -644,7 +651,7 @@ The wrappers check outgoing user content and redact recognized credentials in ag
|
|
|
644
651
|
|
|
645
652
|
## Credential Guard
|
|
646
653
|
|
|
647
|
-
The guard
|
|
654
|
+
The guard checks tool inputs for named credential sources, sensitive file access, and supplied code that it cannot inspect. Write/Edit content checks detect known secret formats. Shell output and existing program contents are outside these checks.
|
|
648
655
|
|
|
649
656
|
**What it blocks:**
|
|
650
657
|
|
|
@@ -691,57 +698,27 @@ Claude Code uses shell command hooks. The package ships a ready-made wrapper scr
|
|
|
691
698
|
|
|
692
699
|
That's it. The hook reads tool input from stdin, runs the guard, and exits with code 2 (blocked + reason on stderr) or 0 (allowed).
|
|
693
700
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
Python inline programs and quoted stdin heredocs can also display approved values through `os.getenv("NAME")`, `os.environ.get("NAME", "default")`, or `os.environ["NAME"]`. The complete program must import unaliased `os`, plus `json` for JSON display, followed by `print(...)` statements. `json.dumps(...)` supports dictionaries and lists of approved reads, including comprehensions over a nonempty literal list of approved names. Every dictionary key and environment read must use an approved name. Each projection has at most 16 entries; the program has at most 65,536 characters. Computed or unbounded names, aliases, escaped or interpolated strings, additional statements, and whole-environment output remain unsupported. The same redirection and pipeline restrictions apply.
|
|
697
|
-
|
|
698
|
-
Literal assignments such as `F=README.md; cat "$F"` work in supported static commands. Bounded proofs also support a literal `for` loop over a fixed list, a single ASCII-letter path binding such as `cd PATH && A=docs/report.md && shasum -a 256 "$A"` or `F=README.md; cat "$F"`, including the existing `git add -- "$T/file"` form, and literal path braces such as `rg -n -i PATTERN src/{a,b} docs/{guide,api}.md`. Path braces work with supported passive text commands and `cat`, and support one unquoted comma list per path, at most 16 members per list and 32 generated paths per command, within 64 KiB. Nested braces, ranges, empty members, mixed quoting, command positions, and compound commands remain unsupported. Path bindings accept literal values and `;`, newline, or `&&` sequencing; a binding conditional on successful `cd` is proved only for uses in that same `&&` list. Their uses must be supported read-only file operands or explicit `git add --` paths. Rebinding, executable operands, startup-variable names, and uncertain scopes cannot establish this proof. Loop binders are a single lowercase letter or `T`, and their uses must occupy supported data operands. Every body command and expanded path is checked; unsupported control flow, mutations such as `printf -v`, and unknown command roles cannot establish the proof. Other variable assignments and brace expansions retain conservative refusal. Fully quoted literal braces remain usable in static searches.
|
|
699
|
-
|
|
700
|
-
Ordinary navigation operands such as `cd "$HOME"` and `git -C "$WORKTREE_ROOT" status --short` do not need display permission. This does not authorize printing those values, using them as code/options, or reading unknown file paths. In `printf`, approved values belong in data arguments after a fixed nonmutating format, for example `printf -- '%s' "$WORKSPACE_LABEL"`.
|
|
701
|
-
|
|
702
|
-
Literal `herdr agent prompt` commands can be composed with independent `cat` readers and passive text pipelines. Prompt text stays data; command substitutions, environment mutation, unknown consumers, and executable pipelines cannot establish the proof. All reader operands and redirects still receive the ordinary sensitive-path checks. Literal loops also support `herdr pane read ID --source recent-unwrapped --lines N`, with the binder restricted to `ID`, and `2>&1` file-descriptor duplication. A bounded Python stdin processor supports only `import json,sys; d=json.load(sys.stdin); print(d["result"].get("text","") if isinstance(d.get("result"),dict) else d)`, including insignificant spacing and single lowercase-letter local renaming. Extra imports, statements, calls, runtime options, arguments, and other Python programs cannot establish this loop proof. The existing loop size and command limits apply.
|
|
703
|
-
|
|
704
|
-
Prompt composition also supports one `cd [--] PATH` with a literal relative or absolute directory at the start of the final `&&` chain. All subsequent inspection must remain in that chain, so a failed `cd` cannot reach its readers. Directory names may contain quoted spaces. Multiple `cd` commands, later `;` or newline boundaries, tilde or variable expansion, other `cd` options, background jobs, `||`, and navigation in pipelines remain unproved. Supported Git inspection can use literal `-C PATH` prefixes with `grep`, `status`, `rev-parse`, or `rev-list`; execution and startup options remain unsupported. Navigation composition refuses relative file redirects, including redirects on `cd` and Git commands, because those use the shell directory before the command runs. Absolute redirects still receive ordinary path checks. Named directories receive sensitive-path checks with directory-prefix semantics. Only a proved `cd` chain qualifies relative reader operands with that directory; Git `-C` qualifies that command's file operands without changing shell state. Git grep uses the shared grep pattern-versus-file checks. This checks textual operands and does not resolve aliases, symlinks, ambient directories, or command lookup.
|
|
705
|
-
|
|
706
|
-
The guard recognizes `rtk`, `rtk proxy`, `command`, and supported `env` prefixes and checks commands in pipelines and chains. Quoted filenames, comments, and redirects retain sensitive-path checks. Jq filters and inline awk programs qualify only when their actual program and options establish passive behavior. Literal environment-command text in `rg`, `grep`, `git grep`, `echo`, and `printf` is allowed only with supported command roles and passive pipeline consumers. Environment-source evidence and startup identity checks also apply to the complete original invocation. Custom dangerous-command patterns apply to both the original input and proved expansions.
|
|
707
|
-
|
|
708
|
-
Jq admission uses a closed grammar for `.field` traversal, literal string/numeric indexes, `[]`/`[]?`, parentheses, `//`, pipelines, nested objects/arrays, literal JSON values, comparisons, arithmetic and `and`/`or`. It admits the pure zero-argument filters `length`, `keys`, `keys_unsorted`, `type`, `values`, `empty`, `add`, `min`, `max`, `sort`, `unique`, `flatten`, `not`, `reverse`, `to_entries` and `from_entries`; single-argument calls are `map`, `map_values`, `select`, `contains`, `has`, `sort_by`, `group_by`, `unique_by`, `any`, `all` and `join`. Operator precedence remains jq's responsibility; the guard validates complete operands and delimiters without evaluating a filter. Unknown functions/syntax, comments, interpolation, variables, `env`/`$ENV`, imports/includes and program-loading options refuse. A string or field named `env` stays data. Limits are 65,536 UTF-8 bytes, 4,096 tokens and 64 nested expression levels. Known formatting/input flags must precede the literal filter. File operands, redirects, downstream consumers and configured command/path rules still apply. Unquoted file globs and tilde paths anywhere in a compound jq invocation refuse; quote or escape genuinely literal filenames, or provide explicit nonsensitive paths.
|
|
709
|
-
|
|
710
|
-
This is a textual jq proof under trusted native executables and host startup configuration. Normal jq loads a home `.jq` file, which can redefine builtins; the guard does not inspect it or prove module provenance. `-L` does not suppress that startup file. The supported exact POSIX child-process form `env HOME=/dev/null jq 'FILTER' file.json` avoids the user home-file lookup. Other explicit startup assignments/env prefixes anywhere in the compound invocation do not receive the jq proof, including producer/consumer cwd mutations. Literal directory changes must satisfy the existing gated navigation proof. Neither form certifies JSON contents, native binaries, aliases or symlinks.
|
|
711
|
-
|
|
712
|
-
Every jq compound command must have a supported native data, navigation, declared frontend or existing literal-script role. Unknown heads, `builtin` wrappers, directory-stack commands and shell state mutations cannot establish context. Declared CLI producers and literal script roles retain their ordinary policies; their source contents are not certified passive.
|
|
713
|
-
|
|
714
|
-
Syntax compilation supports `python3 -I -S -m py_compile src/main.py`, also `python`, known RTK/command wrappers and combined/reordered `-I`, `-S`, `-B` flags before `-m`. Both isolation flags are required: `-I` excludes cwd/user imports and Python startup variables, and `-S` disables site hooks. The module must be exactly `py_compile`, followed by 1–32 literal nonsensitive `.py` paths. Stdin filename lists, unknown flags/modules, expansions, startup mutations and executable output consumers refuse. Target source is compiled without execution, but `__pycache__` writes still occur with `-B`, and error output may quote source. This does not inspect source contents or attest filesystem/runtime identity.
|
|
715
|
-
|
|
716
|
-
With any `additionalBlockedPaths` rule, implicit compiler cache/temp filenames cannot be proved against that policy, so `py_compile` refuses. Use a cache-free syntax parse instead: `python3 -I -S -B -c 'import ast; ast.parse(open("src/main.py", "rb").read(), filename="src/main.py")'`. This form remains subject to source-path, inline-program and command policies. It parses the named source without executing it or writing target bytecode caches. The refusal explains the cache boundary separately from environment access.
|
|
717
|
-
|
|
718
|
-
Paths are checked against sensitive filename patterns and configured path rules. Supported proofs apply those checks to their expanded operands. Ordinary parent-directory and absolute paths may be allowed; the guard does not resolve filesystem paths or symlinks, or enforce repository confinement. The default kubeconfig pattern protects every path segment containing `kubeconfig`, including ancestor directories and names without separators such as `mykubeconfig` or `kubeconfig2`. Only a final ordinary Markdown basename that does not start with `kubeconfig`, such as `check-kubeconfig-topology.md` or `cluster-kubeconfig-notes.md`, has the documentation exception; the `.md` suffix must be the exact end of the path. A kubeconfig-containing ancestor still matches the blocked pattern; `kubeconfig.md` remains protected. Existing explicit path allowances take precedence over blocked patterns, including template names such as `prod-kubeconfig/.env.example` and configured `additionalAllowedPaths`. Otherwise, configured blocked paths still apply to documentation names. This filename convention does not attest file contents, and there is no blanket Markdown or memory-directory exception.
|
|
719
|
-
|
|
720
|
-
Recognized Linux process-environment paths such as `/proc/self/environ`, `/proc/thread-self/environ`, and PID/task variants are blocked before configured path exceptions.
|
|
721
|
-
|
|
722
|
-
Single literal `echo`/`printf` writes with output redirection and single `cat`/`tee` heredoc writes are allowed. Heredoc braces are data. Use a quoted delimiter for literal code; unquoted heredocs containing `$`, backticks, or backslashes do not receive the literal-write exception. The exception permits only supported combinations with navigation or selected inspections; unsupported following commands remain outside it. Supported complete Python stdin heredocs are checked as inline programs, with the normal runtime-argument, path, execution, and environment checks.
|
|
723
|
-
|
|
724
|
-
A supported Python stdin heredoc can be followed by complete literal `cat`/`tee` heredoc writers and passive consumers. The guard retains every writer header, file operand and redirect while excluding only the proved literal bodies from path evidence. Incomplete bodies, executable/unknown headers and unsupported following commands gain no exception. Heredoc composition is bounded to 32 bodies and 65,536 bytes. This separates prose from path operands; Bash writes/output are not content attestation, and Write/Edit secret scanning remains separate.
|
|
701
|
+
### Shell policy
|
|
725
702
|
|
|
726
|
-
|
|
703
|
+
Bash and PowerShell use separate parsers and one shared policy. The policy checks that the command text names no secret source and supplies no code that the guard cannot inspect. A parse error, an analysis limit, or an unresolved executable, file path, environment name, or code operand refuses the command. Refusal messages identify the rule and give one recovery hint per rule family.
|
|
727
704
|
|
|
728
|
-
The
|
|
705
|
+
The guard follows local bindings, finite loops, substitutions, redirects, pipelines, nested supported shell bodies, and command chains. It checks each reachable command and each possible literal path. For example, `F=README.md; cat "$F"` passes. A binding made only after a successful `cd` does not become certain after a later semicolon. Command output does not establish a known filename or executable. Unsupported shell syntax and shell state changes refuse.
|
|
729
706
|
|
|
730
|
-
|
|
707
|
+
`HOME`, `PWD`, `OLDPWD`, and `PATH` are built-in non-secret names in Bash and PowerShell. Other environment reads require exact names in `credentialGuard.allowedEnvironmentVariables`, whose default list is empty. Bash HOME resolves to the hook home directory, and PWD follows the analyzed working directory. A successful Bash `cd` also records OLDPWD. Unresolved values, including PowerShell environment-provider values, remain unknown for roles that require literal paths or code. All four names retain ordinary path, code, and startup checks: `ls "$HOME/projects"` can pass, `cat "$HOME/.env"` refuses, and changing PATH before an interpreter refuses. Local literal bindings are separate from ambient environment values. Environment dumps, process-environment files, credential-store commands, and startup or executable-lookup mutations refuse. Bash treats `%NAME%` as literal text. PowerShell environment providers and names use PowerShell rules.
|
|
731
708
|
|
|
732
|
-
|
|
709
|
+
Command argument roles distinguish data, paths, environment names, executables, and code. Literal search patterns and Herdr prompt text stay data. Names-only listing and staging commands may name files that content readers cannot open. An unknown executable with literal nonsensitive operands can pass. This does not inspect its implementation or certify the contents of existing scripts, project tasks, native executables, aliases, or host startup files. Known CLI operations that require a wrapper still refuse. Supported literal help and version requests can pass without the wrapper.
|
|
733
710
|
|
|
734
|
-
|
|
711
|
+
Inline Python, JavaScript, and other runtime code refuse because they have no analyzer. This includes the Python and Node programs that older versions recognized with special-case patterns. Supported literal shell bodies receive recursive policy checks. Jq uses a closed passive grammar; it admits ordinary projections, literal objects and arrays, and supported pure filters. Environment access, imports, program files, interpolation, and unknown jq syntax refuse. Jq runs under the trusted host-startup assumption: the guard does not inspect the user's `.jq` file. The limited awk field-projection and sed print grammars also refuse unsupported programs.
|
|
735
712
|
|
|
736
|
-
|
|
713
|
+
`python3 -m py_compile src/main.py` is supported with literal nonsensitive source operands. Isolation flags and cache-location proofs are not required. Compilation can write bytecode caches and show source in error output. The guard checks the supplied operands; it does not inspect source contents or runtime identity. Inline cache-free Python alternatives remain unsupported.
|
|
737
714
|
|
|
738
|
-
|
|
715
|
+
Literal heredoc bodies can be written as data. Unquoted heredoc expansion is analyzed, and code sent to an interpreter requires a code analyzer. Redirect destinations receive path checks. Files written or copied during a command do not become trusted existing scripts when invoked later in that command. Bash output and heredoc writes do not receive Write/Edit content scanning.
|
|
739
716
|
|
|
740
|
-
|
|
717
|
+
Copy operations in a Herdr chain require `credentialGuard.chainCopyDestinations`. Copies also receive this destination proof whenever the configured list is nonempty. The synchronous filesystem check refuses errors, symlinks, missing parent directories, and destinations outside the configured directories. Ordinary copies without a Herdr invocation or configured destinations still receive normal source and destination checks.
|
|
741
718
|
|
|
742
|
-
|
|
719
|
+
Sensitive paths include credential files and configured blocked paths. Known template paths and explicit allowed paths can provide exceptions. Process-environment files cannot be allowed by a path exception. Slash direction and Windows path case are normalized independently of the host OS. General path checks do not resolve filesystem symlinks or confine commands to the repository; the copy-destination check above is the bounded filesystem exception. Custom command patterns apply to the original text, nested shell text, and resolved invocations.
|
|
743
720
|
|
|
744
|
-
|
|
721
|
+
The kubeconfig pattern protects path segments containing `kubeconfig`. A final ordinary Markdown basename such as `check-kubeconfig-topology.md` has a documentation exception; `kubeconfig.md` and kubeconfig-containing parent directories remain protected. Explicit allowed paths take precedence over ordinary blocked patterns. This filename convention does not attest file contents.
|
|
745
722
|
|
|
746
723
|
### Setup for OpenCode
|
|
747
724
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/credential-guard/bash.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAKV,UAAU,EAIV,MAAM,EAIP,MAAM,MAAM,CAAC;AAgvBd,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAE3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-hook.d.ts","sourceRoot":"","sources":["../../src/credential-guard/claude-hook.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|
|
1
|
+
{"version":3,"file":"claude-hook.d.ts","sourceRoot":"","sources":["../../src/credential-guard/claude-hook.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.test.d.ts","sourceRoot":"","sources":["../../src/credential-guard/engine.test.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,cAAc,UAoI1B,CAAC;AACF,eAAO,MAAM,gBAAgB,UA0T5B,CAAC;AA4FF,eAAO,MAAM,oBAAoB,UAShC,CAAC;AACF,eAAO,MAAM,sBAAsB,UA+BlC,CAAC"}
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Credential Guard
|
|
3
|
-
*
|
|
4
|
-
* Security patterns and functions for detecting sensitive files and secrets.
|
|
5
|
-
* Used by AI coding agent hooks/plugins.
|
|
6
|
-
*
|
|
7
|
-
* Security layers:
|
|
8
|
-
* 1. Path-based blocking (files that should never be read)
|
|
9
|
-
* 2. Content scanning (detect secrets in write operations)
|
|
10
|
-
* 3. Dangerous bash command detection
|
|
11
|
-
* 4. CLI tool blocking (must use wrapper tools)
|
|
12
|
-
*
|
|
13
|
-
* Note: This is a convenience layer. Real security should be enforced
|
|
14
|
-
* at infrastructure level (K8s RBAC, file permissions, etc.)
|
|
15
|
-
*/
|
|
16
1
|
import type { CredentialGuardConfig } from "#config/types";
|
|
17
2
|
export { findSecretMatches } from "#shared/credential-patterns";
|
|
18
3
|
export { redactSensitiveText } from "#shared/content-security";
|
|
@@ -47,33 +32,21 @@ export declare function extractFilePath(args: Record<string, unknown>): string;
|
|
|
47
32
|
export declare function extractContent(args: Record<string, unknown>): string;
|
|
48
33
|
/** Extract command from hook arguments. */
|
|
49
34
|
export declare function extractCommand(args: Record<string, unknown>): string;
|
|
50
|
-
/**
|
|
51
|
-
* Create a credential guard with optional extra patterns merged into defaults.
|
|
52
|
-
*
|
|
53
|
-
* @param config - Optional overrides. Arrays are concatenated with defaults (not replaced).
|
|
54
|
-
* @returns Object with all guard functions bound to the merged pattern sets.
|
|
55
|
-
*/
|
|
56
35
|
export declare function createCredentialGuard(config?: CredentialGuardConfig): CredentialGuard;
|
|
57
36
|
/** Handle tool execution with default guard (no extra config). */
|
|
58
|
-
export declare const handleToolExecuteBefore:
|
|
37
|
+
export declare const handleToolExecuteBefore: CredentialGuard["handleToolExecuteBefore"];
|
|
59
38
|
/** Detect secrets in content with default guard. */
|
|
60
|
-
export declare const detectSecrets:
|
|
61
|
-
name: string;
|
|
62
|
-
match: string;
|
|
63
|
-
} | null;
|
|
39
|
+
export declare const detectSecrets: CredentialGuard["detectSecrets"];
|
|
64
40
|
/** Check if a path is in the allowed exceptions list (default guard). */
|
|
65
|
-
export declare const isPathAllowed:
|
|
41
|
+
export declare const isPathAllowed: CredentialGuard["isPathAllowed"];
|
|
66
42
|
/** Check if a path should be blocked (default guard). */
|
|
67
|
-
export declare const isPathBlocked:
|
|
43
|
+
export declare const isPathBlocked: CredentialGuard["isPathBlocked"];
|
|
68
44
|
/** Check if a bash command might expose secrets (default guard). */
|
|
69
|
-
export declare const isDangerousBashCommand:
|
|
45
|
+
export declare const isDangerousBashCommand: CredentialGuard["isDangerousBashCommand"];
|
|
70
46
|
/** Get blocked CLI tool info (default guard). */
|
|
71
|
-
export declare const getBlockedCliTool:
|
|
72
|
-
name: string;
|
|
73
|
-
wrapper: string;
|
|
74
|
-
} | null;
|
|
47
|
+
export declare const getBlockedCliTool: CredentialGuard["getBlockedCliTool"];
|
|
75
48
|
/** Check if a gh command is allowed (default guard). */
|
|
76
|
-
export declare const isGhCommandAllowed:
|
|
49
|
+
export declare const isGhCommandAllowed: CredentialGuard["isGhCommandAllowed"];
|
|
77
50
|
/** Detect sleep-polling with agent-tools wrapper commands (default guard). */
|
|
78
|
-
export declare const detectSleepPolling:
|
|
51
|
+
export declare const detectSleepPolling: CredentialGuard["detectSleepPolling"];
|
|
79
52
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/credential-guard/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/credential-guard/index.ts"],"names":[],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2CAA2C;AAC3C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAQpE;AAED,2CAA2C;AAC3C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAEpE;AAiFD,wBAAgB,qBAAqB,CAAC,MAAM,CAAC,EAAE,qBAAqB,GAAG,eAAe,CA4LrF;AAKD,kEAAkE;AAClE,eAAO,MAAM,uBAAuB,EAAE,eAAe,CAAC,yBAAyB,CAC3B,CAAC;AAErD,oDAAoD;AACpD,eAAO,MAAM,aAAa,EAAE,eAAe,CAAC,eAAe,CACjB,CAAC;AAE3C,yEAAyE;AACzE,eAAO,MAAM,aAAa,EAAE,eAAe,CAAC,eAAe,CACjB,CAAC;AAE3C,yDAAyD;AACzD,eAAO,MAAM,aAAa,EAAE,eAAe,CAAC,eAAe,CACjB,CAAC;AAE3C,oEAAoE;AACpE,eAAO,MAAM,sBAAsB,EAAE,eAAe,CAAC,wBAAwB,CAC1B,CAAC;AAEpD,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,EAAE,eAAe,CAAC,mBAAmB,CACrB,CAAC;AAE/C,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CACtB,CAAC;AAEhD,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAAC,oBAAoB,CACtB,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export type Span = {
|
|
2
|
+
readonly start: number;
|
|
3
|
+
readonly end: number;
|
|
4
|
+
};
|
|
5
|
+
export type Script = {
|
|
6
|
+
readonly kind: "script";
|
|
7
|
+
readonly dialect: "bash" | "powershell";
|
|
8
|
+
readonly source: string;
|
|
9
|
+
readonly body: List;
|
|
10
|
+
readonly span: Span;
|
|
11
|
+
};
|
|
12
|
+
export type List = {
|
|
13
|
+
readonly items: readonly AndOr[];
|
|
14
|
+
};
|
|
15
|
+
export type AndOr = {
|
|
16
|
+
readonly first: Pipeline;
|
|
17
|
+
readonly background: boolean;
|
|
18
|
+
readonly rest: readonly {
|
|
19
|
+
readonly op: "&&" | "||";
|
|
20
|
+
readonly pipeline: Pipeline;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
export type Pipeline = {
|
|
24
|
+
readonly negated: boolean;
|
|
25
|
+
readonly stderr: boolean;
|
|
26
|
+
readonly commands: readonly Command[];
|
|
27
|
+
};
|
|
28
|
+
export type Command = SimpleCommand | {
|
|
29
|
+
readonly kind: "group";
|
|
30
|
+
readonly subshell: boolean;
|
|
31
|
+
readonly body: List;
|
|
32
|
+
readonly redirects: readonly Redirect[];
|
|
33
|
+
readonly span: Span;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "for";
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly items: readonly Word[];
|
|
38
|
+
readonly body: List;
|
|
39
|
+
readonly redirects: readonly Redirect[];
|
|
40
|
+
readonly span: Span;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: "while";
|
|
43
|
+
readonly condition: List;
|
|
44
|
+
readonly body: List;
|
|
45
|
+
readonly redirects: readonly Redirect[];
|
|
46
|
+
readonly span: Span;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "until";
|
|
49
|
+
readonly condition: List;
|
|
50
|
+
readonly body: List;
|
|
51
|
+
readonly redirects: readonly Redirect[];
|
|
52
|
+
readonly span: Span;
|
|
53
|
+
} | {
|
|
54
|
+
readonly kind: "if";
|
|
55
|
+
readonly branches: readonly {
|
|
56
|
+
readonly condition: List;
|
|
57
|
+
readonly body: List;
|
|
58
|
+
}[];
|
|
59
|
+
readonly otherwise: List | null;
|
|
60
|
+
readonly redirects: readonly Redirect[];
|
|
61
|
+
readonly span: Span;
|
|
62
|
+
} | {
|
|
63
|
+
readonly kind: "case";
|
|
64
|
+
readonly subject: Word;
|
|
65
|
+
readonly arms: readonly {
|
|
66
|
+
readonly patterns: readonly Word[];
|
|
67
|
+
readonly body: List;
|
|
68
|
+
}[];
|
|
69
|
+
readonly redirects: readonly Redirect[];
|
|
70
|
+
readonly span: Span;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "test";
|
|
73
|
+
readonly words: readonly Word[];
|
|
74
|
+
readonly span: Span;
|
|
75
|
+
};
|
|
76
|
+
export type SimpleCommand = {
|
|
77
|
+
readonly kind: "simple";
|
|
78
|
+
readonly assignments: readonly Assignment[];
|
|
79
|
+
readonly argv: readonly Word[];
|
|
80
|
+
readonly redirects: readonly Redirect[];
|
|
81
|
+
readonly span: Span;
|
|
82
|
+
};
|
|
83
|
+
export type Assignment = {
|
|
84
|
+
readonly operation: "replace" | "opaque";
|
|
85
|
+
readonly name: string;
|
|
86
|
+
readonly value: Word;
|
|
87
|
+
readonly exported: boolean;
|
|
88
|
+
};
|
|
89
|
+
export type Word = {
|
|
90
|
+
readonly split: boolean;
|
|
91
|
+
readonly parts: readonly WordPart[];
|
|
92
|
+
readonly span: Span;
|
|
93
|
+
};
|
|
94
|
+
export type WordPart = {
|
|
95
|
+
readonly kind: "literal";
|
|
96
|
+
readonly text: string;
|
|
97
|
+
readonly quoted: boolean;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: "glob";
|
|
100
|
+
readonly text: string;
|
|
101
|
+
} | {
|
|
102
|
+
readonly kind: "brace";
|
|
103
|
+
readonly alternatives: readonly string[];
|
|
104
|
+
} | {
|
|
105
|
+
readonly kind: "parameter";
|
|
106
|
+
readonly name: string;
|
|
107
|
+
readonly ambient: boolean;
|
|
108
|
+
readonly operator: "plain" | "default" | "alternate" | "length";
|
|
109
|
+
readonly operand: Word | null;
|
|
110
|
+
readonly span: Span;
|
|
111
|
+
} | {
|
|
112
|
+
readonly kind: "special";
|
|
113
|
+
readonly name: string;
|
|
114
|
+
} | {
|
|
115
|
+
readonly kind: "command-substitution";
|
|
116
|
+
readonly body: Script;
|
|
117
|
+
} | {
|
|
118
|
+
readonly kind: "process-substitution";
|
|
119
|
+
readonly body: Script;
|
|
120
|
+
};
|
|
121
|
+
export type Redirect = ({
|
|
122
|
+
readonly kind: "file";
|
|
123
|
+
readonly op: "<" | ">" | ">>" | "<>" | ">|" | "&>" | "&>>";
|
|
124
|
+
readonly target: Word;
|
|
125
|
+
} | {
|
|
126
|
+
readonly kind: "duplicate";
|
|
127
|
+
readonly input: boolean;
|
|
128
|
+
readonly target: string;
|
|
129
|
+
} | {
|
|
130
|
+
readonly kind: "heredoc";
|
|
131
|
+
readonly body: Word;
|
|
132
|
+
readonly literal: boolean;
|
|
133
|
+
} | {
|
|
134
|
+
readonly kind: "herestring";
|
|
135
|
+
readonly body: Word;
|
|
136
|
+
}) & {
|
|
137
|
+
readonly fd: number | null;
|
|
138
|
+
};
|
|
139
|
+
export type ParseErrorCode = "syntax" | "unterminated-quote" | "unterminated-heredoc" | "unterminated-substitution" | "function-definition" | "unsupported-keyword" | "indirect-expansion" | "unsupported-parameter-operator" | "depth-limit" | "size-limit" | "work-limit";
|
|
140
|
+
export type ParseError = {
|
|
141
|
+
readonly kind: "parse-error";
|
|
142
|
+
readonly code: ParseErrorCode;
|
|
143
|
+
readonly span: Span;
|
|
144
|
+
};
|
|
145
|
+
export declare const MAX_ANALYSIS_UNITS = 4096;
|
|
146
|
+
export declare const MAX_PARSE_DEPTH = 8;
|
|
147
|
+
export declare const MAX_SCRIPT_BYTES = 262144;
|
|
148
|
+
export declare function literalWord(text: string, span?: Span): Word;
|
|
149
|
+
export declare function wordText(word: Word): string | undefined;
|
|
150
|
+
//# sourceMappingURL=ir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.d.ts","sourceRoot":"","sources":["../../src/credential-guard/ir.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CA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AQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC5E;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAA;CAAE,CACvD,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AACnC,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,oBAAoB,GACpB,sBAAsB,GACtB,2BAA2B,GAC3B,qBAAqB,GACrB,qBAAqB,GACrB,oBAAoB,GACpB,gCAAgC,GAChC,aAAa,GACb,YAAY,GACZ,YAAY,CAAC;AACjB,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AACF,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,gBAAgB,SAAS,CAAC;AACvC,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,IAA2B,GAAG,IAAI,CAEjF;AACD,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAOvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal-output.d.ts","sourceRoot":"","sources":["../../src/credential-guard/literal-output.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAO1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passive-awk.d.ts","sourceRoot":"","sources":["../../src/credential-guard/passive-awk.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA8OzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"passive-jq.d.ts","sourceRoot":"","sources":["../../src/credential-guard/passive-jq.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"passive-jq.d.ts","sourceRoot":"","sources":["../../src/credential-guard/passive-jq.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEzD;AAmSD,4FAA4F;AAC5F,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAsBxE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passive-sed.d.ts","sourceRoot":"","sources":["../../src/credential-guard/passive-sed.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CA6EzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passive.test.d.ts","sourceRoot":"","sources":["../../src/credential-guard/passive.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const CODE_OR_PROSE_EXTENSION: RegExp;
|
|
2
|
+
export declare const DEFAULT_BLOCKED_PATH_PATTERNS: RegExp[];
|
|
3
|
+
export declare const DEFAULT_ALLOWED_PATH_PATTERNS: RegExp[];
|
|
4
|
+
export type PathContext = {
|
|
5
|
+
readonly home: string;
|
|
6
|
+
readonly cwd: string;
|
|
7
|
+
readonly contentRead?: boolean;
|
|
8
|
+
readonly additionalBlockedPaths?: readonly RegExp[];
|
|
9
|
+
readonly additionalAllowedPaths?: readonly RegExp[];
|
|
10
|
+
};
|
|
11
|
+
export declare function normalizePath(path: string, home?: string, cwd?: string): string;
|
|
12
|
+
export declare function isSensitivePath(path: string, context: PathContext): boolean;
|
|
13
|
+
export declare function expandGlobAlternatives(pattern: string): readonly string[] | null;
|
|
14
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/credential-guard/paths.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,QAC8C,CAAC;AAEnF,eAAO,MAAM,6BAA6B,EAAE,MAAM,EAgBjD,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,MAAM,EAEjD,CAAC;AAKF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpD,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACrD,CAAC;AACF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAmBzE;AAID,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CA2B3E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,IAAI,CAkBhF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ParseError, Script, Span } from "./ir";
|
|
2
|
+
import type { PathContext } from "./paths";
|
|
3
|
+
import type { Registry } from "./registry";
|
|
4
|
+
export type RuleId = string & {
|
|
5
|
+
readonly __brand: "RuleId";
|
|
6
|
+
};
|
|
7
|
+
export type Finding = {
|
|
8
|
+
readonly rule: RuleId;
|
|
9
|
+
readonly detail: string;
|
|
10
|
+
readonly span: Span;
|
|
11
|
+
};
|
|
12
|
+
export type Decision = {
|
|
13
|
+
readonly kind: "pass";
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "violation";
|
|
16
|
+
readonly findings: readonly [Finding, ...Finding[]];
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "missing-knowledge";
|
|
19
|
+
readonly findings: readonly [Finding, ...Finding[]];
|
|
20
|
+
};
|
|
21
|
+
export type PolicyContext = PathContext & {
|
|
22
|
+
readonly approvedNames?: ReadonlySet<string>;
|
|
23
|
+
readonly onInvocation?: (executable: string, argv: readonly (string | undefined)[]) => void;
|
|
24
|
+
readonly registry?: Registry;
|
|
25
|
+
readonly dangerousPatterns?: readonly RegExp[];
|
|
26
|
+
readonly isPathBlocked?: (path: string) => boolean;
|
|
27
|
+
readonly chainCopyDestinations?: readonly string[];
|
|
28
|
+
readonly proveCopyDestination?: (path: string, source: string) => boolean;
|
|
29
|
+
};
|
|
30
|
+
export type Value = {
|
|
31
|
+
readonly kind: "literal";
|
|
32
|
+
readonly texts: readonly string[];
|
|
33
|
+
} | {
|
|
34
|
+
readonly kind: "opaque";
|
|
35
|
+
readonly mentions: readonly string[];
|
|
36
|
+
readonly prefix: string;
|
|
37
|
+
readonly globPatterns?: readonly string[];
|
|
38
|
+
readonly supplied?: boolean;
|
|
39
|
+
} | {
|
|
40
|
+
readonly kind: "stream";
|
|
41
|
+
readonly stdout: Value;
|
|
42
|
+
};
|
|
43
|
+
export declare const MAX_VALUE_ALTERNATIVES = 64;
|
|
44
|
+
export declare const MAX_LOOP_PASSES = 8;
|
|
45
|
+
export declare const MAX_FOLD_STEPS = 20000;
|
|
46
|
+
export declare function judge(script: Script | ParseError, context: PolicyContext): Decision;
|
|
47
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/credential-guard/policy.ts"],"names":[],"mapp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