Skip to content

Commit 7cfafd5

Browse files
committed
move code_integrity to internal module, fix formatting
1 parent 384234e commit 7cfafd5

File tree

5 files changed

+19
-22
lines changed

5 files changed

+19
-22
lines changed
File renamed without changes.

lib/internal/main/eval_string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const {
2424
},
2525
} = require('internal/errors');
2626

27-
const ci = require('code_integrity');
27+
const ci = require('internal/code_integrity');
2828
if (ci.isSystemEnforcingCodeIntegrity()) {
2929
throw new ERR_CODE_INTEGRITY_BLOCKED('"eval"');
3030
}

lib/internal/modules/cjs/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ const onRequire = getLazy(() => tracingChannel('module.require'));
199199

200200
const relativeResolveCache = { __proto__: null };
201201

202-
const ci = require('code_integrity');
202+
const ci = require('internal/code_integrity');
203203

204204
let requireDepth = 0;
205205
let isPreloading = false;

src/node_code_integrity.cc

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ static PCWSTR NODEJS = L"Node.js";
2424
static PCWSTR ENFORCE_CODE_INTEGRITY_SETTING_NAME = L"EnforceCodeIntegrity";
2525

2626
void InitWldp(Environment* env) {
27-
28-
if (isWldpInitialized)
29-
{
27+
if (isWldpInitialized) {
3028
return;
3129
}
3230

@@ -53,7 +51,7 @@ void InitWldp(Environment* env) {
5351
(pfnWldpQuerySecurityPolicy)GetProcAddress(
5452
wldp_module,
5553
"WldpQuerySecurityPolicy");
56-
54+
5755
isWldpInitialized = true;
5856
}
5957

@@ -113,8 +111,7 @@ static void IsSystemEnforcingCodeIntegrity(
113111
InitWldp(env);
114112
}
115113

116-
if (WldpGetApplicationSettingBoolean != nullptr)
117-
{
114+
if (WldpGetApplicationSettingBoolean != nullptr) {
118115
BOOL ret;
119116
HRESULT hr = WldpGetApplicationSettingBoolean(
120117
NODEJS,
@@ -125,14 +122,15 @@ static void IsSystemEnforcingCodeIntegrity(
125122
args.GetReturnValue().Set(
126123
Boolean::New(env->isolate(), ret));
127124
return;
128-
} else if (hr != E_NOTFOUND) {
129-
// If the setting is not found, continue through to attempt WldpQuerySecurityPolicy,
130-
// as the setting may be defined in the old settings format
125+
} else if (hr != E_NOTFOUND) {
126+
// If the setting is not found, continue through to attempt
127+
// WldpQuerySecurityPolicy, as the setting may be defined
128+
// in the old settings format
131129
args.GetReturnValue().Set(Boolean::New(env->isolate(), false));
132130
return;
133131
}
134-
}
135-
132+
}
133+
136134
// WldpGetApplicationSettingBoolean is the preferred way for applications to
137135
// query security policy values. However, this method only exists on Windows
138136
// versions going back to circa Win10 2023H2. In order to support systems
@@ -162,7 +160,7 @@ static void IsSystemEnforcingCodeIntegrity(
162160
Boolean::New(env->isolate(), static_cast<bool>(ret)));
163161
}
164162
}
165-
#endif // _WIN32
163+
#endif // _WIN32
166164

167165
#ifndef _WIN32
168166
static void IsFileTrustedBySystemCodeIntegrityPolicy(
@@ -174,7 +172,7 @@ static void IsSystemEnforcingCodeIntegrity(
174172
const FunctionCallbackInfo<Value>& args) {
175173
args.GetReturnValue().Set(false);
176174
}
177-
#endif // ifndef _WIN32
175+
#endif // ifndef _WIN32
178176

179177
void Initialize(Local<Object> target,
180178
Local<Value> unused,
@@ -194,15 +192,14 @@ void Initialize(Local<Object> target,
194192
}
195193

196194
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
197-
//BindingData::RegisterExternalReferences(registry);
198-
199195
registry->Register(IsFileTrustedBySystemCodeIntegrityPolicy);
200196
registry->Register(IsSystemEnforcingCodeIntegrity);
201197
}
202198

203199
} // namespace codeintegrity
204200
} // namespace node
201+
205202
NODE_BINDING_CONTEXT_AWARE_INTERNAL(code_integrity,
206203
node::codeintegrity::Initialize)
207204
NODE_BINDING_EXTERNAL_REFERENCE(code_integrity,
208-
node::codeintegrity::RegisterExternalReferences)
205+
node::codeintegrity::RegisterExternalReferences)

src/node_code_integrity.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ typedef HRESULT(WINAPI* pfnWldpCanExecuteFile)(
3434
typedef HRESULT(WINAPI* pfnWldpCanExecuteBuffer)(
3535
_In_ REFGUID host,
3636
_In_ WLDP_EXECUTION_EVALUATION_OPTIONS options,
37-
_In_reads_(bufferSize) const BYTE *buffer,
37+
_In_reads_(bufferSize) const BYTE* buffer,
3838
_In_ ULONG bufferSize,
3939
_In_opt_ PCWSTR auditInfo,
40-
_Out_ WLDP_EXECUTION_POLICY *result);
40+
_Out_ WLDP_EXECUTION_POLICY* result);
4141

4242
typedef HRESULT(WINAPI* pfnWldpGetApplicationSettingBoolean)(
4343
_In_ PCWSTR id,
@@ -77,11 +77,11 @@ typedef HRESULT(WINAPI* pfnWldpQuerySecurityPolicy)(
7777
const WCHAR _var ## _buffer[] = _string; \
7878
const UNICODE_STRING _var = \
7979
{ sizeof(_string) - sizeof(WCHAR), sizeof(_string), (PWCH) _var ## _buffer }
80-
#endif
80+
#endif
8181

8282
#ifndef E_NOTFOUND
8383
#define E_NOTFOUND 0x80070490
8484
#endif
8585

8686
#endif // _WIN32
87-
#endif // SRC_NODE_CODE_INTEGRITY_H_
87+
#endif // SRC_NODE_CODE_INTEGRITY_H_

0 commit comments

Comments
 (0)