@sonisoft/now-sdk-ext-core 6.0.0 → 6.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/README.md +46 -0
- package/dist/comm/http/HTTPRequest.d.ts +12 -0
- package/dist/comm/http/RequestHandler.d.ts +13 -0
- package/dist/comm/http/RequestHandler.js +47 -0
- package/dist/comm/http/RequestHandler.js.map +1 -1
- package/dist/comm/http/ServiceNowProcessorRequest.d.ts +8 -2
- package/dist/comm/http/ServiceNowProcessorRequest.js +9 -4
- package/dist/comm/http/ServiceNowProcessorRequest.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/policy/Policy.d.ts +40 -0
- package/dist/policy/Policy.js +161 -0
- package/dist/policy/Policy.js.map +1 -0
- package/dist/policy/PolicyEnv.d.ts +46 -0
- package/dist/policy/PolicyEnv.js +92 -0
- package/dist/policy/PolicyEnv.js.map +1 -0
- package/dist/policy/PolicyRefusal.d.ts +17 -0
- package/dist/policy/PolicyRefusal.js +69 -0
- package/dist/policy/PolicyRefusal.js.map +1 -0
- package/dist/policy/PolicyTypes.d.ts +65 -0
- package/dist/policy/PolicyTypes.js +15 -0
- package/dist/policy/PolicyTypes.js.map +1 -0
- package/dist/policy/ScanScript.d.ts +22 -0
- package/dist/policy/ScanScript.js +171 -0
- package/dist/policy/ScanScript.js.map +1 -0
- package/dist/policy/internal/Classify.d.ts +16 -0
- package/dist/policy/internal/Classify.js +121 -0
- package/dist/policy/internal/Classify.js.map +1 -0
- package/dist/sn/Application.js +18 -8
- package/dist/sn/Application.js.map +1 -1
- package/dist/sn/BackgroundScriptExecutor.d.ts +12 -0
- package/dist/sn/BackgroundScriptExecutor.js +60 -1
- package/dist/sn/BackgroundScriptExecutor.js.map +1 -1
- package/dist/sn/atf/ATFTestExecutor.js +3 -1
- package/dist/sn/atf/ATFTestExecutor.js.map +1 -1
- package/dist/sn/syslog/SyslogReader.js +6 -1
- package/dist/sn/syslog/SyslogReader.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -444,6 +444,52 @@ console.log('Return value:', result.result);
|
|
|
444
444
|
- **`CMDBRelationships`** - Query direct relationships and traverse CI graphs (BFS)
|
|
445
445
|
- **`InstanceDiscovery`** - List tables, scoped apps, store apps, and plugins
|
|
446
446
|
|
|
447
|
+
### Permission policy
|
|
448
|
+
|
|
449
|
+
Core can refuse operations that would change a ServiceNow instance. **It is inert until
|
|
450
|
+
an application installs a policy**, so importing this library changes nothing — the
|
|
451
|
+
`nex` CLI and the MCP server install one at startup because those are the surfaces an
|
|
452
|
+
AI agent drives.
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
import { installPolicy, denyLayer, grantLayer } from '@sonisoft/now-sdk-ext-core';
|
|
456
|
+
|
|
457
|
+
installPolicy([
|
|
458
|
+
denyLayer('lockdown', ['write']), // highest priority
|
|
459
|
+
grantLayer('default', ['write', 'execute']), // lowest
|
|
460
|
+
]);
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
Two verbs — `write` and `execute` — plus a `target` of `instance`, `local` or `session`.
|
|
464
|
+
Only `instance` is gated, so a tool that overwrites a local file is not refused as an
|
|
465
|
+
instance write. Layers are consulted in order and the first to answer `grant` or `deny`
|
|
466
|
+
decides; `abstain` passes the question down.
|
|
467
|
+
|
|
468
|
+
Reads are never gated.
|
|
469
|
+
|
|
470
|
+
> **This is a guardrail, not a security boundary.** Anything holding the credential can
|
|
471
|
+
> reach the instance directly — by calling the SDK, or with curl. What it buys is that
|
|
472
|
+
> inadvertent mutation stops being silent, and that an environment variable can deny in
|
|
473
|
+
> a way the calling code cannot override.
|
|
474
|
+
|
|
475
|
+
#### Script scanning, and what it cannot see
|
|
476
|
+
|
|
477
|
+
Background scripts are parsed to decide whether they need `write` on top of `execute`.
|
|
478
|
+
Anything unresolvable — computed member access like `gr['inse'+'rt']()`, `eval`, or a
|
|
479
|
+
parse failure — escalates to `write` rather than passing.
|
|
480
|
+
|
|
481
|
+
**A `write`-free result means "nothing obviously writes", not "this cannot write."**
|
|
482
|
+
These are invisible to any static scan:
|
|
483
|
+
|
|
484
|
+
- Script Includes — `new global.MyUtil().doThing()`, where the write is in another file
|
|
485
|
+
- `gs.eval(...)`
|
|
486
|
+
- `sn_ws.RESTMessageV2` calling out to anything
|
|
487
|
+
- `workflow.startFlow()`, `gs.getUser().setPreference()`
|
|
488
|
+
- a `GlideRecord` reached through a variable the scan never resolves
|
|
489
|
+
|
|
490
|
+
That is why `execute` is required regardless of what the scan concludes: permitting a
|
|
491
|
+
script to run at all is the real decision.
|
|
492
|
+
|
|
447
493
|
### Logging & Real-time Events
|
|
448
494
|
|
|
449
495
|
- **`SyslogReader`** - Log querying, formatting, export, and real-time tailing
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Requirement } from "../../policy/PolicyTypes.js";
|
|
1
2
|
export interface HTTPRequest {
|
|
2
3
|
path: string;
|
|
3
4
|
headers: object | null;
|
|
@@ -6,4 +7,15 @@ export interface HTTPRequest {
|
|
|
6
7
|
method?: string | null;
|
|
7
8
|
fields?: object | null;
|
|
8
9
|
json?: object | null;
|
|
10
|
+
/**
|
|
11
|
+
* What permission this request needs, when the HTTP verb would get it wrong.
|
|
12
|
+
*
|
|
13
|
+
* Leave unset almost always: GET is assumed to read, everything else to write, and
|
|
14
|
+
* that is right for all but two call sites in this library — `SyslogReader` POSTs
|
|
15
|
+
* to read, and `ATFTestExecutor` POSTs to run tests. Set it there.
|
|
16
|
+
*
|
|
17
|
+
* This can correct a wrong default but can never lower a floor rule; see
|
|
18
|
+
* `policy/internal/Classify.ts`.
|
|
19
|
+
*/
|
|
20
|
+
requires?: Requirement;
|
|
9
21
|
}
|
|
@@ -46,6 +46,19 @@ export declare class RequestHandler implements IRequestHandler {
|
|
|
46
46
|
* own.
|
|
47
47
|
*/
|
|
48
48
|
private toThrowable;
|
|
49
|
+
/**
|
|
50
|
+
* Refuses the request when policy does not permit what it would do.
|
|
51
|
+
*
|
|
52
|
+
* No-op until an application installs a policy, so embedding this library is
|
|
53
|
+
* unaffected. The `nex` CLI and the MCP server install a deny-by-default policy at
|
|
54
|
+
* startup, because those are the surfaces an agent drives.
|
|
55
|
+
*
|
|
56
|
+
* Allowed mutations are logged at info with the deciding layer. That log is the
|
|
57
|
+
* only thing that surfaces a missing floor rule — a mutating endpoint nobody
|
|
58
|
+
* classified shows up as a write that was permitted for the wrong reason — and it
|
|
59
|
+
* is what answers "why was this refused" when someone asks.
|
|
60
|
+
*/
|
|
61
|
+
private assertPermitted;
|
|
49
62
|
private assertSessionMatchesBoundInstance;
|
|
50
63
|
isValidXmlString(xmlString: any): boolean;
|
|
51
64
|
private doRequest;
|
|
@@ -4,6 +4,9 @@ import { makeRequest } from "@servicenow/sdk-cli-core/dist/http/index.js";
|
|
|
4
4
|
import { DOMParser } from '@xmldom/xmldom';
|
|
5
5
|
import { StaleInstanceError } from '../../exception/StaleInstanceError.js';
|
|
6
6
|
import { stripSecretsFromError, redactValue } from '../../util/redact.js';
|
|
7
|
+
import { checkRequirement } from '../../policy/Policy.js';
|
|
8
|
+
import { policyRefusal } from '../../policy/PolicyRefusal.js';
|
|
9
|
+
import { classify } from '../../policy/internal/Classify.js';
|
|
7
10
|
//axios.defaults.withCredentials = true;
|
|
8
11
|
export class RequestHandler {
|
|
9
12
|
_logger = new Logger("RequestHandler");
|
|
@@ -96,6 +99,45 @@ export class RequestHandler {
|
|
|
96
99
|
}
|
|
97
100
|
return new Error(described);
|
|
98
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Refuses the request when policy does not permit what it would do.
|
|
104
|
+
*
|
|
105
|
+
* No-op until an application installs a policy, so embedding this library is
|
|
106
|
+
* unaffected. The `nex` CLI and the MCP server install a deny-by-default policy at
|
|
107
|
+
* startup, because those are the surfaces an agent drives.
|
|
108
|
+
*
|
|
109
|
+
* Allowed mutations are logged at info with the deciding layer. That log is the
|
|
110
|
+
* only thing that surfaces a missing floor rule — a mutating endpoint nobody
|
|
111
|
+
* classified shows up as a write that was permitted for the wrong reason — and it
|
|
112
|
+
* is what answers "why was this refused" when someone asks.
|
|
113
|
+
*/
|
|
114
|
+
assertPermitted(request) {
|
|
115
|
+
const requirement = classify(request);
|
|
116
|
+
if (requirement.verbs.length === 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const decision = checkRequirement(requirement);
|
|
120
|
+
const path = typeof request.path === "string" ? request.path.split("?")[0] : "(unknown)";
|
|
121
|
+
if (!decision.allowed) {
|
|
122
|
+
this._logger.warn("Refused by policy", {
|
|
123
|
+
path,
|
|
124
|
+
method: request.method ?? "get",
|
|
125
|
+
verbs: decision.verbs,
|
|
126
|
+
decidingLayer: decision.decidingLayer,
|
|
127
|
+
floor: requirement.reasons,
|
|
128
|
+
});
|
|
129
|
+
throw policyRefusal(decision);
|
|
130
|
+
}
|
|
131
|
+
if (decision.decidingLayer !== "no-policy") {
|
|
132
|
+
this._logger.info("Permitted by policy", {
|
|
133
|
+
path,
|
|
134
|
+
method: request.method ?? "get",
|
|
135
|
+
verbs: decision.verbs,
|
|
136
|
+
grantedBy: decision.decidingLayer,
|
|
137
|
+
floor: requirement.reasons,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
}
|
|
99
141
|
assertSessionMatchesBoundInstance() {
|
|
100
142
|
const bound = this._boundInstanceId;
|
|
101
143
|
const forSession = this._sessionInstanceId;
|
|
@@ -301,6 +343,11 @@ export class RequestHandler {
|
|
|
301
343
|
// destination host from auth.instanceUrl, so a mismatch here does not send a
|
|
302
344
|
// bad cookie to the right host — it sends a valid session to the wrong one.
|
|
303
345
|
this.assertSessionMatchesBoundInstance();
|
|
346
|
+
// Same reasoning, same place: this is the one point every request passes
|
|
347
|
+
// through — both SessionManager-managed handlers and the ~21 managers that
|
|
348
|
+
// construct their own ServiceNowRequest. A second chokepoint elsewhere would
|
|
349
|
+
// only be a second thing to keep in sync.
|
|
350
|
+
this.assertPermitted(request);
|
|
304
351
|
const config = {
|
|
305
352
|
auth: this._session,
|
|
306
353
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/comm/http/RequestHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEvE,wCAAwC;AAExC,MAAM,OAAO,cAAc;IAEvB,OAAO,GAAU,IAAI,MAAM,CAAC,gBAAgB,CAAC,CAAC;IAC9C,yCAAyC;IACzC,2BAA2B;IAC3B,QAAQ,CAAW;IAEnB,YAAY,CAAc;IAC1B,YAAY,CAAwB;IAEpC,QAAQ,CAAM;IAEd,+EAA+E;IACvE,gBAAgB,CAAqB;IAE7C,gGAAgG;IACxF,kBAAkB,CAAqB;IAE/C;;;OAGG;IACH,YAAmB,WAAkC;QACjD,sDAAsD;QACvD,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAE/B,gDAAgD;QAChD,2DAA2D;QAC3D,oCAAoC;QACpC,mCAAmC;QACnC,6BAA6B;QAC7B,2EAA2E;QAC3E,QAAQ;QAER,6CAA6C;IAEhD,CAAC;IAIK,UAAU,CAAC,OAAY,EAAE,QAA8B;QAC1D,MAAM,QAAQ,GAAG,IAAI,CAAC,kBAAkB,CAAC;QACzC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,4EAA4E;QAC5E,6EAA6E;QAC7E,8DAA8D;QAC9D,IAAI,CAAC,kBAAkB,GAAG,QAAQ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EAAE,CAAC;QAGrC,KAAI,MAAM,IAAI,IAAI,QAAQ,EAAC,CAAC;YACxB,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;QAAA,CAAC;IAC9B,CAAC;CAKJ"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { IHttpResponse } from "./IHttpResponse.js";
|
|
2
2
|
import { ServiceNowInstance } from "../../sn/ServiceNowInstance.js";
|
|
3
|
+
import { Requirement } from "../../policy/PolicyTypes.js";
|
|
3
4
|
export declare class ServiceNowProcessorRequest {
|
|
4
5
|
private static _logger;
|
|
5
6
|
_instance: ServiceNowInstance;
|
|
6
7
|
constructor(instance: ServiceNowInstance);
|
|
7
8
|
private _headers;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param requires What this processor call needs. Defaults to `write`, because
|
|
11
|
+
* /xmlhttp.do is a POST and most processors mutate. Two callers legitimately differ
|
|
12
|
+
* and say so: SyslogReader reads, ATFTestExecutor executes.
|
|
13
|
+
*/
|
|
14
|
+
execute(processor: string, processorMethod: string, scope: string, processorArgs: object, requires?: Requirement): Promise<string>;
|
|
15
|
+
doXmlHttpRequest(processor: string, processorMethod: string, scope: string, processorArgs: object, requires?: Requirement): Promise<IHttpResponse<unknown>>;
|
|
10
16
|
}
|
|
@@ -12,9 +12,14 @@ export class ServiceNowProcessorRequest {
|
|
|
12
12
|
_headers = {
|
|
13
13
|
"Content-Type": "application/x-www-form-urlencoded"
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @param requires What this processor call needs. Defaults to `write`, because
|
|
17
|
+
* /xmlhttp.do is a POST and most processors mutate. Two callers legitimately differ
|
|
18
|
+
* and say so: SyslogReader reads, ATFTestExecutor executes.
|
|
19
|
+
*/
|
|
20
|
+
async execute(processor, processorMethod, scope, processorArgs, requires) {
|
|
16
21
|
let retVal = null;
|
|
17
|
-
let resp = await this.doXmlHttpRequest(processor, processorMethod, scope, processorArgs);
|
|
22
|
+
let resp = await this.doXmlHttpRequest(processor, processorMethod, scope, processorArgs, requires);
|
|
18
23
|
if (resp.status == 200) {
|
|
19
24
|
let data = resp.data;
|
|
20
25
|
if (typeof data != 'undefined' && data && data.indexOf('answer=') != -1) {
|
|
@@ -28,7 +33,7 @@ export class ServiceNowProcessorRequest {
|
|
|
28
33
|
}
|
|
29
34
|
return retVal;
|
|
30
35
|
}
|
|
31
|
-
async doXmlHttpRequest(processor, processorMethod, scope, processorArgs) {
|
|
36
|
+
async doXmlHttpRequest(processor, processorMethod, scope, processorArgs, requires) {
|
|
32
37
|
let resp = null;
|
|
33
38
|
try {
|
|
34
39
|
let dataObj = {};
|
|
@@ -40,7 +45,7 @@ export class ServiceNowProcessorRequest {
|
|
|
40
45
|
}
|
|
41
46
|
//let data = qs.stringify(dataObj);
|
|
42
47
|
let req = new ServiceNowRequest(this._instance);
|
|
43
|
-
let request = { method: 'POST', path: XMLHTTP_PROCESSOR_ENDPOINT, headers: this._headers, query: null, fields: dataObj, body: null };
|
|
48
|
+
let request = { method: 'POST', path: XMLHTTP_PROCESSOR_ENDPOINT, headers: this._headers, query: null, fields: dataObj, body: null, requires: requires };
|
|
44
49
|
resp = await req.post(request);
|
|
45
50
|
}
|
|
46
51
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceNowProcessorRequest.js","sourceRoot":"","sources":["../../../src/comm/http/ServiceNowProcessorRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"ServiceNowProcessorRequest.js","sourceRoot":"","sources":["../../../src/comm/http/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11 @@ export * from './exception/InvalidParameterException.js';
|
|
|
10
10
|
export * from './exception/PathException.js';
|
|
11
11
|
export * from './exception/StaleInstanceError.js';
|
|
12
12
|
export * from './model/types.js';
|
|
13
|
+
export * from './policy/Policy.js';
|
|
14
|
+
export * from './policy/PolicyEnv.js';
|
|
15
|
+
export * from './policy/PolicyRefusal.js';
|
|
16
|
+
export * from './policy/PolicyTypes.js';
|
|
17
|
+
export * from './policy/ScanScript.js';
|
|
13
18
|
export * from './sn/Application.js';
|
|
14
19
|
export * from './sn/BackgroundScriptExecutor.js';
|
|
15
20
|
export * from './sn/IServiceNowInstance.js';
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,11 @@ export * from './exception/InvalidParameterException.js';
|
|
|
10
10
|
export * from './exception/PathException.js';
|
|
11
11
|
export * from './exception/StaleInstanceError.js';
|
|
12
12
|
export * from './model/types.js';
|
|
13
|
+
export * from './policy/Policy.js';
|
|
14
|
+
export * from './policy/PolicyEnv.js';
|
|
15
|
+
export * from './policy/PolicyRefusal.js';
|
|
16
|
+
export * from './policy/PolicyTypes.js';
|
|
17
|
+
export * from './policy/ScanScript.js';
|
|
13
18
|
export * from './sn/Application.js';
|
|
14
19
|
export * from './sn/BackgroundScriptExecutor.js';
|
|
15
20
|
export * from './sn/IServiceNowInstance.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kBAAk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C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,0EAA0E;AAC1E,4EAA4E;AAC5E,gEAAgE;AAChE,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Decision, PolicyLayer, Requirement, Target, Verb } from "./PolicyTypes.js";
|
|
2
|
+
/** True once an application has installed a policy. Until then, everything is allowed. */
|
|
3
|
+
export declare function isPolicyInstalled(): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Installs the process policy. Call once, from the application that owns the entry
|
|
6
|
+
* point — never from a library.
|
|
7
|
+
*
|
|
8
|
+
* Layers are supplied in priority order (highest first).
|
|
9
|
+
*/
|
|
10
|
+
export declare function installPolicy(orderedLayers: readonly PolicyLayer[]): void;
|
|
11
|
+
/** Removes the policy, returning to the permissive default. Test seam. */
|
|
12
|
+
export declare function resetPolicyForTests(): void;
|
|
13
|
+
/** The layers currently installed, highest priority first. Diagnostics and `nex policy status`. */
|
|
14
|
+
export declare function currentLayers(): readonly PolicyLayer[];
|
|
15
|
+
/**
|
|
16
|
+
* Decides whether an operation may proceed.
|
|
17
|
+
*
|
|
18
|
+
* Only `target: "instance"` is gated. A local file write or a session-preference change
|
|
19
|
+
* is not what this exists to prevent, and refusing them would produce false refusals on
|
|
20
|
+
* operations that never touch instance data (`script-sync pull` being the clearest).
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkRequirement(requirement: Requirement): Decision;
|
|
23
|
+
export declare function setRemediationWriter(writer: (verbs: readonly Verb[], missing: Verb, layer: string) => string): void;
|
|
24
|
+
/**
|
|
25
|
+
* A layer that denies the listed verbs outright.
|
|
26
|
+
*
|
|
27
|
+
* Placed at the top of the ladder so nothing below can grant past it. This is the layer
|
|
28
|
+
* that makes pointing the tool at production meaningful.
|
|
29
|
+
*
|
|
30
|
+
* The guarantee has a precise limit, and the docs must state it: this only holds when
|
|
31
|
+
* the variable is set somewhere the agent cannot write — a shell profile, a systemd
|
|
32
|
+
* unit, a container environment. A project-local `.mcp.json` is a file in the workspace,
|
|
33
|
+
* and an agent with file-write access can edit it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function denyLayer(name: string, denied: readonly Verb[]): PolicyLayer;
|
|
36
|
+
/** A layer that grants the listed verbs and abstains on the rest. */
|
|
37
|
+
export declare function grantLayer(name: string, granted: readonly Verb[]): PolicyLayer;
|
|
38
|
+
/** Convenience for tests and for embedders that want the old unrestricted behaviour. */
|
|
39
|
+
export declare function allowAllLayer(): PolicyLayer;
|
|
40
|
+
export type { Decision, PolicyLayer, Requirement, Target, Verb };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-wide permission policy.
|
|
3
|
+
*
|
|
4
|
+
* INERT UNTIL CONFIGURED. With no policy installed every check allows, so importing
|
|
5
|
+
* this library changes nothing for existing consumers — `new TableAPIRequest(i).post()`
|
|
6
|
+
* behaves exactly as it did. The applications that are actually driven by agents (the
|
|
7
|
+
* `nex` CLI and the MCP server) install a policy in their entrypoints.
|
|
8
|
+
*
|
|
9
|
+
* That split is deliberate. The risk being managed is "an agent drives the CLI or the
|
|
10
|
+
* MCP server", not "a program imports this library"; gating here by default would break
|
|
11
|
+
* every embedder to mitigate a risk they do not have.
|
|
12
|
+
*
|
|
13
|
+
* Those applications currently install a ladder whose LAST layer grants both verbs, so
|
|
14
|
+
* changes are permitted unless something above revokes them — `NEX_POLICY_DENY`, or a
|
|
15
|
+
* CLI deny flag. Flipping to deny-by-default is deleting that trailing layer; nothing
|
|
16
|
+
* in this file assumes either direction.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Layers in priority order. The FIRST layer to answer anything other than `abstain`
|
|
20
|
+
* decides.
|
|
21
|
+
*
|
|
22
|
+
* Ordered layers rather than an escalating if-chain because not every source is a
|
|
23
|
+
* grant: `--read-only` (NEX-76) REVOKES, and an escalate-only model cannot express a
|
|
24
|
+
* source that lowers permission. Getting this shape right now is what lets NEX-76 add
|
|
25
|
+
* `ApprovalToken` and `--approve-all` later without a rewrite.
|
|
26
|
+
*
|
|
27
|
+
* Index 0 is the only layer an agent cannot reach — see `denyFromEnvironment`.
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_LAYER = "default";
|
|
30
|
+
let layers = [];
|
|
31
|
+
let installed = false;
|
|
32
|
+
/** True once an application has installed a policy. Until then, everything is allowed. */
|
|
33
|
+
export function isPolicyInstalled() {
|
|
34
|
+
return installed;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Installs the process policy. Call once, from the application that owns the entry
|
|
38
|
+
* point — never from a library.
|
|
39
|
+
*
|
|
40
|
+
* Layers are supplied in priority order (highest first).
|
|
41
|
+
*/
|
|
42
|
+
export function installPolicy(orderedLayers) {
|
|
43
|
+
layers = [...orderedLayers];
|
|
44
|
+
installed = true;
|
|
45
|
+
}
|
|
46
|
+
/** Removes the policy, returning to the permissive default. Test seam. */
|
|
47
|
+
export function resetPolicyForTests() {
|
|
48
|
+
layers = [];
|
|
49
|
+
installed = false;
|
|
50
|
+
}
|
|
51
|
+
/** The layers currently installed, highest priority first. Diagnostics and `nex policy status`. */
|
|
52
|
+
export function currentLayers() {
|
|
53
|
+
return layers;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Resolves a single verb against the ladder.
|
|
57
|
+
*
|
|
58
|
+
* Returns the deciding layer's name alongside the answer so refusals can say which one
|
|
59
|
+
* spoke. Without that, a precedence bug is invisible: the user sees "refused" and has
|
|
60
|
+
* no way to tell whether the environment denied it or nothing granted it.
|
|
61
|
+
*/
|
|
62
|
+
function resolveVerb(verb) {
|
|
63
|
+
for (const layer of layers) {
|
|
64
|
+
const answer = layer.answer(verb);
|
|
65
|
+
if (answer === "grant") {
|
|
66
|
+
return { granted: true, decidingLayer: layer.name };
|
|
67
|
+
}
|
|
68
|
+
if (answer === "deny") {
|
|
69
|
+
return { granted: false, decidingLayer: layer.name };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { granted: false, decidingLayer: DEFAULT_LAYER };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Decides whether an operation may proceed.
|
|
76
|
+
*
|
|
77
|
+
* Only `target: "instance"` is gated. A local file write or a session-preference change
|
|
78
|
+
* is not what this exists to prevent, and refusing them would produce false refusals on
|
|
79
|
+
* operations that never touch instance data (`script-sync pull` being the clearest).
|
|
80
|
+
*/
|
|
81
|
+
export function checkRequirement(requirement) {
|
|
82
|
+
if (!installed || requirement.verbs.length === 0 || requirement.target !== "instance") {
|
|
83
|
+
return {
|
|
84
|
+
allowed: true,
|
|
85
|
+
verbs: requirement.verbs,
|
|
86
|
+
decidingLayer: installed ? "not-gated" : "no-policy",
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
// Every required verb must be granted. A script needing execute AND write is not
|
|
90
|
+
// satisfied by execute alone.
|
|
91
|
+
for (const verb of requirement.verbs) {
|
|
92
|
+
const { granted, decidingLayer } = resolveVerb(verb);
|
|
93
|
+
if (!granted) {
|
|
94
|
+
return {
|
|
95
|
+
allowed: false,
|
|
96
|
+
verbs: requirement.verbs,
|
|
97
|
+
decidingLayer,
|
|
98
|
+
remediation: remediationFor(requirement.verbs, verb, decidingLayer),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Report EVERY layer that granted, not just the first verb's.
|
|
103
|
+
//
|
|
104
|
+
// A requirement like ["execute", "write"] can be satisfied by two different layers
|
|
105
|
+
// — execute from the environment, write from the default — and naming only the
|
|
106
|
+
// first makes the audit log quietly wrong about how a mutation was permitted. That
|
|
107
|
+
// log is the thing meant to surface a missing floor rule, so it has to be accurate.
|
|
108
|
+
const granting = [...new Set(requirement.verbs.map((v) => resolveVerb(v).decidingLayer))];
|
|
109
|
+
return {
|
|
110
|
+
allowed: true,
|
|
111
|
+
verbs: requirement.verbs,
|
|
112
|
+
decidingLayer: granting.join(" + "),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* How the application explains a refusal.
|
|
117
|
+
*
|
|
118
|
+
* Set by the CLI to name its flags. Left unset by the MCP server, whose caller is the
|
|
119
|
+
* model — naming the parameter there would advertise the escape hatch.
|
|
120
|
+
*/
|
|
121
|
+
let remediationWriter;
|
|
122
|
+
export function setRemediationWriter(writer) {
|
|
123
|
+
remediationWriter = writer;
|
|
124
|
+
}
|
|
125
|
+
function remediationFor(verbs, missing, layer) {
|
|
126
|
+
if (remediationWriter) {
|
|
127
|
+
return remediationWriter(verbs, missing, layer);
|
|
128
|
+
}
|
|
129
|
+
return `This operation requires ${missing} permission on the instance, which has not been granted.`;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A layer that denies the listed verbs outright.
|
|
133
|
+
*
|
|
134
|
+
* Placed at the top of the ladder so nothing below can grant past it. This is the layer
|
|
135
|
+
* that makes pointing the tool at production meaningful.
|
|
136
|
+
*
|
|
137
|
+
* The guarantee has a precise limit, and the docs must state it: this only holds when
|
|
138
|
+
* the variable is set somewhere the agent cannot write — a shell profile, a systemd
|
|
139
|
+
* unit, a container environment. A project-local `.mcp.json` is a file in the workspace,
|
|
140
|
+
* and an agent with file-write access can edit it.
|
|
141
|
+
*/
|
|
142
|
+
export function denyLayer(name, denied) {
|
|
143
|
+
const set = new Set(denied);
|
|
144
|
+
return {
|
|
145
|
+
name,
|
|
146
|
+
answer: (verb) => (set.has(verb) ? "deny" : "abstain"),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** A layer that grants the listed verbs and abstains on the rest. */
|
|
150
|
+
export function grantLayer(name, granted) {
|
|
151
|
+
const set = new Set(granted);
|
|
152
|
+
return {
|
|
153
|
+
name,
|
|
154
|
+
answer: (verb) => (set.has(verb) ? "grant" : "abstain"),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** Convenience for tests and for embedders that want the old unrestricted behaviour. */
|
|
158
|
+
export function allowAllLayer() {
|
|
159
|
+
return grantLayer("allow-all", ["write", "execute"]);
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=Policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Policy.js","sourceRoot":"","sources":["../../src/policy/Policy.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;GAgBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,aAAa,GAAG,SAAS,CAAC;AAEhC,IAAI,MAAM,GAA2B,EAAE,CAAC;AACxC,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB,0FAA0F;AAC1F,MAAM,UAAU,iBAAiB;IAC7B,OAAO,SAAS,CAAC;AACrB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,aAAqC;IAC/D,MAAM,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC;IAC5B,SAAS,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,mBAAmB;IAC/B,MAAM,GAAG,EAAE,CAAC;IACZ,SAAS,GAAG,KAAK,CAAC;AACtB,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,aAAa;IACzB,OAAO,MAAM,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,WAAW,CAAC,IAAU;IAC3B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,MAAM,GAAgB,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACxD,CAAC;QACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACzD,CAA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
+
* Environment-variable policy layers.
|
|
4
|
+
*
|
|
5
|
+
* `NEX_POLICY_DENY` sits at the top of the ladder and cannot be granted past.
|
|
6
|
+
* `NEX_POLICY_ALLOW` sits near the bottom and exists for backward compatibility, so an
|
|
7
|
+
* existing CI job can restore its previous behaviour with one variable rather than
|
|
8
|
+
* editing every command line.
|
|
9
|
+
*
|
|
10
|
+
* Named `NEX_POLICY_*` rather than `NEX_ALLOW_WRITE` because `write` and `execute`
|
|
11
|
+
* collide with ServiceNow ACL vocabulary, and a reader should not have to work out
|
|
12
|
+
* whether this is about ACLs.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DENY_ENV = "NEX_POLICY_DENY";
|
|
15
|
+
export declare const ALLOW_ENV = "NEX_POLICY_ALLOW";
|
|
16
|
+
export interface ParsedVerbs {
|
|
17
|
+
readonly verbs: readonly Verb[];
|
|
18
|
+
/** Tokens that were not recognised. Non-empty means the value was malformed. */
|
|
19
|
+
readonly unknown: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Parses a comma-separated verb list.
|
|
23
|
+
*
|
|
24
|
+
* `all` expands to every verb. Unrecognised tokens are REPORTED rather than dropped, so
|
|
25
|
+
* the caller can fail closed — see `denyFromEnvironment`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseVerbList(raw: string | undefined): ParsedVerbs;
|
|
28
|
+
/**
|
|
29
|
+
* The deny layer, built from `NEX_POLICY_DENY`.
|
|
30
|
+
*
|
|
31
|
+
* FAILS CLOSED on a malformed value. `NEX_POLICY_DENY=wrtie` denies everything and
|
|
32
|
+
* warns, rather than silently denying nothing — a typo in the variable that is supposed
|
|
33
|
+
* to protect production must not quietly disable the protection. That is the whole
|
|
34
|
+
* reason this function reports `unknown` instead of filtering it away.
|
|
35
|
+
*
|
|
36
|
+
* Returns `undefined` when the variable is unset, so the layer is simply absent.
|
|
37
|
+
*/
|
|
38
|
+
export declare function denyFromEnvironment(env?: NodeJS.ProcessEnv, warn?: (message: string) => void): PolicyLayer | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The backward-compatibility grant layer, built from `NEX_POLICY_ALLOW`.
|
|
41
|
+
*
|
|
42
|
+
* Unrecognised tokens here are dropped with a warning rather than failing closed: this
|
|
43
|
+
* variable only ever *grants*, so a typo already fails safe — the operation is refused
|
|
44
|
+
* and the operator sees why.
|
|
45
|
+
*/
|
|
46
|
+
export declare function allowFromEnvironment(env?: NodeJS.ProcessEnv, warn?: (message: string) => void): PolicyLayer | undefined;
|