@imbue-ai/detent 1.0.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/README.md +246 -0
- package/dist/src/builtinPatterns/any.json +3 -0
- package/dist/src/builtinPatterns/builtinPatterns/any.json +3 -0
- package/dist/src/builtinPatterns.d.ts +5 -0
- package/dist/src/builtinPatterns.d.ts.map +1 -0
- package/dist/src/builtinPatterns.js +50 -0
- package/dist/src/builtinPatterns.js.map +1 -0
- package/dist/src/check.d.ts +2 -0
- package/dist/src/check.d.ts.map +1 -0
- package/dist/src/check.js +8 -0
- package/dist/src/check.js.map +1 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +64 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/config.d.ts +18 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +157 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/curl.d.ts +5 -0
- package/dist/src/curl.d.ts.map +1 -0
- package/dist/src/curl.js +394 -0
- package/dist/src/curl.js.map +1 -0
- package/dist/src/decomposedRequest.d.ts +24 -0
- package/dist/src/decomposedRequest.d.ts.map +1 -0
- package/dist/src/decomposedRequest.js +51 -0
- package/dist/src/decomposedRequest.js.map +1 -0
- package/dist/src/detentConfig.d.ts +15 -0
- package/dist/src/detentConfig.d.ts.map +1 -0
- package/dist/src/detentConfig.js +169 -0
- package/dist/src/detentConfig.js.map +1 -0
- package/dist/src/dump.d.ts +6 -0
- package/dist/src/dump.d.ts.map +1 -0
- package/dist/src/dump.js +14 -0
- package/dist/src/dump.js.map +1 -0
- package/dist/src/environment.d.ts +3 -0
- package/dist/src/environment.d.ts.map +1 -0
- package/dist/src/environment.js +15 -0
- package/dist/src/environment.js.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +7 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/patterns/builtin/any.json +3 -0
- package/dist/src/patterns/builtin/builtin/any.json +3 -0
- package/dist/src/patterns/builtin/builtin/aws.json +326 -0
- package/dist/src/patterns/builtin/builtin/calendly.json +274 -0
- package/dist/src/patterns/builtin/builtin/coolify.json +238 -0
- package/dist/src/patterns/builtin/builtin/discord.json +157 -0
- package/dist/src/patterns/builtin/builtin/dropbox.json +115 -0
- package/dist/src/patterns/builtin/builtin/figma.json +228 -0
- package/dist/src/patterns/builtin/builtin/github.json +248 -0
- package/dist/src/patterns/builtin/builtin/gitlab.json +262 -0
- package/dist/src/patterns/builtin/builtin/google-analytics.json +155 -0
- package/dist/src/patterns/builtin/builtin/google-calendar.json +227 -0
- package/dist/src/patterns/builtin/builtin/google-directions.json +67 -0
- package/dist/src/patterns/builtin/builtin/google-docs.json +102 -0
- package/dist/src/patterns/builtin/builtin/google-drive.json +162 -0
- package/dist/src/patterns/builtin/builtin/google-gmail.json +257 -0
- package/dist/src/patterns/builtin/builtin/google-people.json +142 -0
- package/dist/src/patterns/builtin/builtin/google-sheets.json +115 -0
- package/dist/src/patterns/builtin/builtin/linear.json +12 -0
- package/dist/src/patterns/builtin/builtin/mailchimp.json +263 -0
- package/dist/src/patterns/builtin/builtin/notion.json +230 -0
- package/dist/src/patterns/builtin/builtin/sentry.json +172 -0
- package/dist/src/patterns/builtin/builtin/slack.json +221 -0
- package/dist/src/patterns/builtin/builtin/stripe.json +347 -0
- package/dist/src/patterns/builtin/builtin/telegram.json +89 -0
- package/dist/src/patterns/builtin/builtin/umami.json +172 -0
- package/dist/src/patterns/builtin/builtin/yelp.json +147 -0
- package/dist/src/patterns/builtin/builtin/zoom.json +192 -0
- package/dist/src/patterns/requestPattern.d.ts +33 -0
- package/dist/src/patterns/requestPattern.d.ts.map +1 -0
- package/dist/src/patterns/requestPattern.js +157 -0
- package/dist/src/patterns/requestPattern.js.map +1 -0
- package/dist/src/requestPattern.d.ts +15 -0
- package/dist/src/requestPattern.d.ts.map +1 -0
- package/dist/src/requestPattern.js +35 -0
- package/dist/src/requestPattern.js.map +1 -0
- package/dist/tests/builtinPatterns.test.d.ts +2 -0
- package/dist/tests/builtinPatterns.test.d.ts.map +1 -0
- package/dist/tests/builtinPatterns.test.js +1293 -0
- package/dist/tests/builtinPatterns.test.js.map +1 -0
- package/dist/tests/check.test.d.ts +2 -0
- package/dist/tests/check.test.d.ts.map +1 -0
- package/dist/tests/check.test.js +671 -0
- package/dist/tests/check.test.js.map +1 -0
- package/dist/tests/cli.test.d.ts +2 -0
- package/dist/tests/cli.test.d.ts.map +1 -0
- package/dist/tests/cli.test.js +77 -0
- package/dist/tests/cli.test.js.map +1 -0
- package/dist/tests/codeQuality.test.d.ts +2 -0
- package/dist/tests/codeQuality.test.d.ts.map +1 -0
- package/dist/tests/codeQuality.test.js +15 -0
- package/dist/tests/codeQuality.test.js.map +1 -0
- package/dist/tests/curl.test.d.ts +2 -0
- package/dist/tests/curl.test.d.ts.map +1 -0
- package/dist/tests/curl.test.js +241 -0
- package/dist/tests/curl.test.js.map +1 -0
- package/dist/tests/dump.test.d.ts +2 -0
- package/dist/tests/dump.test.d.ts.map +1 -0
- package/dist/tests/dump.test.js +154 -0
- package/dist/tests/dump.test.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Detent
|
|
2
|
+
|
|
3
|
+
Fine-grained HTTP permissions for AI agents.
|
|
4
|
+
|
|
5
|
+
## Quick example
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Store rules.
|
|
9
|
+
echo '{
|
|
10
|
+
"rules": [
|
|
11
|
+
{"github-rest-api": ["github-read-all", "github-write-issues"]},
|
|
12
|
+
{"slack-api": ["slack-read-all"]}
|
|
13
|
+
]
|
|
14
|
+
}' > ~/.config/detent/config.json
|
|
15
|
+
|
|
16
|
+
# Check a request before sending.
|
|
17
|
+
# (Exit code: 0 = approved, 1 = rejected.)
|
|
18
|
+
detent curl -s https://api.github.com/repos/octocat/Hello-World/issues/1
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g detent
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
(This is not needed if you only intend to use Detent as a JavaScript library.)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Motivation
|
|
31
|
+
|
|
32
|
+
Users of AI agents sometimes give them access to services like
|
|
33
|
+
Slack, Google Drive, GitHub and others. Giving agents full
|
|
34
|
+
access is unnecessarily risky - the best practice in most cases
|
|
35
|
+
is giving only the necessary level of access. In practice, that
|
|
36
|
+
can be challenging, especially for services that do not offer
|
|
37
|
+
native granular permissions.
|
|
38
|
+
|
|
39
|
+
Detent is meant to address this. Users or developers can easily specify
|
|
40
|
+
permissions, from broad ones ("only read access to my Slack") to
|
|
41
|
+
more specific ones ("only read access to GitHub issues for this one repository").
|
|
42
|
+
|
|
43
|
+
## Integrations
|
|
44
|
+
|
|
45
|
+
Checking permissions is only useful if the results are
|
|
46
|
+
respected. To be effective, Detent needs to be integrated into
|
|
47
|
+
whatever tool the agent uses to access third-party services.
|
|
48
|
+
|
|
49
|
+
### Latchkey
|
|
50
|
+
|
|
51
|
+
[Latchkey](https://github.com/imbue-ai/latchkey) lets users
|
|
52
|
+
point to Detent configs in order to keep control over what
|
|
53
|
+
agents can and can't access. (This is currently a work in
|
|
54
|
+
progress.)
|
|
55
|
+
|
|
56
|
+
## Details and architecture
|
|
57
|
+
|
|
58
|
+
Detent is a command line tool and a Typescript library. It allows users and developers to:
|
|
59
|
+
|
|
60
|
+
1. Define named permissions for outgoing HTTP requests.
|
|
61
|
+
2. Check that a given request is allowed given the defined permissions.
|
|
62
|
+
|
|
63
|
+
### Usage
|
|
64
|
+
|
|
65
|
+
Store your permission setup in a config file as documented
|
|
66
|
+
below. Then assemble a `curl` invocation for an HTTP request and
|
|
67
|
+
prepend it with the `detent` command (`detent curl ...`) to
|
|
68
|
+
check whether it's allowed. Detent returns 0 if the request is
|
|
69
|
+
allowed based on the config, 1 if it's not allowed and 2 or
|
|
70
|
+
higher in case of errors. No requests are actually sent.
|
|
71
|
+
|
|
72
|
+
Alternatively, use `detent` as a library:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { check } from "detent";
|
|
76
|
+
|
|
77
|
+
const request = new Request("https://api.example.com/users", {
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json" },
|
|
80
|
+
body: JSON.stringify({ name: "alice" }),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const result = await check(request);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Configuration
|
|
87
|
+
|
|
88
|
+
All the configuration goes to `~/.config/detent/config.json` (or
|
|
89
|
+
`$XDG_CONFIG_HOME/detent/config.json` if `XDG_CONFIG_HOME` is set). Use the `DETENT_CONFIG`
|
|
90
|
+
environment variable to specify a different path.
|
|
91
|
+
|
|
92
|
+
### Matching requests
|
|
93
|
+
|
|
94
|
+
An HTTP(s) request can be represented as an object that has
|
|
95
|
+
several well-defined properties: `protocol`, `domain`, `port`,
|
|
96
|
+
`path`, `method`, `headers`, `queryParams` and `body`. Using this
|
|
97
|
+
representation, the `detent` tool uses [JSON schemas](https://json-schema.org/) to:
|
|
98
|
+
|
|
99
|
+
1. Match requests to permission checks.
|
|
100
|
+
2. Define the "acceptable" shape of a request that is subject to a permission check.
|
|
101
|
+
|
|
102
|
+
Some of the fields are normalized to canonical form before matching:
|
|
103
|
+
`method` is always uppercase (e.g. `"GET"`), `protocol`,
|
|
104
|
+
`domain` and `headers` keys are always lowercase (e.g. `"content-type"`).
|
|
105
|
+
|
|
106
|
+
#### Request patterns
|
|
107
|
+
|
|
108
|
+
A "request pattern" is a JSON Schema for matching and validating request objects. For example:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"properties": {
|
|
113
|
+
"method": { "const": "GET" }
|
|
114
|
+
},
|
|
115
|
+
"required": ["method"]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This would match all GET requests, regardless of the domain,
|
|
120
|
+
path, or anything else. Patterns must use normalized field
|
|
121
|
+
values (uppercase for methods etc.).
|
|
122
|
+
|
|
123
|
+
In the Detent config, patterns are actually specified with names,
|
|
124
|
+
like this:
|
|
125
|
+
|
|
126
|
+
```json
|
|
127
|
+
{
|
|
128
|
+
"patterns": {
|
|
129
|
+
"github-api": {
|
|
130
|
+
"properties": {
|
|
131
|
+
"domain": { "const": "api.github.com" }
|
|
132
|
+
},
|
|
133
|
+
"required": ["domain"]
|
|
134
|
+
},
|
|
135
|
+
"github-read-issues-detent": {
|
|
136
|
+
"properties": {
|
|
137
|
+
"method": { "const": "GET" },
|
|
138
|
+
"path": {
|
|
139
|
+
"type": "string",
|
|
140
|
+
"pattern": "^/repos/imbue-ai/detent/issues(/[0-9]+)?$"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"required": ["method", "path"]
|
|
144
|
+
},
|
|
145
|
+
...
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
### Permission rules
|
|
152
|
+
|
|
153
|
+
Once defined, request patterns can be combined in a two-level rules hierarchy, like this:
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"patterns": {...},
|
|
158
|
+
"rules": [
|
|
159
|
+
{"github-api": ["github-read-issues-detent", "github-write-comments-detent", ...] },
|
|
160
|
+
{"slack-api": ["slack-read-all"] }
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
In each rule, the key defines scope ("should a given request be
|
|
166
|
+
subject to this rule") and each value represents a list of permissions
|
|
167
|
+
allowed by this rule.
|
|
168
|
+
|
|
169
|
+
This is the meaning of the rules in the example above:
|
|
170
|
+
- When accessing the GitHub API, the only allowed actions are reading issues and writing comments in the Detent repository.
|
|
171
|
+
- When accessing the Slack API, only read actions are allowed.
|
|
172
|
+
- No other requests are allowed.
|
|
173
|
+
|
|
174
|
+
### Rule resolution, default outcomes
|
|
175
|
+
|
|
176
|
+
When a request gets checked, the rules in your config are simply
|
|
177
|
+
evaluated from top to bottom. The first rule whose scope matches
|
|
178
|
+
the request determines the outcome: if the request matches any
|
|
179
|
+
of the permissions in the rule, it's approved. Otherwise, it's
|
|
180
|
+
rejected. Further rules are not evaluated. By default, requests
|
|
181
|
+
that don't match any rule get rejected. If you want to allow
|
|
182
|
+
requests by default, append the `{"any": ["any"]}` rule to the
|
|
183
|
+
end of your rule list.
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
### Built-in permissions
|
|
187
|
+
|
|
188
|
+
Detent comes with a number of pattern definitions out of the box that
|
|
189
|
+
are automatically available and recognized in rule bodies:
|
|
190
|
+
|
|
191
|
+
- `any` (to match and allow any and all requests)
|
|
192
|
+
- `aws-s3` (to identify requests going to AWS S3)
|
|
193
|
+
- `aws-s3-read` (to allow read operations on AWS S3)
|
|
194
|
+
- `stripe-read-all` (to allow all read operations in Stripe API)
|
|
195
|
+
- `google-drive-write-comments` (to allow adding comments to Google Drive items)
|
|
196
|
+
- (... and many others)
|
|
197
|
+
|
|
198
|
+
Run `detent dump` to see your current config together with all the
|
|
199
|
+
existing built-in patterns. If you only want to list the pattern
|
|
200
|
+
names, run `detent dump | jq '.patterns | keys'`.
|
|
201
|
+
|
|
202
|
+
If you don't want to use the built-in patterns, set the
|
|
203
|
+
`DETENT_DO_NOT_USE_BUILTIN_PATTERNS` environment variable to
|
|
204
|
+
a non-empty value.
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
### Including other config files
|
|
208
|
+
|
|
209
|
+
Use the `include` key to split your configuration across
|
|
210
|
+
multiple files. Paths are resolved relative to the directory of
|
|
211
|
+
the config that contains the `include`.
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"include": ["shared/example.json", "shared/another_example.json"],
|
|
216
|
+
"rules": [
|
|
217
|
+
{"github-rest-api": ["github-read-issues"]}
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Included configs are merged recursively: patterns and rules from
|
|
223
|
+
all included files are collected first (in list order), then the
|
|
224
|
+
including config's own patterns and rules are applied on top.
|
|
225
|
+
This means the parent config's patterns override equally-named
|
|
226
|
+
included patterns, and its rules are evaluated after included
|
|
227
|
+
rules. Circular includes are detected and rejected.
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
## Contributing
|
|
231
|
+
|
|
232
|
+
Contributions of all kinds are welcome!
|
|
233
|
+
|
|
234
|
+
## Disclaimer
|
|
235
|
+
|
|
236
|
+
We're providing the preconfigured pattern definitions for
|
|
237
|
+
convenience, but it's likely that some of them may not work
|
|
238
|
+
entirely as intended. We hope that the community will help us refine the
|
|
239
|
+
built-in permission definitions over time. In the meantime,
|
|
240
|
+
preferably double-check built-in definitions before using them,
|
|
241
|
+
and when possible, use API tokens with reduced permission
|
|
242
|
+
scopes.
|
|
243
|
+
|
|
244
|
+
We still think the tool is useful in its current form as a protection
|
|
245
|
+
against accidental agent actions and the first line of defense
|
|
246
|
+
against malicious or compromised agents.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtinPatterns.d.ts","sourceRoot":"","sources":["../../src/builtinPatterns.ts"],"names":[],"mappings":"AAIA,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B;AAmDD,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CACvD,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
export class BuiltinPatternLoadError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'BuiltinPatternLoadError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function loadBuiltinPatterns() {
|
|
11
|
+
const currentDirectory = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const builtinPatternsDirectory = join(currentDirectory, 'builtinPatterns');
|
|
13
|
+
let entries;
|
|
14
|
+
try {
|
|
15
|
+
entries = readdirSync(builtinPatternsDirectory, { recursive: true, encoding: 'utf-8' });
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const jsonFiles = entries.filter((entry) => entry.endsWith('.json'));
|
|
21
|
+
const merged = {};
|
|
22
|
+
for (const jsonFile of jsonFiles) {
|
|
23
|
+
const filePath = join(builtinPatternsDirectory, jsonFile);
|
|
24
|
+
let content;
|
|
25
|
+
try {
|
|
26
|
+
content = readFileSync(filePath, 'utf-8');
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
30
|
+
throw new BuiltinPatternLoadError(`Failed to read builtin pattern file "${filePath}": ${message}`);
|
|
31
|
+
}
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = JSON.parse(content);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof SyntaxError) {
|
|
38
|
+
throw new BuiltinPatternLoadError(`Failed to parse builtin pattern file "${filePath}": ${error.message}`);
|
|
39
|
+
}
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
const patternsObject = parsed;
|
|
43
|
+
for (const [name, schema] of Object.entries(patternsObject)) {
|
|
44
|
+
merged[name] = schema;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return merged;
|
|
48
|
+
}
|
|
49
|
+
export const builtinPatterns = loadBuiltinPatterns();
|
|
50
|
+
//# sourceMappingURL=builtinPatterns.js.map
|
|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QAC5C,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,uBAAuB,CAC/B,wCAAwC,QAAQ,MAAM,OAAO,EAAE,CAChE,CAAC;QACJ,CAAC;QAED,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;gBACjC,MAAM,IAAI,uBAAuB,CAC/B,yCAAyC,QAAQ,MAAM,KAAK,CAAC,OAAO,EAAE,CACvE,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;QAED,MAAM,cAAc,GAAG,MAAiD,CAAC;QAEzE,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;YAC5D,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAC1B,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/check.ts"],"names":[],"mappings":"AAGA,wBAAsB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAInF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
import { resolveConfigPath, useBuiltinPatterns } from './environment.js';
|
|
3
|
+
export async function check(request, configPath) {
|
|
4
|
+
const resolvedPath = resolveConfigPath(configPath);
|
|
5
|
+
const config = new Config(resolvedPath, !useBuiltinPatterns());
|
|
6
|
+
return config.check(request);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,OAAgB,EAAE,UAAmB;IAC/D,MAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACnD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC/D,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/src/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { parseCurlArgs } from './curl.js';
|
|
5
|
+
import { check } from './check.js';
|
|
6
|
+
import { dump } from './dump.js';
|
|
7
|
+
import { resolveConfigPath } from './environment.js';
|
|
8
|
+
// Use createRequire instead of JSON import to avoid experimental warnings in some Node versions.
|
|
9
|
+
// The path is ../../ because this runs from dist/src/cli.js after compilation.
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
const packageJson = require('../../package.json');
|
|
12
|
+
const EXIT_CODE_ALLOWED = 0;
|
|
13
|
+
const EXIT_CODE_DENIED = 1;
|
|
14
|
+
const EXIT_CODE_ERROR = 2;
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
16
|
+
const configPathOverride = process.env['DETENT_CONFIG'];
|
|
17
|
+
const program = new Command();
|
|
18
|
+
const defaultConfigPath = resolveConfigPath();
|
|
19
|
+
program
|
|
20
|
+
.name('detent')
|
|
21
|
+
.description(`Check HTTP requests against permission rules. Returns 0 if allowed, 1 if denied, 2+ on error.`)
|
|
22
|
+
.version(packageJson.version)
|
|
23
|
+
.addHelpText('after', `
|
|
24
|
+
Environment variables:
|
|
25
|
+
DETENT_CONFIG Path to config file (default: ${defaultConfigPath})
|
|
26
|
+
DETENT_DO_NOT_USE_BUILTIN_PATTERNS When set to any non-empty value, disables built-in patterns`);
|
|
27
|
+
program
|
|
28
|
+
.command('curl')
|
|
29
|
+
.description('Check a curl-style HTTP request against permission rules')
|
|
30
|
+
.allowUnknownOption()
|
|
31
|
+
.allowExcessArguments()
|
|
32
|
+
.action(async (_options, command) => {
|
|
33
|
+
try {
|
|
34
|
+
const curlArgs = command.args;
|
|
35
|
+
const request = parseCurlArgs(curlArgs);
|
|
36
|
+
const allowed = await check(request, configPathOverride);
|
|
37
|
+
console.log(allowed ? 'approved' : 'rejected');
|
|
38
|
+
process.exitCode = allowed ? EXIT_CODE_ALLOWED : EXIT_CODE_DENIED;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
console.error(`Error: ${error.message}`);
|
|
43
|
+
}
|
|
44
|
+
process.exitCode = EXIT_CODE_ERROR;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
program
|
|
48
|
+
.command('dump')
|
|
49
|
+
.description('Print the effective config with all patterns (including built-in) as JSON')
|
|
50
|
+
.action(() => {
|
|
51
|
+
try {
|
|
52
|
+
const effectiveConfig = dump(configPathOverride);
|
|
53
|
+
console.log(JSON.stringify(effectiveConfig, null, 2));
|
|
54
|
+
process.exitCode = EXIT_CODE_ALLOWED;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
console.error(`Error: ${error.message}`);
|
|
59
|
+
}
|
|
60
|
+
process.exitCode = EXIT_CODE_ERROR;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
program.parse();
|
|
64
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,iGAAiG;AACjG,+EAA+E;AAC/E,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,OAAO,CAAC,oBAAoB,CAAwB,CAAC;AAEzE,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AAExD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,MAAM,iBAAiB,GAAG,iBAAiB,EAAE,CAAC;AAE9C,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CACV,+FAA+F,CAChG;KACA,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC;KAC5B,WAAW,CACV,OAAO,EACP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KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,QAAQ,GAAG,eAAe,CAAC;IACrC,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PatternRegistry } from './patterns/requestPattern.js';
|
|
2
|
+
export declare class ConfigError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export interface RawConfig {
|
|
6
|
+
readonly include?: readonly string[];
|
|
7
|
+
readonly patterns: Readonly<Record<string, Record<string, unknown>>>;
|
|
8
|
+
readonly rules: readonly Readonly<Record<string, readonly string[]>>[];
|
|
9
|
+
}
|
|
10
|
+
export declare function createPatternRegistry(rawConfig: RawConfig, doNotUseBuiltinPatterns: boolean): PatternRegistry;
|
|
11
|
+
export declare class Config {
|
|
12
|
+
private readonly rules;
|
|
13
|
+
constructor(configPath: string, doNotUseBuiltinPatterns: boolean);
|
|
14
|
+
check(request: Request): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export declare function readRawConfig(configPath: string): RawConfig;
|
|
17
|
+
export declare function validateRules(rawConfig: RawConfig, registry: PatternRegistry): void;
|
|
18
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,eAAe,EAEhB,MAAM,8BAA8B,CAAC;AAGtC,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACrE,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;CACxE;AAkCD,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,OAAO,GAC/B,eAAe,CAWjB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;gBAEpC,UAAU,EAAE,MAAM,EAAE,uBAAuB,EAAE,OAAO;IAM1D,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBhD;AAED,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAE3D;AAmFD,wBAAgB,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAEnF"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { Validator } from '@cfworker/json-schema';
|
|
4
|
+
import { RequestPatternError, PatternRegistry, getAllBuiltinSchemas, } from './patterns/requestPattern.js';
|
|
5
|
+
import { decomposeRequest } from './decomposedRequest.js';
|
|
6
|
+
export class ConfigError extends Error {
|
|
7
|
+
constructor(message) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'ConfigError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
const rawConfigSchema = {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
include: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: { type: 'string' },
|
|
18
|
+
},
|
|
19
|
+
patterns: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
additionalProperties: { type: 'object' },
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
type: 'array',
|
|
25
|
+
items: {
|
|
26
|
+
type: 'object',
|
|
27
|
+
additionalProperties: {
|
|
28
|
+
type: 'array',
|
|
29
|
+
items: { type: 'string' },
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
additionalProperties: false,
|
|
35
|
+
};
|
|
36
|
+
const rawConfigValidator = new Validator(rawConfigSchema, '2020-12', false);
|
|
37
|
+
export function createPatternRegistry(rawConfig, doNotUseBuiltinPatterns) {
|
|
38
|
+
const schemas = {};
|
|
39
|
+
if (!doNotUseBuiltinPatterns) {
|
|
40
|
+
Object.assign(schemas, getAllBuiltinSchemas());
|
|
41
|
+
}
|
|
42
|
+
// User patterns override builtins with the same name.
|
|
43
|
+
Object.assign(schemas, rawConfig.patterns);
|
|
44
|
+
return new PatternRegistry(schemas);
|
|
45
|
+
}
|
|
46
|
+
export class Config {
|
|
47
|
+
rules;
|
|
48
|
+
constructor(configPath, doNotUseBuiltinPatterns) {
|
|
49
|
+
const rawConfig = readRawConfig(configPath);
|
|
50
|
+
const registry = createPatternRegistry(rawConfig, doNotUseBuiltinPatterns);
|
|
51
|
+
this.rules = resolveRules(rawConfig, registry);
|
|
52
|
+
}
|
|
53
|
+
async check(request) {
|
|
54
|
+
const decomposedRequest = await decomposeRequest(request);
|
|
55
|
+
for (const rule of this.rules) {
|
|
56
|
+
if (rule.scope.match(decomposedRequest)) {
|
|
57
|
+
for (const permission of rule.permissions) {
|
|
58
|
+
if (permission.match(decomposedRequest)) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// No rule matched — reject by default
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function readRawConfig(configPath) {
|
|
70
|
+
return readRawConfigRecursive(configPath, []);
|
|
71
|
+
}
|
|
72
|
+
function readSingleRawConfig(configPath) {
|
|
73
|
+
if (!existsSync(configPath)) {
|
|
74
|
+
return { patterns: {}, rules: [] };
|
|
75
|
+
}
|
|
76
|
+
let content;
|
|
77
|
+
try {
|
|
78
|
+
content = readFileSync(configPath, 'utf-8');
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
82
|
+
throw new ConfigError(`Failed to read config file "${configPath}": ${message}`);
|
|
83
|
+
}
|
|
84
|
+
let parsed;
|
|
85
|
+
try {
|
|
86
|
+
parsed = JSON.parse(content);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
90
|
+
throw new ConfigError(`Failed to parse config file "${configPath}": ${message}`);
|
|
91
|
+
}
|
|
92
|
+
const validationResult = rawConfigValidator.validate(parsed);
|
|
93
|
+
if (!validationResult.valid) {
|
|
94
|
+
const errors = validationResult.errors
|
|
95
|
+
.map((error) => {
|
|
96
|
+
const path = error.instanceLocation || '#';
|
|
97
|
+
return `${path}: ${error.error}`;
|
|
98
|
+
})
|
|
99
|
+
.join('; ');
|
|
100
|
+
throw new ConfigError(`Invalid config file "${configPath}": ${errors}`);
|
|
101
|
+
}
|
|
102
|
+
const validated = parsed;
|
|
103
|
+
return {
|
|
104
|
+
include: validated.include,
|
|
105
|
+
patterns: validated.patterns ?? {},
|
|
106
|
+
rules: validated.rules ?? [],
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function readRawConfigRecursive(configPath, visitedPaths) {
|
|
110
|
+
const absolutePath = resolve(configPath);
|
|
111
|
+
if (visitedPaths.includes(absolutePath)) {
|
|
112
|
+
const cycle = [...visitedPaths, absolutePath].join(' -> ');
|
|
113
|
+
throw new ConfigError(`Circular include detected: ${cycle}`);
|
|
114
|
+
}
|
|
115
|
+
const currentConfig = readSingleRawConfig(absolutePath);
|
|
116
|
+
if (currentConfig.include === undefined || currentConfig.include.length === 0) {
|
|
117
|
+
return currentConfig;
|
|
118
|
+
}
|
|
119
|
+
const configDirectory = dirname(absolutePath);
|
|
120
|
+
const newVisitedPaths = [...visitedPaths, absolutePath];
|
|
121
|
+
let mergedPatterns = {};
|
|
122
|
+
let mergedRules = [];
|
|
123
|
+
for (const includePath of currentConfig.include) {
|
|
124
|
+
const resolvedIncludePath = resolve(configDirectory, includePath);
|
|
125
|
+
const includedConfig = readRawConfigRecursive(resolvedIncludePath, newVisitedPaths);
|
|
126
|
+
mergedPatterns = { ...mergedPatterns, ...includedConfig.patterns };
|
|
127
|
+
mergedRules = [...mergedRules, ...includedConfig.rules];
|
|
128
|
+
}
|
|
129
|
+
// The current config's own patterns override included ones;
|
|
130
|
+
// the current config's own rules are appended after included rules.
|
|
131
|
+
mergedPatterns = { ...mergedPatterns, ...currentConfig.patterns };
|
|
132
|
+
mergedRules = [...mergedRules, ...currentConfig.rules];
|
|
133
|
+
return { patterns: mergedPatterns, rules: mergedRules };
|
|
134
|
+
}
|
|
135
|
+
export function validateRules(rawConfig, registry) {
|
|
136
|
+
resolveRules(rawConfig, registry);
|
|
137
|
+
}
|
|
138
|
+
function resolveRules(rawConfig, registry) {
|
|
139
|
+
return rawConfig.rules.map((ruleObject, index) => {
|
|
140
|
+
const entries = Object.entries(ruleObject);
|
|
141
|
+
if (entries.length !== 1) {
|
|
142
|
+
throw new ConfigError(`Rule at index ${String(index)} must have exactly one key, got ${String(entries.length)}`);
|
|
143
|
+
}
|
|
144
|
+
const [scopeName, permissionNames] = entries[0];
|
|
145
|
+
const scope = resolvePattern(scopeName, registry, `scope of rule at index ${String(index)}`);
|
|
146
|
+
const permissions = permissionNames.map((permissionName) => resolvePattern(permissionName, registry, `permission "${permissionName}" in rule at index ${String(index)}`));
|
|
147
|
+
return { scope, permissions };
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function resolvePattern(name, registry, context) {
|
|
151
|
+
const pattern = registry.get(name);
|
|
152
|
+
if (pattern === undefined) {
|
|
153
|
+
throw new RequestPatternError(`Unknown pattern "${name}" used in ${context}`);
|
|
154
|
+
}
|
|
155
|
+
return pattern;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAEL,mBAAmB,EACnB,eAAe,EACf,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AAQD,MAAM,eAAe,GAAG;IACtB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,OAAO,EAAE;YACP,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SAC1B;QACD,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ;YACd,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzC;QACD,KAAK,EAAE;YACL,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE;oBACpB,IAAI,EAAE,OAAO;oBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBAC1B;aACF;SACF;KACF;IACD,oBAAoB,EAAE,KAAK;CACnB,CAAC;AAEX,MAAM,kBAAkB,GAAG,IAAI,SAAS,CAAC,eAAe,EAAE,SAAS,EAAE,KA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