-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unc - adopt setting and handling of allow list (#5)
* unc - adopt setting and handling of allow list * unc - set allow list on server too * unc - pick our patched node.js for now * bump electron * unc - ignore sync is not needed with machine scope * unc - use process set directly * 🆙 22.5.1
- Loading branch information
Showing
17 changed files
with
203 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { isWindows } from 'vs/base/common/platform'; | ||
|
||
function processUNCHostAllowlist(): Set<string> | undefined { | ||
|
||
// The property `process.uncHostAllowlist` is not available in official node.js | ||
// releases, only in our own builds, so we have to probe for availability | ||
|
||
const processWithUNCHostAllowlist = process as typeof process & { readonly uncHostAllowlist?: Set<string> }; | ||
|
||
return processWithUNCHostAllowlist.uncHostAllowlist; | ||
} | ||
|
||
export function setUNCHostAllowlist(allowedHosts: string[]): void { | ||
if (!isWindows) { | ||
return; | ||
} | ||
|
||
const allowlist = processUNCHostAllowlist(); | ||
if (allowlist) { | ||
allowlist.clear(); | ||
|
||
for (const allowedHost of allowedHosts) { | ||
allowlist.add(allowedHost); | ||
} | ||
} | ||
} | ||
|
||
export function getUNCHostAllowlist(): string[] { | ||
const allowlist = processUNCHostAllowlist(); | ||
if (allowlist) { | ||
return Array.from(allowlist); | ||
} | ||
|
||
return []; | ||
} | ||
|
||
export function addUNCHostToAllowlist(allowedHost: string): void { | ||
if (!isWindows) { | ||
return; | ||
} | ||
|
||
const allowlist = processUNCHostAllowlist(); | ||
if (allowlist) { | ||
allowlist.add(allowedHost); | ||
} | ||
} | ||
|
||
export function toUNCHostAllowlist(arg0: unknown): string[] { | ||
const allowedUNCHosts = new Set<string>(); | ||
|
||
if (Array.isArray(arg0)) { | ||
for (const host of arg0) { | ||
if (typeof host === 'string') { | ||
allowedUNCHosts.add(host); | ||
} | ||
} | ||
} | ||
|
||
return Array.from(allowedUNCHosts); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.