@glassbox-ai/engine 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/README.md +31 -2
- package/dist/action/acc.d.ts +48 -0
- package/dist/action/acc.js +117 -0
- package/dist/action/inline.d.ts +14 -0
- package/dist/action/inline.js +54 -0
- package/dist/action/paths.d.ts +71 -0
- package/dist/action/paths.js +398 -0
- package/dist/action/powershell.d.ts +9 -0
- package/dist/action/powershell.js +848 -0
- package/dist/action/protected-write.d.ts +11 -0
- package/dist/action/protected-write.js +113 -0
- package/dist/action/schedule.d.ts +43 -0
- package/dist/action/schedule.js +213 -0
- package/dist/action/shell/analyze.d.ts +28 -0
- package/dist/action/shell/analyze.js +2030 -0
- package/dist/action/shell/parse.d.ts +74 -0
- package/dist/action/shell/parse.js +1037 -0
- package/dist/action/shell/view.d.ts +6 -0
- package/dist/action/shell/view.js +89 -0
- package/dist/action/sql.d.ts +3 -0
- package/dist/action/sql.js +259 -0
- package/dist/action/tools.d.ts +20 -0
- package/dist/action/tools.js +240 -0
- package/dist/action/upload.d.ts +17 -0
- package/dist/action/upload.js +72 -0
- package/dist/analysis/fields.d.ts +14 -0
- package/dist/analysis/fields.js +136 -0
- package/dist/analysis/findings.d.ts +25 -0
- package/dist/analysis/findings.js +82 -0
- package/dist/analysis/gate.d.ts +16 -0
- package/dist/analysis/gate.js +660 -0
- package/dist/analysis/manifest.d.ts +3 -0
- package/dist/analysis/manifest.js +369 -0
- package/dist/analysis/match.d.ts +54 -0
- package/dist/analysis/match.js +352 -0
- package/dist/analysis/scan.d.ts +17 -0
- package/dist/analysis/scan.js +97 -0
- package/dist/canon/confusables.generated.d.ts +3 -0
- package/dist/canon/confusables.generated.js +6 -0
- package/dist/canon/decode.d.ts +11 -0
- package/dist/canon/decode.js +147 -0
- package/dist/canon/views.d.ts +36 -0
- package/dist/canon/views.js +283 -0
- package/dist/evidence/evidence.d.ts +12 -0
- package/dist/evidence/evidence.js +149 -0
- package/dist/fingerprint/diff.d.ts +3 -0
- package/dist/fingerprint/diff.js +273 -0
- package/dist/fingerprint/fingerprint.d.ts +4 -0
- package/dist/fingerprint/fingerprint.js +77 -0
- package/dist/grade/score.d.ts +19 -0
- package/dist/grade/score.js +89 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +148 -0
- package/dist/intake/json.d.ts +17 -0
- package/dist/intake/json.js +284 -0
- package/dist/intake/snapshot.d.ts +14 -0
- package/dist/intake/snapshot.js +130 -0
- package/dist/limits.d.ts +4 -0
- package/dist/limits.js +30 -0
- package/dist/policy/decide.d.ts +26 -0
- package/dist/policy/decide.js +74 -0
- package/dist/rules/ids.d.ts +2 -0
- package/dist/rules/ids.js +99 -0
- package/dist/ruleset/baseline-tests.generated.d.ts +6 -0
- package/dist/ruleset/baseline-tests.generated.js +2935 -0
- package/dist/ruleset/baseline.d.ts +3 -0
- package/dist/ruleset/baseline.generated.d.ts +3 -0
- package/dist/ruleset/baseline.generated.js +5 -0
- package/dist/ruleset/baseline.js +44 -0
- package/dist/ruleset/fakes.d.ts +3 -0
- package/dist/ruleset/fakes.js +26 -0
- package/dist/ruleset/load.d.ts +14 -0
- package/dist/ruleset/load.js +173 -0
- package/dist/ruleset/schema.d.ts +120 -0
- package/dist/ruleset/schema.js +54 -0
- package/dist/ruleset/selftest.d.ts +18 -0
- package/dist/ruleset/selftest.js +42 -0
- package/dist/ruleset-entry.d.ts +5 -0
- package/dist/ruleset-entry.js +7 -0
- package/dist/secrets/detect.d.ts +17 -0
- package/dist/secrets/detect.js +236 -0
- package/dist/secrets/redact.d.ts +19 -0
- package/dist/secrets/redact.js +116 -0
- package/dist/types.d.ts +434 -0
- package/dist/types.js +10 -0
- package/dist/util/hash.d.ts +4 -0
- package/dist/util/hash.js +16 -0
- package/dist/util/initclock.d.ts +3 -0
- package/dist/util/initclock.js +17 -0
- package/dist/util/jcs.d.ts +4 -0
- package/dist/util/jcs.js +91 -0
- package/dist/util/misc.d.ts +17 -0
- package/dist/util/misc.js +77 -0
- package/dist/util/re.d.ts +14 -0
- package/dist/util/re.js +47 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +55 -3
package/dist/util/re.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Linear-time regex (engine-spec §10.3): every pattern applied to untrusted text goes
|
|
2
|
+
// through re2js. Compiled patterns are cached per pattern string (bounded cache).
|
|
3
|
+
import { RE2JS } from "re2js";
|
|
4
|
+
import { initTimed } from "./initclock.js";
|
|
5
|
+
const cache = new Map();
|
|
6
|
+
export function compile(pattern, flags) {
|
|
7
|
+
const key = (flags ?? "") + "\u0000" + pattern;
|
|
8
|
+
if (cache.has(key))
|
|
9
|
+
return cache.get(key) ?? null;
|
|
10
|
+
let c;
|
|
11
|
+
try {
|
|
12
|
+
c = initTimed(() => RE2JS.compile(flags === "i" ? `(?i)${pattern}` : pattern));
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
c = null;
|
|
16
|
+
}
|
|
17
|
+
if (cache.size > 2000)
|
|
18
|
+
cache.clear();
|
|
19
|
+
cache.set(key, c);
|
|
20
|
+
return c;
|
|
21
|
+
}
|
|
22
|
+
export function findAll(pattern, text, flags, max = 200) {
|
|
23
|
+
const re = compile(pattern, flags);
|
|
24
|
+
if (!re)
|
|
25
|
+
return [];
|
|
26
|
+
const m = re.matcher(text);
|
|
27
|
+
const out = [];
|
|
28
|
+
while (out.length < max && m.find()) {
|
|
29
|
+
const groups = [];
|
|
30
|
+
for (let g = 1; g <= m.groupCount(); g++)
|
|
31
|
+
groups.push(m.group(g));
|
|
32
|
+
out.push({ start: m.start(), end: m.end(), text: m.group() ?? "", groups });
|
|
33
|
+
if (m.end() === m.start() && m.end() >= text.length)
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
export function test(pattern, text, flags) {
|
|
39
|
+
const re = compile(pattern, flags);
|
|
40
|
+
if (!re)
|
|
41
|
+
return false;
|
|
42
|
+
return re.matcher(text).find();
|
|
43
|
+
}
|
|
44
|
+
export function isValidPattern(pattern) {
|
|
45
|
+
return compile(pattern) !== null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=re.js.map
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,58 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glassbox-ai/engine",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Glassbox security engine: pure, deterministic analysis of MCP metadata and agent tool calls.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"ai-agent",
|
|
9
|
+
"security",
|
|
10
|
+
"prompt-injection",
|
|
11
|
+
"tool-poisoning",
|
|
12
|
+
"claude-code"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/Adithya6ramesh/Glassbox#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Adithya6ramesh/Glassbox/issues"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/Adithya6ramesh/Glassbox.git",
|
|
21
|
+
"directory": "packages/engine"
|
|
22
|
+
},
|
|
23
|
+
"license": "Apache-2.0",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./ruleset": {
|
|
32
|
+
"types": "./dist/ruleset-entry.d.ts",
|
|
33
|
+
"import": "./dist/ruleset-entry.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"!dist/**/*.map",
|
|
39
|
+
"!dist/**/*.tsbuildinfo",
|
|
40
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=24.11.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@noble/curves": "2.4.0",
|
|
47
|
+
"@noble/hashes": "2.4.0",
|
|
48
|
+
"re2js": "2.9.1",
|
|
49
|
+
"valibot": "1.5.0"
|
|
50
|
+
},
|
|
51
|
+
"publishConfig": {
|
|
52
|
+
"access": "public"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsc -b",
|
|
56
|
+
"test": "vitest run"
|
|
57
|
+
}
|
|
6
58
|
}
|