فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

feat(holoo): add fail-closed reusable SQL operation policy

Davood Mehraban committed Nov 22, 2026 at 21:31 UTC ee306409850a46b7746b149735e96b383752a26a
2 files changed +28
src/holoo-write-policy.cjs new
+9
@@ -0,0 +1,9 @@
1 +'use strict';
2 +// Deliberately fail closed. This is a reusable policy, not an installed SQL interception layer.
3 +function evaluateHolooWrite({ operation, database, audit } = {}) {
4 + if (operation !== 'read') return Object.freeze({ allowed: false, reason: 'Holoo writes are not authorized: no behavioral/concurrency acceptance evidence' });
5 + if (database !== 'HolooBackup_050808_LAB_20261110') return Object.freeze({ allowed: false, reason: 'Only the approved backup lab may be read through this policy' });
6 + if (!audit || audit.readOnlyAudit !== true || audit.complete !== true || audit.database !== database || audit.productionWriteGate?.status !== 'NO-GO' || audit.productionWriteGate?.productionWritesAuthorized !== false) return Object.freeze({ allowed: false, reason: 'Verified lab audit is required' });
7 + return Object.freeze({ allowed: true, reason: 'Read-only approved lab operation' });
8 +}
9 +module.exports = { evaluateHolooWrite };
tests/holoo-write-policy.test.mjs new
+19
@@ -0,0 +1,19 @@
1 +import test from 'node:test';
2 +import assert from 'node:assert/strict';
3 +import { createRequire } from 'node:module';
4 +const require = createRequire(import.meta.url);
5 +const { evaluateHolooWrite } = require('../src/holoo-write-policy.cjs');
6 +const database = 'HolooBackup_050808_LAB_20261110';
7 +const audit = { database, readOnlyAudit: true, complete: true, productionWriteGate: { status: 'NO-GO', productionWritesAuthorized: false } };
8 +test('deny all write attempts even with approved lab audit', () => {
9 + for (const operation of ['insert','update','delete','execute','write',undefined]) assert.equal(evaluateHolooWrite({ operation, database, audit }).allowed, false);
10 +});
11 +test('deny production database even for reads', () => {
12 + assert.equal(evaluateHolooWrite({ operation:'read', database:'Holoo1', audit }).allowed, false);
13 +});
14 +test('deny missing or malformed audit', () => {
15 + for (const bad of [undefined, {}, {...audit,complete:false}, {...audit,productionWriteGate:{status:'GO',productionWritesAuthorized:true}}]) assert.equal(evaluateHolooWrite({ operation:'read', database, audit:bad }).allowed, false);
16 +});
17 +test('allow only audited approved lab read operation', () => {
18 + assert.equal(evaluateHolooWrite({ operation:'read', database, audit }).allowed, true);
19 +});