mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
fix(core): Allow GIT_SSH_COMMAND in simple-git after 3.36.0 upgrade (#29894)
This commit is contained in:
parent
de3a98f58f
commit
f42be9030e
|
|
@ -366,9 +366,15 @@ describe('SourceControlGitService', () => {
|
|||
mockSourceControlPreferencesService.getPreferences.mockReturnValue({
|
||||
connectionType: 'ssh',
|
||||
} as never);
|
||||
(simpleGit as jest.Mock).mockClear();
|
||||
|
||||
await sourceControlGitService.setGitCommand();
|
||||
|
||||
expect(simpleGit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
unsafe: { allowUnsafeSshCommand: true },
|
||||
}),
|
||||
);
|
||||
expect(mockGitInstance.env).toHaveBeenCalledWith(
|
||||
'GIT_SSH_COMMAND',
|
||||
'ssh -o UserKnownHostsFile=".ssh/known_hosts" -o StrictHostKeyChecking=accept-new -i "private-key"',
|
||||
|
|
|
|||
|
|
@ -171,7 +171,12 @@ export class SourceControlGitService {
|
|||
// - Subsequent connections: verifies against saved key
|
||||
const sshCommand = `ssh -o UserKnownHostsFile="${escapedKnownHostsPath}" -o StrictHostKeyChecking=accept-new -i "${escapedPrivateKeyPath}"`;
|
||||
|
||||
this.git = simpleGit(this.gitOptions)
|
||||
// Allow GIT_SSH_COMMAND so we can point SSH at n8n's own private key and known_hosts.
|
||||
// This is safe because the command is constructed internally above, not from user input.
|
||||
this.git = simpleGit({
|
||||
...this.gitOptions,
|
||||
unsafe: { allowUnsafeSshCommand: true },
|
||||
})
|
||||
.env('GIT_SSH_COMMAND', sshCommand)
|
||||
.env('GIT_TERMINAL_PROMPT', '0');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user