@comment-labs/opencode-hidden-guard 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +13 -2
- package/dist/index.d.mts +5 -0
- package/dist/index.mjs +301 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +39 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @comment-labs/opencode-hidden-guard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blocks agent reads of hidden (dot) files — `.env`, `.ssh`, token files, any
|
|
4
|
+
basename starting with `.` — at two layers:
|
|
5
|
+
|
|
6
|
+
- **Tool layer**: any tool argument that references a hidden file path
|
|
7
|
+
(`read`/`glob`/`ls`/`grep` path args, nested paths).
|
|
8
|
+
- **Bash layer**: any bash command whose positional file arguments include a
|
|
9
|
+
hidden file (parsed with [unbash](https://github.com/lukeed/unbash), so
|
|
10
|
+
flags, env prefixes and substitutions are handled).
|
|
11
|
+
|
|
12
|
+
Prose fields (`text`, `description`) are exempt — mentioning `.env` in a
|
|
13
|
+
question is fine. Options: `{ allow: string[], disabled: boolean }`
|
|
14
|
+
(allow-lists specific basenames). Fails open on bash parse errors.
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Plugin } from "@opencode/plugin";
|
|
2
|
+
import { parse } from "unbash";
|
|
3
|
+
//#region src/core.ts
|
|
4
|
+
/**
|
|
5
|
+
* hidden-guard core: dotfile-read detection for tool args and bash
|
|
6
|
+
* commands. Framework-agnostic — the V2 adapter runs this core.
|
|
7
|
+
*/
|
|
8
|
+
const PATH_SEGMENT_SPLIT_REGEX = /[\\/]/u;
|
|
9
|
+
const PATH_ISH_REGEX = /^[.~/]/u;
|
|
10
|
+
const URL_REGEX = /:\/\//u;
|
|
11
|
+
function isWord(n) {
|
|
12
|
+
return typeof n === "object" && n !== null && "text" in n && typeof n.text === "string" && !("type" in n && n.type !== void 0 && n.type !== "");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dotfile DIRECTORIES that are infrastructure, not secrets — allowed as
|
|
16
|
+
* any path segment (.config, .git, build caches …).
|
|
17
|
+
*/
|
|
18
|
+
const INFRA_SEGMENTS = /* @__PURE__ */ new Set([
|
|
19
|
+
".config",
|
|
20
|
+
".local",
|
|
21
|
+
".cache",
|
|
22
|
+
".git",
|
|
23
|
+
".github",
|
|
24
|
+
".gitlab",
|
|
25
|
+
".husky",
|
|
26
|
+
".opencode",
|
|
27
|
+
".codemode",
|
|
28
|
+
".tgrep",
|
|
29
|
+
".turbo",
|
|
30
|
+
".next",
|
|
31
|
+
".nuxt",
|
|
32
|
+
".svelte-kit",
|
|
33
|
+
".astro",
|
|
34
|
+
".output",
|
|
35
|
+
".pnpm-store",
|
|
36
|
+
".venv",
|
|
37
|
+
".venvs",
|
|
38
|
+
".tox",
|
|
39
|
+
".mypy_cache",
|
|
40
|
+
".pytest_cache",
|
|
41
|
+
".ruff_cache",
|
|
42
|
+
".idea",
|
|
43
|
+
".vscode",
|
|
44
|
+
".devcontainer",
|
|
45
|
+
".storybook",
|
|
46
|
+
".vercel",
|
|
47
|
+
".wrangler",
|
|
48
|
+
".claude",
|
|
49
|
+
".codesandbox",
|
|
50
|
+
".parcel-cache",
|
|
51
|
+
".yarn",
|
|
52
|
+
".expo",
|
|
53
|
+
".docusaurus"
|
|
54
|
+
]);
|
|
55
|
+
/**
|
|
56
|
+
* Dotfile NAMES that are code/config, not secrets — allowed as leaves.
|
|
57
|
+
*/
|
|
58
|
+
const INFRA_FILES = /* @__PURE__ */ new Set([
|
|
59
|
+
".gitignore",
|
|
60
|
+
".gitattributes",
|
|
61
|
+
".gitmodules",
|
|
62
|
+
".gitkeep",
|
|
63
|
+
".editorconfig",
|
|
64
|
+
".prettierrc",
|
|
65
|
+
".eslintrc",
|
|
66
|
+
".oxlintrc.json",
|
|
67
|
+
".dockerignore",
|
|
68
|
+
".npmignore",
|
|
69
|
+
".nvmrc",
|
|
70
|
+
".node-version",
|
|
71
|
+
".tool-versions",
|
|
72
|
+
".python-version",
|
|
73
|
+
".DS_Store",
|
|
74
|
+
".babelrc",
|
|
75
|
+
".lintstagedrc",
|
|
76
|
+
".czrc",
|
|
77
|
+
".watchmanconfig",
|
|
78
|
+
".hgignore",
|
|
79
|
+
".flake8",
|
|
80
|
+
".pylintrc",
|
|
81
|
+
".prettierignore",
|
|
82
|
+
".eslintignore",
|
|
83
|
+
".stylelintrc",
|
|
84
|
+
".commitlintrc",
|
|
85
|
+
".releaserc",
|
|
86
|
+
".versionrc",
|
|
87
|
+
".taplo.toml",
|
|
88
|
+
".latexmkrc"
|
|
89
|
+
]);
|
|
90
|
+
/**
|
|
91
|
+
* Command flags whose VALUE is an expression — a jq filter, Go template,
|
|
92
|
+
* or JMESPath — never a file path. The word after one of these is not a
|
|
93
|
+
* file argument (gh --jq .headSha, aws --query '.Tags[0].Value' …).
|
|
94
|
+
*/
|
|
95
|
+
const EXPR_VALUE_FLAGS = {
|
|
96
|
+
gh: /* @__PURE__ */ new Set([
|
|
97
|
+
"--jq",
|
|
98
|
+
"--template",
|
|
99
|
+
"-t"
|
|
100
|
+
]),
|
|
101
|
+
aws: /* @__PURE__ */ new Set(["--query"]),
|
|
102
|
+
az: /* @__PURE__ */ new Set(["--query"])
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* jq/yq subcommand aliases that are not the filter itself (yq eval …).
|
|
106
|
+
*/
|
|
107
|
+
const FILTER_EVAL_WORDS = /* @__PURE__ */ new Set([
|
|
108
|
+
"e",
|
|
109
|
+
"eval",
|
|
110
|
+
"eval-all",
|
|
111
|
+
"ea"
|
|
112
|
+
]);
|
|
113
|
+
/**
|
|
114
|
+
* jq flags that consume words from the stream; those words are file (or
|
|
115
|
+
* variable) arguments — they are checked as files and never mistaken for
|
|
116
|
+
* the filter expression.
|
|
117
|
+
*/
|
|
118
|
+
const BASH_VALUE_FLAGS = {
|
|
119
|
+
jq: {
|
|
120
|
+
"-f": 1,
|
|
121
|
+
"--from-file": 1,
|
|
122
|
+
"--slurpfile": 2,
|
|
123
|
+
"--rawfile": 2
|
|
124
|
+
},
|
|
125
|
+
yq: {}
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Any path segment that is a hidden file/dir (`.secrets/tokens.json` is
|
|
129
|
+
* hidden because of `.secrets`, not its basename). Returns the first
|
|
130
|
+
* hidden segment, or undefined.
|
|
131
|
+
*/
|
|
132
|
+
function pathHasHidden(s, opts = {}) {
|
|
133
|
+
if (s === "" || s.length > 4096) return;
|
|
134
|
+
for (const seg of s.split(PATH_SEGMENT_SPLIT_REGEX)) {
|
|
135
|
+
if (seg === "" || [
|
|
136
|
+
".",
|
|
137
|
+
"..",
|
|
138
|
+
"~"
|
|
139
|
+
].includes(seg)) continue;
|
|
140
|
+
if (!seg.startsWith(".")) continue;
|
|
141
|
+
if (INFRA_SEGMENTS.has(seg)) continue;
|
|
142
|
+
if (INFRA_FILES.has(seg)) continue;
|
|
143
|
+
if (!(opts.allow ?? []).includes(seg)) return seg;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function isPlainObject(v) {
|
|
147
|
+
return typeof v === "object" && v !== null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* True when a tool argument object references a hidden file in any
|
|
151
|
+
* path-ish string value (filePath, path, file, or nested arrays of them).
|
|
152
|
+
*/
|
|
153
|
+
function argsTouchHidden(args, opts = {}) {
|
|
154
|
+
const seen = [];
|
|
155
|
+
const visit = (v, depth) => {
|
|
156
|
+
if (v === null || v === void 0 || depth > 6) return;
|
|
157
|
+
if (typeof v === "string") {
|
|
158
|
+
if (v.length > 0 && v.length < 4096 && PATH_ISH_REGEX.test(v)) return pathHasHidden(v, opts);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (!isPlainObject(v)) return;
|
|
162
|
+
if (seen.includes(v)) return;
|
|
163
|
+
seen.push(v);
|
|
164
|
+
for (const [k, val] of Object.entries(v)) {
|
|
165
|
+
if (k === "text" || k === "description") continue;
|
|
166
|
+
const hit = visit(val, depth + 1);
|
|
167
|
+
if (hit !== void 0) return hit;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
return visit(args, 0);
|
|
171
|
+
}
|
|
172
|
+
const MSG = (name, what) => `hidden-guard BLOCKED: \`${name}\` is a hidden (dot) file. ${what} Reading hidden files is not allowed (they hold credentials and local state). If you truly need it, ask the user to paste the relevant part.`;
|
|
173
|
+
function blockMessage(name) {
|
|
174
|
+
return MSG(name, "Requested via a tool.");
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Bash layer: any positional file argument whose basename is a hidden file
|
|
178
|
+
* (any command, any reader — cat .env, wc -l .foo, strings .secret …).
|
|
179
|
+
* NOT file args: flags; the value word of expression flags (--jq, --query,
|
|
180
|
+
* --template — jq/JMESPath/Go-template expressions, never paths); value
|
|
181
|
+
* words of known value-flags (checked as files); and the first positional
|
|
182
|
+
* of jq/yq (the filter expression — files come after it).
|
|
183
|
+
*/
|
|
184
|
+
function bashTouchesHidden(command, opts = {}) {
|
|
185
|
+
if (opts.disabled === true) return;
|
|
186
|
+
let ast;
|
|
187
|
+
try {
|
|
188
|
+
ast = parse(command);
|
|
189
|
+
} catch {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const found = [];
|
|
193
|
+
walkBashAst(ast, found, opts);
|
|
194
|
+
if (found.length === 0) return;
|
|
195
|
+
return MSG(found.join(", "), "Found it in a bash command.");
|
|
196
|
+
}
|
|
197
|
+
function walkBashAst(node, found, opts, depth = 0) {
|
|
198
|
+
if (node === null || node === void 0 || typeof node !== "object" || depth > 32) return;
|
|
199
|
+
if (Array.isArray(node)) {
|
|
200
|
+
for (const child of node) walkBashAst(child, found, opts, depth + 1);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const n = node;
|
|
204
|
+
if (n.type === "Command") scanCommandWords(n, found, opts);
|
|
205
|
+
for (const k of [
|
|
206
|
+
"command",
|
|
207
|
+
"body",
|
|
208
|
+
"clause",
|
|
209
|
+
"then",
|
|
210
|
+
"else",
|
|
211
|
+
"wordlist",
|
|
212
|
+
"commands"
|
|
213
|
+
]) {
|
|
214
|
+
const v = n[k];
|
|
215
|
+
if (v !== null && v !== void 0) walkBashAst(v, found, opts, depth + 1);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function scanCommandWords(node, found, opts) {
|
|
219
|
+
const words = Array.isArray(node.suffix) ? node.suffix.filter((w) => isWord(w)) : [];
|
|
220
|
+
const base = (node.name?.text ?? "").split("/").pop() ?? "";
|
|
221
|
+
const exprFlags = EXPR_VALUE_FLAGS[base];
|
|
222
|
+
const valueFlags = BASH_VALUE_FLAGS[base];
|
|
223
|
+
const filterCmd = base === "jq" || base === "yq";
|
|
224
|
+
let skipExpr = false;
|
|
225
|
+
let consumeValues = 0;
|
|
226
|
+
let sawFilter = false;
|
|
227
|
+
for (const w of words) {
|
|
228
|
+
if (skipExpr) {
|
|
229
|
+
skipExpr = false;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (consumeValues > 0) {
|
|
233
|
+
consumeValues--;
|
|
234
|
+
if (pathHasHidden(w.text, opts) !== void 0 && !found.includes(w.text)) found.push(w.text);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (w.text.startsWith("-") && w.text !== "-") {
|
|
238
|
+
if (exprFlags?.has(w.text) === true) skipExpr = true;
|
|
239
|
+
else {
|
|
240
|
+
const count = valueFlags?.[w.text];
|
|
241
|
+
if (count !== void 0) consumeValues = count;
|
|
242
|
+
}
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (URL_REGEX.test(w.text)) continue;
|
|
246
|
+
if (filterCmd) {
|
|
247
|
+
if (!sawFilter && FILTER_EVAL_WORDS.has(w.text)) continue;
|
|
248
|
+
if (!sawFilter) {
|
|
249
|
+
sawFilter = true;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (pathHasHidden(w.text, opts) !== void 0 && !found.includes(w.text)) found.push(w.text);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/v2.ts
|
|
258
|
+
/**
|
|
259
|
+
* V2 adapter (OpenCode 2) for hidden-guard.
|
|
260
|
+
*/
|
|
261
|
+
function readGuardOptions(value) {
|
|
262
|
+
if (typeof value !== "object" || value === null) return {};
|
|
263
|
+
const options = {};
|
|
264
|
+
if ("disabled" in value && typeof value.disabled === "boolean") options.disabled = value.disabled;
|
|
265
|
+
if ("allow" in value && Array.isArray(value.allow)) options.allow = value.allow.filter((item) => typeof item === "string");
|
|
266
|
+
return options;
|
|
267
|
+
}
|
|
268
|
+
function hasCommand(input) {
|
|
269
|
+
return typeof input === "object" && input !== null && "command" in input;
|
|
270
|
+
}
|
|
271
|
+
const v2def = () => Plugin.define({
|
|
272
|
+
id: "hidden-guard",
|
|
273
|
+
async setup(ctx) {
|
|
274
|
+
const options = readGuardOptions(ctx.options);
|
|
275
|
+
if (options.disabled === true) return;
|
|
276
|
+
await ctx.tool.hook("execute.before", (event) => {
|
|
277
|
+
if (event.tool === "bash" || event.tool === "shell") {
|
|
278
|
+
const cmd = hasCommand(event.input) ? event.input.command : void 0;
|
|
279
|
+
if (typeof cmd === "string") {
|
|
280
|
+
const hit = bashTouchesHidden(cmd, options);
|
|
281
|
+
if (hit !== void 0) throw new Error(hit);
|
|
282
|
+
}
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const hit = argsTouchHidden(event.input, options);
|
|
286
|
+
if (hit !== void 0) throw new Error(blockMessage(hit));
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/index.ts
|
|
292
|
+
/**
|
|
293
|
+
* opencode-hidden-guard — OpenCode 2 plugin.
|
|
294
|
+
*
|
|
295
|
+
* Default export: pure Plugin.define (v2 calls setup()).
|
|
296
|
+
*/
|
|
297
|
+
var src_default = v2def();
|
|
298
|
+
//#endregion
|
|
299
|
+
export { src_default as default };
|
|
300
|
+
|
|
301
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/core.ts","../src/v2.ts","../src/index.ts"],"sourcesContent":["/**\n * hidden-guard core: dotfile-read detection for tool args and bash\n * commands. Framework-agnostic — the V2 adapter runs this core.\n */\nimport { parse } from 'unbash'\n\nexport type HiddenGuardOptions = {\n /** dotfile basenames that are allowed to be read (eg. ['.bashrc']) */\n allow?: string[]\n disabled?: boolean\n}\n\ntype Node = {\n type?: string\n text?: string\n name?: { text?: string }\n suffix?: unknown[]\n commands?: Node[]\n command?: Node\n body?: Node\n clause?: Node\n then?: Node\n else?: Node\n wordlist?: Node[]\n [k: string]: unknown\n}\n\ntype Word = { text: string; pos?: number; end?: number; value?: string }\n\nconst PATH_SEGMENT_SPLIT_REGEX = /[\\\\/]/u\nconst PATH_ISH_REGEX = /^[.~/]/u\nconst URL_REGEX = /:\\/\\//u\n\nfunction isWord(n: unknown): n is Word {\n return typeof n === 'object'\n && n !== null\n && 'text' in n\n && typeof n.text === 'string'\n && !('type' in n && n.type !== undefined && n.type !== '')\n}\n\n/**\n * Dotfile DIRECTORIES that are infrastructure, not secrets — allowed as\n * any path segment (.config, .git, build caches …).\n */\nconst INFRA_SEGMENTS = new Set([\n '.config', '.local', '.cache', '.git', '.github', '.gitlab', '.husky',\n '.opencode', '.codemode', '.tgrep', '.turbo', '.next', '.nuxt',\n '.svelte-kit', '.astro', '.output', '.pnpm-store', '.venv', '.venvs',\n '.tox', '.mypy_cache', '.pytest_cache', '.ruff_cache', '.idea', '.vscode',\n '.devcontainer', '.storybook', '.vercel', '.wrangler', '.claude',\n '.codesandbox', '.parcel-cache', '.yarn', '.expo', '.docusaurus'\n])\n\n/**\n * Dotfile NAMES that are code/config, not secrets — allowed as leaves.\n */\nconst INFRA_FILES = new Set([\n '.gitignore', '.gitattributes', '.gitmodules', '.gitkeep', '.editorconfig',\n '.prettierrc', '.eslintrc', '.oxlintrc.json', '.dockerignore', '.npmignore',\n '.nvmrc', '.node-version', '.tool-versions', '.python-version', '.DS_Store',\n '.babelrc', '.lintstagedrc', '.czrc', '.watchmanconfig', '.hgignore',\n '.flake8', '.pylintrc', '.prettierignore', '.eslintignore', '.stylelintrc',\n '.commitlintrc', '.releaserc', '.versionrc', '.taplo.toml', '.latexmkrc'\n])\n\n/**\n * Command flags whose VALUE is an expression — a jq filter, Go template,\n * or JMESPath — never a file path. The word after one of these is not a\n * file argument (gh --jq .headSha, aws --query '.Tags[0].Value' …).\n */\nconst EXPR_VALUE_FLAGS: Record<string, Set<string>> = {\n gh: new Set([ '--jq', '--template', '-t' ]),\n aws: new Set([ '--query' ]),\n az: new Set([ '--query' ])\n}\n\n/**\n * jq/yq subcommand aliases that are not the filter itself (yq eval …).\n */\nconst FILTER_EVAL_WORDS = new Set([ 'e', 'eval', 'eval-all', 'ea' ])\n\n/**\n * jq flags that consume words from the stream; those words are file (or\n * variable) arguments — they are checked as files and never mistaken for\n * the filter expression.\n */\nconst BASH_VALUE_FLAGS: Record<string, Record<string, number>> = {\n jq: { '-f': 1, '--from-file': 1, '--slurpfile': 2, '--rawfile': 2 },\n yq: {}\n}\n\nexport function isHiddenBase(name: string, opts: HiddenGuardOptions = {}): boolean {\n if (name === '.' || name === '..' || !name.startsWith('.')) {\n return false\n }\n\n if (INFRA_SEGMENTS.has(name) || INFRA_FILES.has(name)) {\n return false\n }\n\n return !(opts.allow ?? []).includes(name)\n}\n\n/**\n * Any path segment that is a hidden file/dir (`.secrets/tokens.json` is\n * hidden because of `.secrets`, not its basename). Returns the first\n * hidden segment, or undefined.\n */\nexport function pathHasHidden(s: string, opts: HiddenGuardOptions = {}): string | undefined {\n if (s === '' || s.length > 4096) {\n return undefined\n }\n\n for (const seg of s.split(PATH_SEGMENT_SPLIT_REGEX)) {\n if (seg === '' || [ '.', '..', '~' ].includes(seg)) {\n continue\n }\n\n if (!seg.startsWith('.')) {\n continue\n }\n\n // infra dot-dirs (.config, .git, …) are walkable; sensitive hidden\n // dirs (.ssh, .aws) and hidden FILES anywhere in the path are not\n if (INFRA_SEGMENTS.has(seg)) {\n continue\n }\n\n if (INFRA_FILES.has(seg)) {\n continue\n }\n\n if (!(opts.allow ?? []).includes(seg)) {\n return seg\n }\n }\n\n return undefined\n}\n\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null\n}\n\n/**\n * True when a tool argument object references a hidden file in any\n * path-ish string value (filePath, path, file, or nested arrays of them).\n */\nexport function argsTouchHidden(args: unknown, opts: HiddenGuardOptions = {}): string | undefined {\n const seen: unknown[] = []\n\n const visit = (v: unknown, depth: number): string | undefined => {\n if (v === null || v === undefined || depth > 6) {\n return undefined\n }\n\n if (typeof v === 'string') {\n // path-ish only: starts with ., / or ~, or a plain dotfile name\n if (v.length > 0 && v.length < 4096 && PATH_ISH_REGEX.test(v)) {\n return pathHasHidden(v, opts)\n }\n\n return undefined\n }\n\n if (!isPlainObject(v)) {\n return undefined\n }\n\n if (seen.includes(v)) {\n return undefined\n }\n\n seen.push(v)\n\n for (const [ k, val ] of Object.entries(v)) {\n // prose fields may legitimately mention dotfiles\n if (k === 'text' || k === 'description') {\n continue\n }\n\n const hit = visit(val, depth + 1)\n if (hit !== undefined) {\n return hit\n }\n }\n\n return undefined\n }\n\n return visit(args, 0)\n}\n\nconst MSG = (name: string, what: string) =>\n `hidden-guard BLOCKED: \\`${name}\\` is a hidden (dot) file. ${what} Reading hidden files is not allowed (they hold credentials and local state). If you truly need it, ask the user to paste the relevant part.`\n\nexport function blockMessage(name: string): string {\n return MSG(name, 'Requested via a tool.')\n}\n\n/**\n * Bash layer: any positional file argument whose basename is a hidden file\n * (any command, any reader — cat .env, wc -l .foo, strings .secret …).\n * NOT file args: flags; the value word of expression flags (--jq, --query,\n * --template — jq/JMESPath/Go-template expressions, never paths); value\n * words of known value-flags (checked as files); and the first positional\n * of jq/yq (the filter expression — files come after it).\n */\nexport function bashTouchesHidden(command: string, opts: HiddenGuardOptions = {}): string | undefined {\n if (opts.disabled === true) {\n return undefined\n }\n\n let ast: Node\n\n try {\n // unbash's own AST types are stricter unions; this loose Node is the\n // analyzer's working shape\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n ast = parse(command) as unknown as Node\n } catch {\n // fail open\n return undefined\n }\n\n const found: string[] = []\n walkBashAst(ast, found, opts)\n\n if (found.length === 0) {\n return undefined\n }\n\n return MSG(found.join(', '), 'Found it in a bash command.')\n}\n\nfunction walkBashAst(node: unknown, found: string[], opts: HiddenGuardOptions, depth = 0): void {\n if (node === null || node === undefined || typeof node !== 'object' || depth > 32) {\n return\n }\n\n if (Array.isArray(node)) {\n for (const child of node) {\n walkBashAst(child, found, opts, depth + 1)\n }\n\n return\n }\n\n // parser AST boundary: every value reaching here comes from unbash's parse()\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const n = node as Node\n if (n.type === 'Command') {\n scanCommandWords(n, found, opts)\n }\n\n for (const k of [ 'command', 'body', 'clause', 'then', 'else', 'wordlist', 'commands' ]) {\n const v = (n as Record<string, unknown>)[k]\n if (v !== null && v !== undefined) {\n walkBashAst(v, found, opts, depth + 1)\n }\n }\n}\n\nfunction scanCommandWords(node: Node, found: string[], opts: HiddenGuardOptions): void {\n const words: Word[] = Array.isArray(node.suffix) ? node.suffix.filter(w => isWord(w)) : []\n const base = (node.name?.text ?? '').split('/').pop() ?? ''\n const exprFlags = EXPR_VALUE_FLAGS[base]\n const valueFlags = BASH_VALUE_FLAGS[base]\n const filterCmd = base === 'jq' || base === 'yq'\n let skipExpr = false\n let consumeValues = 0\n let sawFilter = false\n\n for (const w of words) {\n if (skipExpr) {\n // expression value (--jq .headSha) — not a file argument\n skipExpr = false\n continue\n }\n\n if (consumeValues > 0) {\n // flag value word (-f FILE, --slurpfile VAR FILE) — checked as a\n // file, never treated as the filter\n consumeValues--\n\n const hidden = pathHasHidden(w.text, opts)\n if (hidden !== undefined && !found.includes(w.text)) {\n found.push(w.text)\n }\n\n continue\n }\n\n if (w.text.startsWith('-') && w.text !== '-') {\n if (exprFlags?.has(w.text) === true) {\n skipExpr = true\n } else {\n const count = valueFlags?.[w.text]\n if (count !== undefined) {\n consumeValues = count\n }\n }\n\n continue\n }\n\n // URLs are not filesystem paths — dot-segments inside them\n // (https://host/.well-known/…) are never hidden-file reads\n if (URL_REGEX.test(w.text)) {\n continue\n }\n\n if (filterCmd) {\n if (!sawFilter && FILTER_EVAL_WORDS.has(w.text)) {\n continue\n }\n\n if (!sawFilter) {\n // first positional is the filter expression\n sawFilter = true\n continue\n }\n }\n\n const hidden = pathHasHidden(w.text, opts)\n if (hidden !== undefined && !found.includes(w.text)) {\n found.push(w.text)\n }\n }\n}\n","/**\n * V2 adapter (OpenCode 2) for hidden-guard.\n */\nimport { Plugin } from '@opencode/plugin'\nimport { argsTouchHidden, bashTouchesHidden, blockMessage, type HiddenGuardOptions } from './core'\n\n\nfunction readGuardOptions(value: unknown): HiddenGuardOptions {\n if (typeof value !== 'object' || value === null) {\n return {}\n }\n\n const options: HiddenGuardOptions = {}\n if ('disabled' in value && typeof value.disabled === 'boolean') {\n options.disabled = value.disabled\n }\n\n if ('allow' in value && Array.isArray(value.allow)) {\n options.allow = value.allow.filter((item): item is string => typeof item === 'string')\n }\n\n return options\n}\n\nfunction hasCommand(input: unknown): input is { command: unknown } {\n return typeof input === 'object' && input !== null && 'command' in input\n}\n\nexport const v2def = () =>\n Plugin.define({\n id: 'hidden-guard',\n async setup(ctx) {\n const options = readGuardOptions(ctx.options)\n if (options.disabled === true) {\n return\n }\n\n await ctx.tool.hook('execute.before', event => {\n if (event.tool === 'bash' || event.tool === 'shell') {\n const cmd = hasCommand(event.input) ? event.input.command : undefined\n if (typeof cmd === 'string') {\n const hit = bashTouchesHidden(cmd, options)\n if (hit !== undefined) {\n throw new Error(hit)\n }\n }\n\n return\n }\n\n const hit = argsTouchHidden(event.input, options)\n if (hit !== undefined) {\n throw new Error(blockMessage(hit))\n }\n })\n }\n })\n","/**\n * opencode-hidden-guard — OpenCode 2 plugin.\n *\n * Default export: pure Plugin.define (v2 calls setup()).\n */\nimport { v2def } from './v2'\n\nexport default v2def()\n"],"mappings":";;;;;;;AA6BA,MAAM,2BAA2B;AACjC,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAElB,SAAS,OAAO,GAAuB;CACrC,OAAO,OAAO,MAAM,YACf,MAAM,QACN,UAAU,KACV,OAAO,EAAE,SAAS,YAClB,EAAE,UAAU,KAAK,EAAE,SAAS,KAAA,KAAa,EAAE,SAAS;AAC3D;;;;;AAMA,MAAM,iCAAiB,IAAI,IAAI;CAC7B;CAAW;CAAU;CAAU;CAAQ;CAAW;CAAW;CAC7D;CAAa;CAAa;CAAU;CAAU;CAAS;CACvD;CAAe;CAAU;CAAW;CAAe;CAAS;CAC5D;CAAQ;CAAe;CAAiB;CAAe;CAAS;CAChE;CAAiB;CAAc;CAAW;CAAa;CACvD;CAAgB;CAAiB;CAAS;CAAS;AACrD,CAAC;;;;AAKD,MAAM,8BAAc,IAAI,IAAI;CAC1B;CAAc;CAAkB;CAAe;CAAY;CAC3D;CAAe;CAAa;CAAkB;CAAiB;CAC/D;CAAU;CAAiB;CA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nUA,SAAS,iBAAiB,OAAoC;CAC5D,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,CAAC;CAGV,MAAM,UAA8B,CAAC;CACrC,IAAI,cAAc,SAAS,OAAO,MAAM,aAAa,WACnD,QAAQ,WAAW,MAAM;CAG3B,IAAI,WAAW,SAAS,MAAM,QAAQ,MAAM,KAAK,GAC/C,QAAQ,QAAQ,MAAM,MAAM,QAAQ,SAAyB,OAAO,SAAS,QAAQ;CAGvF,OAAO;AACT;AAEA,SAAS,WAAW,OAA+C;CACjE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,aAAa;AACrE;AAEA,MAAa,cACX,OAAO,OAAO;CACZ,IAAI;CACJ,MAAM,MAAM,KAAK;EACf,MAAM,UAAU,iBAAiB,IAAI,OAAO;EAC5C,IAAI,QAAQ,aAAa,MACvB;EAGF,MAAM,IAAI,KAAK,KAAK,mBAAkB,UAAS;GAC7C,IAAI,MAAM,SAAS,UAAU,MAAM,SAAS,SAAS;IACnD,MAAM,MAAM,WAAW,MAAM,KAAK,IAAI,MAAM,MAAM,UAAU,KAAA;IAC5D,IAAI,OAAO,QAAQ,UAAU;KAC3B,MAAM,MAAM,kBAAkB,KAAK,OAAO;KAC1C,IAAI,QAAQ,KAAA,GACV,MAAM,IAAI,MAAM,GAAG;IAEvB;IAEA;GACF;GAEA,MAAM,MAAM,gBAAgB,MAAM,OAAO,OAAO;GAChD,IAAI,QAAQ,KAAA,GACV,MAAM,IAAI,MAAM,aAAa,GAAG,CAAC;EAErC,CAAC;CACH;AACF,CAAC;;;;;;;;ACjDH,IAAA,cAAe,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
2
3
|
"name": "@comment-labs/opencode-hidden-guard",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"description": "opencode plugin: blocks agent reads of hidden (dot) files (.env, .ssh, tokens) at the tool and bash layers.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "CommEnt Team",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.mjs",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/"
|
|
12
|
+
],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"import": "./dist/index.mjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@opencode/plugin": "2.0.16",
|
|
21
|
+
"unbash": "4.0.11"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@comment-labs/oxlint-config": "1.0.4",
|
|
25
|
+
"@comment-labs/tsconfig": "1.0.0-beta.8",
|
|
26
|
+
"@types/node": "25.9.5",
|
|
27
|
+
"oxlint": "1.83.0",
|
|
28
|
+
"oxlint-tsgolint": "7.0.2002",
|
|
29
|
+
"tsdown": "0.23.1",
|
|
30
|
+
"typescript": "npm:typescript-native-bridge@6.0.3-bridge.12.tsgo.7.0.2",
|
|
31
|
+
"vitest": "4.1.11"
|
|
32
|
+
},
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsdown",
|
|
38
|
+
"lint": "oxlint",
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"typecheck": "tsc"
|
|
41
|
+
}
|
|
6
42
|
}
|