@glassbox-ai/engine 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.
Files changed (101) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +33 -2
  3. package/dist/action/acc.d.ts +48 -0
  4. package/dist/action/acc.js +117 -0
  5. package/dist/action/builtin-tools.d.ts +5 -0
  6. package/dist/action/builtin-tools.js +74 -0
  7. package/dist/action/inline.d.ts +14 -0
  8. package/dist/action/inline.js +54 -0
  9. package/dist/action/paths.d.ts +71 -0
  10. package/dist/action/paths.js +398 -0
  11. package/dist/action/powershell.d.ts +9 -0
  12. package/dist/action/powershell.js +848 -0
  13. package/dist/action/protected-write.d.ts +11 -0
  14. package/dist/action/protected-write.js +113 -0
  15. package/dist/action/schedule.d.ts +43 -0
  16. package/dist/action/schedule.js +213 -0
  17. package/dist/action/shell/analyze.d.ts +28 -0
  18. package/dist/action/shell/analyze.js +2057 -0
  19. package/dist/action/shell/parse.d.ts +74 -0
  20. package/dist/action/shell/parse.js +1037 -0
  21. package/dist/action/shell/view.d.ts +6 -0
  22. package/dist/action/shell/view.js +89 -0
  23. package/dist/action/sql.d.ts +3 -0
  24. package/dist/action/sql.js +259 -0
  25. package/dist/action/tools.d.ts +20 -0
  26. package/dist/action/tools.js +305 -0
  27. package/dist/action/upload.d.ts +17 -0
  28. package/dist/action/upload.js +72 -0
  29. package/dist/analysis/fields.d.ts +14 -0
  30. package/dist/analysis/fields.js +136 -0
  31. package/dist/analysis/findings.d.ts +25 -0
  32. package/dist/analysis/findings.js +82 -0
  33. package/dist/analysis/gate.d.ts +16 -0
  34. package/dist/analysis/gate.js +662 -0
  35. package/dist/analysis/manifest.d.ts +3 -0
  36. package/dist/analysis/manifest.js +369 -0
  37. package/dist/analysis/match.d.ts +54 -0
  38. package/dist/analysis/match.js +352 -0
  39. package/dist/analysis/scan.d.ts +17 -0
  40. package/dist/analysis/scan.js +97 -0
  41. package/dist/canon/confusables.generated.d.ts +3 -0
  42. package/dist/canon/confusables.generated.js +6 -0
  43. package/dist/canon/decode.d.ts +11 -0
  44. package/dist/canon/decode.js +147 -0
  45. package/dist/canon/views.d.ts +36 -0
  46. package/dist/canon/views.js +283 -0
  47. package/dist/evidence/evidence.d.ts +12 -0
  48. package/dist/evidence/evidence.js +149 -0
  49. package/dist/fingerprint/diff.d.ts +3 -0
  50. package/dist/fingerprint/diff.js +273 -0
  51. package/dist/fingerprint/fingerprint.d.ts +4 -0
  52. package/dist/fingerprint/fingerprint.js +77 -0
  53. package/dist/grade/score.d.ts +19 -0
  54. package/dist/grade/score.js +89 -0
  55. package/dist/index.d.ts +26 -0
  56. package/dist/index.js +152 -0
  57. package/dist/intake/json.d.ts +17 -0
  58. package/dist/intake/json.js +284 -0
  59. package/dist/intake/snapshot.d.ts +14 -0
  60. package/dist/intake/snapshot.js +130 -0
  61. package/dist/limits.d.ts +4 -0
  62. package/dist/limits.js +30 -0
  63. package/dist/policy/decide.d.ts +32 -0
  64. package/dist/policy/decide.js +105 -0
  65. package/dist/rules/ids.d.ts +2 -0
  66. package/dist/rules/ids.js +99 -0
  67. package/dist/ruleset/baseline-tests.generated.d.ts +6 -0
  68. package/dist/ruleset/baseline-tests.generated.js +2935 -0
  69. package/dist/ruleset/baseline.d.ts +3 -0
  70. package/dist/ruleset/baseline.generated.d.ts +3 -0
  71. package/dist/ruleset/baseline.generated.js +5 -0
  72. package/dist/ruleset/baseline.js +44 -0
  73. package/dist/ruleset/fakes.d.ts +3 -0
  74. package/dist/ruleset/fakes.js +26 -0
  75. package/dist/ruleset/load.d.ts +13 -0
  76. package/dist/ruleset/load.js +187 -0
  77. package/dist/ruleset/schema.d.ts +120 -0
  78. package/dist/ruleset/schema.js +54 -0
  79. package/dist/ruleset/selftest.d.ts +18 -0
  80. package/dist/ruleset/selftest.js +42 -0
  81. package/dist/ruleset-entry.d.ts +5 -0
  82. package/dist/ruleset-entry.js +7 -0
  83. package/dist/secrets/detect.d.ts +17 -0
  84. package/dist/secrets/detect.js +236 -0
  85. package/dist/secrets/redact.d.ts +19 -0
  86. package/dist/secrets/redact.js +116 -0
  87. package/dist/types.d.ts +455 -0
  88. package/dist/types.js +10 -0
  89. package/dist/util/hash.d.ts +4 -0
  90. package/dist/util/hash.js +16 -0
  91. package/dist/util/initclock.d.ts +3 -0
  92. package/dist/util/initclock.js +17 -0
  93. package/dist/util/jcs.d.ts +4 -0
  94. package/dist/util/jcs.js +91 -0
  95. package/dist/util/misc.d.ts +17 -0
  96. package/dist/util/misc.js +77 -0
  97. package/dist/util/re.d.ts +14 -0
  98. package/dist/util/re.js +47 -0
  99. package/dist/version.d.ts +2 -0
  100. package/dist/version.js +2 -0
  101. package/package.json +57 -4
@@ -0,0 +1,77 @@
1
+ // Small shared helpers.
2
+ /** Deep-freeze plain data (iterative). */
3
+ export function deepFreeze(value) {
4
+ const stack = [value];
5
+ const seen = new Set();
6
+ while (stack.length > 0) {
7
+ const v = stack.pop();
8
+ if (v === null || typeof v !== "object" || seen.has(v))
9
+ continue;
10
+ seen.add(v);
11
+ Object.freeze(v);
12
+ for (const k of Object.keys(v))
13
+ stack.push(v[k]);
14
+ }
15
+ return value;
16
+ }
17
+ /**
18
+ * Removes trailing characters in `chars`. Linear time: a regex like /[. ]+$/ backtracks
19
+ * quadratically in V8 on a long run that isn't at the end (a 120 KB path took 27 s).
20
+ */
21
+ export function trimEndChars(s, chars) {
22
+ let e = s.length;
23
+ while (e > 0 && chars.includes(s[e - 1]))
24
+ e--;
25
+ return e === s.length ? s : s.slice(0, e);
26
+ }
27
+ export function isRecord(v) {
28
+ return v !== null && typeof v === "object" && !Array.isArray(v);
29
+ }
30
+ /** Own data property read on a snapshot (null-prototype) object. */
31
+ export function get(v, key) {
32
+ if (!isRecord(v))
33
+ return undefined;
34
+ return Object.prototype.hasOwnProperty.call(v, key) ? v[key] : undefined;
35
+ }
36
+ export function getString(v, key) {
37
+ const x = get(v, key);
38
+ return typeof x === "string" ? x : undefined;
39
+ }
40
+ export function codePointLength(s) {
41
+ let n = 0;
42
+ for (let i = 0; i < s.length; i++) {
43
+ const c = s.charCodeAt(i);
44
+ if (c >= 0xd800 && c <= 0xdbff && i + 1 < s.length) {
45
+ const d = s.charCodeAt(i + 1);
46
+ if (d >= 0xdc00 && d <= 0xdfff)
47
+ i++;
48
+ }
49
+ n++;
50
+ }
51
+ return n;
52
+ }
53
+ /** RFC 6901 pointer segment escaping. */
54
+ export function ptrSeg(k) {
55
+ return String(k).replace(/~/g, "~0").replace(/\//g, "~1");
56
+ }
57
+ export function utf8Length(s) {
58
+ let n = 0;
59
+ for (let i = 0; i < s.length; i++) {
60
+ const c = s.charCodeAt(i);
61
+ if (c < 0x80)
62
+ n += 1;
63
+ else if (c < 0x800)
64
+ n += 2;
65
+ else if (c >= 0xd800 && c <= 0xdbff) {
66
+ n += 4;
67
+ i++;
68
+ }
69
+ else
70
+ n += 3;
71
+ }
72
+ return n;
73
+ }
74
+ export function uniq(xs) {
75
+ return [...new Set(xs)];
76
+ }
77
+ //# sourceMappingURL=misc.js.map
@@ -0,0 +1,14 @@
1
+ import { RE2JS } from "re2js";
2
+ type Compiled = ReturnType<typeof RE2JS.compile>;
3
+ export declare function compile(pattern: string, flags?: "i"): Compiled | null;
4
+ export interface ReMatch {
5
+ start: number;
6
+ end: number;
7
+ text: string;
8
+ groups: (string | null)[];
9
+ }
10
+ export declare function findAll(pattern: string, text: string, flags?: "i", max?: number): ReMatch[];
11
+ export declare function test(pattern: string, text: string, flags?: "i"): boolean;
12
+ export declare function isValidPattern(pattern: string): boolean;
13
+ export {};
14
+ //# sourceMappingURL=re.d.ts.map
@@ -0,0 +1,47 @@
1
+ // Linear-time regex: 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
@@ -0,0 +1,2 @@
1
+ export declare const ENGINE_VERSION = "0.1.1";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const ENGINE_VERSION = "0.1.1";
2
+ //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,59 @@
1
1
  {
2
2
  "name": "@glassbox-ai/engine",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
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
+ "scripts": {
46
+ "build": "tsc -b",
47
+ "test": "vitest run",
48
+ "prepublishOnly": "tsc -b"
49
+ },
50
+ "dependencies": {
51
+ "@noble/curves": "2.4.0",
52
+ "@noble/hashes": "2.4.0",
53
+ "re2js": "2.9.1",
54
+ "valibot": "1.5.0"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ }
59
+ }