@shieldaai/agent-map 0.1.0-alpha.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +653 -268
- package/dist/assets.js +16 -26
- package/dist/boundary-flags.d.ts +73 -0
- package/dist/boundary-flags.js +352 -0
- package/dist/boundary.d.ts +19 -2
- package/dist/boundary.js +75 -19
- package/dist/cli-entry.d.ts +13 -0
- package/dist/cli-entry.js +66 -0
- package/dist/cli.js +41 -44
- package/dist/common.d.ts +34 -0
- package/dist/common.js +94 -0
- package/dist/http.js +78 -51
- package/dist/identity-cli.js +94 -47
- package/dist/identity-http.js +226 -94
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/mcp.js +40 -5
- package/dist/oidc.d.ts +5 -0
- package/dist/oidc.js +121 -38
- package/dist/policy-reader.d.ts +56 -3
- package/dist/policy-reader.js +823 -110
- package/dist/projection-fields.d.ts +4 -0
- package/dist/projection-fields.js +144 -0
- package/dist/service/changes.d.ts +5 -0
- package/dist/service/changes.js +255 -0
- package/dist/service/context.d.ts +33 -0
- package/dist/service/context.js +2 -0
- package/dist/service/discovery.d.ts +6 -0
- package/dist/service/discovery.js +31 -0
- package/dist/service/explain.d.ts +12 -0
- package/dist/service/explain.js +126 -0
- package/dist/service/flags.d.ts +20 -0
- package/dist/service/flags.js +70 -0
- package/dist/service/inventory.d.ts +4 -0
- package/dist/service/inventory.js +62 -0
- package/dist/service/json.d.ts +8 -0
- package/dist/service/json.js +7 -0
- package/dist/service/operations/discovery.d.ts +5 -0
- package/dist/service/operations/discovery.js +90 -0
- package/dist/service/operations/explain-access.d.ts +3 -0
- package/dist/service/operations/explain-access.js +25 -0
- package/dist/service/operations/find-agents-with-access.d.ts +3 -0
- package/dist/service/operations/find-agents-with-access.js +120 -0
- package/dist/service/operations/get-agent-access.d.ts +3 -0
- package/dist/service/operations/get-agent-access.js +75 -0
- package/dist/service/operations/get-agent-inventory.d.ts +3 -0
- package/dist/service/operations/get-agent-inventory.js +42 -0
- package/dist/service/operations/get-changes.d.ts +3 -0
- package/dist/service/operations/get-changes.js +11 -0
- package/dist/service/operations/get-inventory-health.d.ts +3 -0
- package/dist/service/operations/get-inventory-health.js +81 -0
- package/dist/service/operations/get-resource-access.d.ts +3 -0
- package/dist/service/operations/get-resource-access.js +48 -0
- package/dist/service/operations/list-agents.d.ts +3 -0
- package/dist/service/operations/list-agents.js +92 -0
- package/dist/service/operations/list-owners-resources.d.ts +5 -0
- package/dist/service/operations/list-owners-resources.js +69 -0
- package/dist/service/ordering.d.ts +9 -0
- package/dist/service/ordering.js +47 -0
- package/dist/service/outside-guard.d.ts +68 -0
- package/dist/service/outside-guard.js +313 -0
- package/dist/service/policy.d.ts +26 -0
- package/dist/service/policy.js +299 -0
- package/dist/service/schemas.d.ts +16 -0
- package/dist/service/schemas.js +192 -0
- package/dist/service/summaries.d.ts +32 -0
- package/dist/service/summaries.js +247 -0
- package/dist/service/work.d.ts +33 -0
- package/dist/service/work.js +116 -0
- package/dist/service.d.ts +5 -5
- package/dist/service.js +110 -645
- package/dist/store/ancestors.d.ts +9 -0
- package/dist/store/ancestors.js +86 -0
- package/dist/store/discovery.d.ts +8 -0
- package/dist/store/discovery.js +288 -0
- package/dist/store/evidence.d.ts +12 -0
- package/dist/store/evidence.js +90 -0
- package/dist/store/identity-scope.d.ts +9 -0
- package/dist/store/identity-scope.js +71 -0
- package/dist/store/nodes.d.ts +24 -0
- package/dist/store/nodes.js +237 -0
- package/dist/store/projection.d.ts +19 -0
- package/dist/store/projection.js +242 -0
- package/dist/store/queries.d.ts +48 -0
- package/dist/store/queries.js +302 -0
- package/dist/store/read.d.ts +81 -0
- package/dist/store/read.js +135 -0
- package/dist/store/selection.d.ts +3 -0
- package/dist/store/selection.js +102 -0
- package/dist/store.d.ts +15 -0
- package/dist/store.js +102 -395
- package/dist/transport.d.ts +42 -2
- package/dist/transport.js +144 -16
- package/dist/types.d.ts +184 -4
- package/dist/types.js +52 -11
- package/package.json +32 -5
package/dist/identity-cli.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { constants } from 'node:fs';
|
|
3
|
-
import { open } from 'node:fs/promises';
|
|
4
2
|
import { dirname, resolve } from 'node:path';
|
|
5
3
|
import { parseArgs } from 'node:util';
|
|
6
|
-
import {
|
|
4
|
+
import { PACKAGE_VERSION, STORE_LIMITS, isCliEntry, reportStartupFailure } from './cli-entry.js';
|
|
7
5
|
import { createNeo4jMapStore } from './store.js';
|
|
8
6
|
import { MapService } from './service.js';
|
|
9
7
|
import { startMapIdentityServer } from './identity-http.js';
|
|
10
|
-
import {
|
|
8
|
+
import { fail } from './common.js';
|
|
9
|
+
import { fields, parseRequest, readHostFile } from './boundary.js';
|
|
11
10
|
function environment(value) {
|
|
12
11
|
if (typeof value !== 'string' || !/^[A-Za-z_][A-Za-z0-9_]{0,127}$/.test(value))
|
|
13
12
|
fail('MAP_CONFIG_INVALID');
|
|
@@ -16,43 +15,66 @@ function environment(value) {
|
|
|
16
15
|
fail('MAP_CREDENTIAL_REQUIRED');
|
|
17
16
|
return secret;
|
|
18
17
|
}
|
|
19
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The company launcher holds a TLS key and names secrets, so its files are this user's own
|
|
20
|
+
* regular files, never a link, and private inputs exclude group and other access.
|
|
21
|
+
*/
|
|
20
22
|
async function boundedFile(path, maximum, privateFile) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
fail('MAP_CONFIG_INVALID');
|
|
29
|
-
const data = Buffer.alloc(maximum + 1);
|
|
30
|
-
let bytes = 0;
|
|
31
|
-
while (bytes < data.length) {
|
|
32
|
-
const read = await file.read(data, bytes, data.length - bytes, null);
|
|
33
|
-
if (!read.bytesRead)
|
|
34
|
-
break;
|
|
35
|
-
bytes += read.bytesRead;
|
|
36
|
-
}
|
|
37
|
-
if (bytes > maximum)
|
|
38
|
-
fail('MAP_CONFIG_INVALID');
|
|
39
|
-
return new TextDecoder('utf-8', { fatal: true }).decode(data.subarray(0, bytes));
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
await file.close();
|
|
43
|
-
}
|
|
23
|
+
const bytes = await readHostFile(path, maximum, {
|
|
24
|
+
noFollow: true,
|
|
25
|
+
owner: 'service',
|
|
26
|
+
singleLink: true,
|
|
27
|
+
private: privateFile,
|
|
28
|
+
});
|
|
29
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
44
30
|
}
|
|
45
31
|
export async function loadMapIdentityConfig(filename) {
|
|
46
32
|
const path = resolve(filename), directory = dirname(path);
|
|
47
|
-
const config = fields(parseRequest(Buffer.from(await boundedFile(path, 128 * 1024, true)), 128 * 1024), [
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
const config = fields(parseRequest(Buffer.from(await boundedFile(path, 128 * 1024, true)), 128 * 1024), [
|
|
34
|
+
'neo4j',
|
|
35
|
+
'publicOrigin',
|
|
36
|
+
'tls',
|
|
37
|
+
'oidc',
|
|
38
|
+
'companyId',
|
|
39
|
+
'bindings',
|
|
40
|
+
'listenHost',
|
|
41
|
+
'port',
|
|
42
|
+
'viewerDirectory',
|
|
43
|
+
'sessionTtlMs',
|
|
44
|
+
'loginTtlMs',
|
|
45
|
+
'maxSessions',
|
|
46
|
+
'maxLoginTransactions',
|
|
47
|
+
'requestTimeoutMs',
|
|
48
|
+
'maxRequestBytes',
|
|
49
|
+
'maxResponseBytes',
|
|
50
|
+
'maxConcurrentRequests',
|
|
51
|
+
'rateLimit',
|
|
52
|
+
], ['neo4j', 'publicOrigin', 'tls', 'oidc', 'companyId', 'bindings']);
|
|
53
|
+
const db = fields(config.neo4j, ['uri', 'username', 'passwordEnv', 'database', ...STORE_LIMITS], ['uri', 'username', 'passwordEnv']);
|
|
54
|
+
if (typeof db.uri !== 'string' ||
|
|
55
|
+
typeof db.username !== 'string' ||
|
|
56
|
+
(db.database !== undefined && typeof db.database !== 'string'))
|
|
52
57
|
fail('MAP_CONFIG_INVALID');
|
|
53
|
-
const database = {
|
|
58
|
+
const database = {
|
|
59
|
+
uri: db.uri,
|
|
60
|
+
username: db.username,
|
|
61
|
+
password: environment(db.passwordEnv),
|
|
62
|
+
...(db.database === undefined ? {} : { database: db.database }),
|
|
63
|
+
// Optional read limits; the store checks their type and hard maximum.
|
|
64
|
+
...Object.fromEntries(STORE_LIMITS.filter(key => db[key] !== undefined).map(key => [key, db[key]])),
|
|
65
|
+
};
|
|
54
66
|
const tls = fields(config.tls, ['keyFile', 'certFile'], ['keyFile', 'certFile']);
|
|
55
|
-
const oidc = fields(config.oidc, [
|
|
67
|
+
const oidc = fields(config.oidc, [
|
|
68
|
+
'issuer',
|
|
69
|
+
'clientId',
|
|
70
|
+
'clientSecretEnv',
|
|
71
|
+
'clientAuthMethod',
|
|
72
|
+
'endpointOrigins',
|
|
73
|
+
'caFile',
|
|
74
|
+
'requestTimeoutMs',
|
|
75
|
+
'maxResponseBytes',
|
|
76
|
+
'clockToleranceSeconds',
|
|
77
|
+
], ['issuer', 'clientId', 'clientSecretEnv']);
|
|
56
78
|
for (const value of [tls.keyFile, tls.certFile])
|
|
57
79
|
if (typeof value !== 'string' || !value)
|
|
58
80
|
fail('MAP_CONFIG_INVALID');
|
|
@@ -62,22 +84,43 @@ export async function loadMapIdentityConfig(filename) {
|
|
|
62
84
|
fail('MAP_CONFIG_INVALID');
|
|
63
85
|
const { neo4j: _database, tls: _tls, oidc: _oidc, ...server } = config;
|
|
64
86
|
const { clientSecretEnv: _secret, caFile: _ca, ...provider } = oidc;
|
|
65
|
-
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
87
|
+
return {
|
|
88
|
+
database,
|
|
89
|
+
server: {
|
|
90
|
+
...server,
|
|
91
|
+
tls: {
|
|
92
|
+
key: await boundedFile(resolve(directory, tls.keyFile), 256 * 1024, true),
|
|
93
|
+
cert: await boundedFile(resolve(directory, tls.certFile), 256 * 1024, false),
|
|
94
|
+
},
|
|
95
|
+
oidc: {
|
|
96
|
+
...provider,
|
|
97
|
+
clientSecret: environment(oidc.clientSecretEnv),
|
|
98
|
+
...(oidc.caFile === undefined
|
|
99
|
+
? {}
|
|
100
|
+
: { ca: await boundedFile(resolve(directory, oidc.caFile), 256 * 1024, false) }),
|
|
101
|
+
},
|
|
102
|
+
...(config.viewerDirectory === undefined ? {} : { viewerDirectory: resolve(directory, config.viewerDirectory) }),
|
|
103
|
+
},
|
|
104
|
+
};
|
|
71
105
|
}
|
|
106
|
+
const USAGE = 'agent-guard-map-identity --config PRIVATE_HOST_CONFIG.json | --help | --version';
|
|
72
107
|
/** Restart reloads policy/secrets and invalidates sessions; credentials are never printed. */
|
|
73
108
|
export async function runMapIdentityCli(argv = process.argv.slice(2)) {
|
|
74
|
-
const { values } = parseArgs({
|
|
109
|
+
const { values } = parseArgs({
|
|
110
|
+
args: argv,
|
|
111
|
+
options: { config: { type: 'string' }, help: { type: 'boolean' }, version: { type: 'boolean' } },
|
|
112
|
+
strict: true,
|
|
113
|
+
});
|
|
75
114
|
if (values.help) {
|
|
76
|
-
process.stdout.write(
|
|
115
|
+
process.stdout.write(`${USAGE}\n`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (values.version) {
|
|
119
|
+
process.stdout.write(`${PACKAGE_VERSION}\n`);
|
|
77
120
|
return;
|
|
78
121
|
}
|
|
79
122
|
if (!values.config)
|
|
80
|
-
fail('
|
|
123
|
+
fail('MAP_ARGUMENT_INVALID');
|
|
81
124
|
const config = await loadMapIdentityConfig(values.config);
|
|
82
125
|
const store = createNeo4jMapStore(config.database);
|
|
83
126
|
try {
|
|
@@ -85,7 +128,11 @@ export async function runMapIdentityCli(argv = process.argv.slice(2)) {
|
|
|
85
128
|
try {
|
|
86
129
|
process.stdout.write(`${JSON.stringify({ url: server.url, mode: 'oidc-read-only' })}\n`);
|
|
87
130
|
await new Promise(done => {
|
|
88
|
-
const stop = () => {
|
|
131
|
+
const stop = () => {
|
|
132
|
+
process.off('SIGINT', stop);
|
|
133
|
+
process.off('SIGTERM', stop);
|
|
134
|
+
done();
|
|
135
|
+
};
|
|
89
136
|
process.once('SIGINT', stop);
|
|
90
137
|
process.once('SIGTERM', stop);
|
|
91
138
|
});
|
|
@@ -98,6 +145,6 @@ export async function runMapIdentityCli(argv = process.argv.slice(2)) {
|
|
|
98
145
|
await store.close();
|
|
99
146
|
}
|
|
100
147
|
}
|
|
101
|
-
if (
|
|
102
|
-
void runMapIdentityCli().catch(
|
|
148
|
+
if (isCliEntry(import.meta)) {
|
|
149
|
+
void runMapIdentityCli().catch(error => reportStartupFailure(error, USAGE));
|
|
103
150
|
}
|