فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(holoo): block effective dtproperties mutation paths before LAB counts
Davood Mehraban committed
Nov 22, 2026 at 23:41 UTC
c3119172ab508a840f8d9d24398e72a2d82d3db9
2 files changed
+17
-4
scripts/holoo-lab-counts.ps1
+7
-4
@@ -30,11 +30,14 @@ try {
30
$q.CommandText="SELECT COUNT_BIG(*) FROM sys.database_permissions WHERE grantee_principal_id=DATABASE_PRINCIPAL_ID('public') AND state_desc IN ('GRANT','GRANT_WITH_GRANT_OPTION') AND ((permission_name='EXECUTE') OR (permission_name IN ('INSERT','UPDATE','DELETE','ALTER','CONTROL','TAKE OWNERSHIP')))"
31
$publicRisks=[long]$q.ExecuteScalar()
32
if($publicRisks -ne 0){throw 'SQL same-connection inherited public privilege gate BLOCKED'}
33
+ # Reject effective mutation paths even if catalog visibility or public-grant inventory changes.
34
+ $q.CommandText="SELECT HAS_PERMS_BY_NAME('dbo.dtproperties','OBJECT','INSERT'),HAS_PERMS_BY_NAME('dbo.dtproperties','OBJECT','UPDATE'),HAS_PERMS_BY_NAME('dbo.dtproperties','OBJECT','DELETE'),HAS_PERMS_BY_NAME('dbo.dt_setpropertybyid','OBJECT','EXECUTE')"
35
+ $er=$q.ExecuteReader()
36
+ try {
37
+ if(-not $er.Read()){throw 'SQL effective mutation-path gate BLOCKED'}
38
+ foreach($i in 0..3){if($er.IsDBNull($i) -or $er.GetInt32($i) -ne 0){throw 'SQL effective mutation-path gate BLOCKED'}}
39
+ }finally{$er.Close()}
40
$q.CommandText=$queries[$QueryId]
41
$value=[long]$q.ExecuteScalar()
42
[pscustomobject]@{database='HolooBackup_050808_LAB_20261110';queryId=$QueryId;count=$value;readOnly=$true}|ConvertTo-Json -Compress
43
} finally {$c.Dispose()}
37
-
38
-
39
-
40
-
tests/holoo-lab-reader.test.mjs
+10
@@ -51,3 +51,13 @@ test('same-connection gate blocks inherited public EXECUTE and DML before counts
51
assert.match(source,/permission_name IN \('INSERT','UPDATE','DELETE'/);
52
assert.match(source,/inherited public privilege gate BLOCKED/);
53
});
54
+
55
+test('same-connection gate rejects effective dtproperties writes and executable setter',()=>{
56
+ const source=readFileSync(fileURLToPath(new URL('../scripts/holoo-lab-counts.ps1',import.meta.url)),'utf8');
57
+ const check=source.indexOf("HAS_PERMS_BY_NAME('dbo.dtproperties','OBJECT','INSERT')");
58
+ const count=source.indexOf('$q.CommandText=$queries[$QueryId]');
59
+ assert.ok(check>source.indexOf('$c.Open()') && count>check);
60
+ for(const permission of ['INSERT','UPDATE','DELETE']) assert.ok(source.includes(`HAS_PERMS_BY_NAME('dbo.dtproperties','OBJECT','${permission}')`));
61
+ assert.match(source,/HAS_PERMS_BY_NAME\('dbo\.dt_setpropertybyid','OBJECT','EXECUTE'\)/);
62
+ assert.match(source,/SQL effective mutation-path gate BLOCKED/);
63
+});