dsh-server-connector 0.1.0 → 0.2.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/CHANGELOG.md +46 -0
- package/README.md +573 -456
- package/lib/audit.js +14 -3
- package/lib/client.js +1716 -1376
- package/lib/policy.js +167 -6
- package/lib/registry.js +59 -0
- package/lib/routes.js +1527 -1272
- package/lib/tools.js +42 -10
- package/package.json +3 -2
package/lib/audit.js
CHANGED
|
@@ -61,9 +61,20 @@ const APPEND_QUEUES = new Map()
|
|
|
61
61
|
* Non-execution events the spec names (doc §3.4, §4.2.4, §9.6). `rule-disabled`
|
|
62
62
|
* is the event that must be written when a rule id leaves a server's
|
|
63
63
|
* `disabledRules` — i.e. when the rule is switched off (doc §4.2.4).
|
|
64
|
-
*
|
|
64
|
+
* `server-enabled` / `server-disabled` record the enable switch, which applies
|
|
65
|
+
* immediately rather than through the pending queue (enable-switch spec).
|
|
66
|
+
* @typedef {'hostkey-disabled'|'server-deleted'|'rule-disabled'|'server-enabled'|'server-disabled'} AuditEvent
|
|
65
67
|
*/
|
|
66
68
|
|
|
69
|
+
/** Every accepted event name, in one place so the validator and the type agree. */
|
|
70
|
+
const AUDIT_EVENTS = Object.freeze([
|
|
71
|
+
'hostkey-disabled',
|
|
72
|
+
'server-deleted',
|
|
73
|
+
'rule-disabled',
|
|
74
|
+
'server-enabled',
|
|
75
|
+
'server-disabled',
|
|
76
|
+
])
|
|
77
|
+
|
|
67
78
|
/**
|
|
68
79
|
* What `append()` accepts. Every key except `ts` is optional; `ts` is stamped
|
|
69
80
|
* by the log so callers cannot backdate an entry.
|
|
@@ -168,10 +179,10 @@ function buildRecord(entry, now) {
|
|
|
168
179
|
if (!isPlainObject(entry)) throw new AuditError('INVALID_AUDIT', 'audit entry must be an object.')
|
|
169
180
|
const isEvent = entry.event !== undefined
|
|
170
181
|
if (isEvent) {
|
|
171
|
-
if (
|
|
182
|
+
if (!AUDIT_EVENTS.includes(/** @type {any} */ (entry.event))) {
|
|
172
183
|
throw new AuditError(
|
|
173
184
|
'INVALID_AUDIT',
|
|
174
|
-
|
|
185
|
+
`event must be one of ${AUDIT_EVENTS.join(', ')}.`,
|
|
175
186
|
)
|
|
176
187
|
}
|
|
177
188
|
if (entry.decision !== undefined) {
|