|
1 | | -'use strict'; |
2 | | - |
3 | | -let isCodeIntegrityEnforced; |
4 | | -let alreadyQueriedSystemCodeEnforcmentMode = false; |
5 | | - |
6 | | -const { |
7 | | - isFileTrustedBySystemCodeIntegrityPolicy, |
8 | | - isSystemEnforcingCodeIntegrity, |
9 | | -} = internalBinding('code_integrity'); |
10 | | - |
11 | | -function isAllowedToExecuteFile(filepath) { |
12 | | - if (!alreadyQueriedSystemCodeEnforcmentMode) { |
13 | | - isCodeIntegrityEnforced = isSystemEnforcingCodeIntegrity(); |
14 | | - alreadyQueriedSystemCodeEnforcmentMode = true; |
15 | | - } |
16 | | - |
17 | | - if (!isCodeIntegrityEnforced) { |
18 | | - return true; |
19 | | - } |
20 | | - |
21 | | - return isFileTrustedBySystemCodeIntegrityPolicy(filepath); |
22 | | -} |
23 | | - |
24 | | -module.exports = { |
25 | | - isAllowedToExecuteFile, |
26 | | - isFileTrustedBySystemCodeIntegrityPolicy, |
27 | | - isSystemEnforcingCodeIntegrity, |
28 | | -}; |
| 1 | +'use strict'; |
| 2 | + |
| 3 | +let isCodeIntegrityEnforced; |
| 4 | +let alreadyQueriedSystemCodeEnforcmentMode = false; |
| 5 | + |
| 6 | +const { |
| 7 | + isFileTrustedBySystemCodeIntegrityPolicy, |
| 8 | + isSystemEnforcingCodeIntegrity, |
| 9 | +} = internalBinding('code_integrity'); |
| 10 | + |
| 11 | +function isAllowedToExecuteFile(filepath) { |
| 12 | + if (!alreadyQueriedSystemCodeEnforcmentMode) { |
| 13 | + isCodeIntegrityEnforced = isSystemEnforcingCodeIntegrity(); |
| 14 | + alreadyQueriedSystemCodeEnforcmentMode = true; |
| 15 | + } |
| 16 | + |
| 17 | + if (!isCodeIntegrityEnforced) { |
| 18 | + return true; |
| 19 | + } |
| 20 | + |
| 21 | + return isFileTrustedBySystemCodeIntegrityPolicy(filepath); |
| 22 | +} |
| 23 | + |
| 24 | +module.exports = { |
| 25 | + isAllowedToExecuteFile, |
| 26 | + isFileTrustedBySystemCodeIntegrityPolicy, |
| 27 | + isSystemEnforcingCodeIntegrity, |
| 28 | +}; |
0 commit comments