Skip to content

Commit e33148f

Browse files
authored
fix: Ensure PowerShell output use for hostname detection is limited to hostname only (#3899)
1 parent a1b1f6f commit e33148f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/apm-client/http-apm-client/detect-hostname.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ function detectHostname() {
3030
// https://learn.microsoft.com/en-us/dotnet/api/system.net.dns.gethostentry
3131
out = spawnSync(
3232
'powershell.exe',
33-
['[System.Net.Dns]::GetHostEntry($env:computerName).HostName'],
33+
[
34+
'-NoLogo',
35+
'-NonInteractive',
36+
'-NoProfile',
37+
'-ExecutionPolicy',
38+
'Bypass',
39+
'-Command',
40+
'[System.Net.Dns]::GetHostEntry($env:computerName).HostName',
41+
],
3442
{ encoding: 'utf8', shell: true, timeout: 2000 },
3543
);
3644
if (!out.error) {

0 commit comments

Comments
 (0)