Skip to content

Commit 38e32db

Browse files
committed
Fix infinite ssh config file processing.
1 parent a6a238f commit 38e32db

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Extension/src/SSH/sshHosts.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,15 @@ export async function getSshConfiguration(configurationPath: string, resolveIncl
9999
return config;
100100
}
101101

102+
function getProcessedPathKey(filePath: string): string {
103+
const absolutePath: string = path.resolve(filePath);
104+
const normalizedPath: string = path.normalize(absolutePath);
105+
return isWindows ? normalizedPath.toLowerCase() : normalizedPath;
106+
}
107+
102108
async function resolveConfigIncludes(config: Configuration, configPath: string): Promise<void> {
109+
const processedIncludePaths: Set<string> = new Set<string>();
110+
processedIncludePaths.add(getProcessedPathKey(configPath));
103111
for (const entry of config) {
104112
if (isDirective(entry) && entry.param === 'Include') {
105113
let includePath: string = resolveHome(entry.value);
@@ -114,6 +122,11 @@ async function resolveConfigIncludes(config: Configuration, configPath: string):
114122
const pathsToGetFilesFrom: string[] = await globAsync(includePath);
115123

116124
for (const filePath of pathsToGetFilesFrom) {
125+
const includeKey: string = getProcessedPathKey(filePath);
126+
if (processedIncludePaths.has(includeKey)) {
127+
continue;
128+
}
129+
processedIncludePaths.add(includeKey);
117130
await getIncludedConfigFile(config, filePath);
118131
}
119132
}

0 commit comments

Comments
 (0)