fix(Git Node): Restore Clone and other operations on simple-git 3.36+ (#30223)

This commit is contained in:
Alexander Gekov 2026-05-11 17:46:30 +03:00 committed by GitHub
parent c75a45ba15
commit a8aa95551e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 25 additions and 0 deletions

View File

@ -337,6 +337,10 @@ export class Git implements INodeType {
const gitOptions: Partial<SimpleGitOptions> = { const gitOptions: Partial<SimpleGitOptions> = {
baseDir: resolvedRepositoryPath, baseDir: resolvedRepositoryPath,
config: gitConfig, config: gitConfig,
// simple-git blocks callers from setting `core.hooksPath` via `config`
// unless this flag is set. We set it deliberately as a mitigation, so
// opt in to keep that mitigation working.
...(!enableHooks && { unsafe: { allowUnsafeHooksPath: true } }),
}; };
const git: SimpleGit = simpleGit(gitOptions) const git: SimpleGit = simpleGit(gitOptions)

View File

@ -130,6 +130,18 @@ describe('Git Node', () => {
); );
}); });
it('should opt into allowUnsafeHooksPath when enableGitNodeHooks is false', async () => {
securityConfig.enableGitNodeHooks = false;
await gitNode.execute.call(executeFunctions);
expect(mockSimpleGit).toHaveBeenCalledWith(
expect.objectContaining({
unsafe: { allowUnsafeHooksPath: true },
}),
);
});
it('should not add core.hooksPath=/dev/null when enableGitNodeHooks is true', async () => { it('should not add core.hooksPath=/dev/null when enableGitNodeHooks is true', async () => {
securityConfig.enableGitNodeHooks = true; securityConfig.enableGitNodeHooks = true;
@ -141,6 +153,15 @@ describe('Git Node', () => {
}), }),
); );
}); });
it('should not opt into allowUnsafeHooksPath when enableGitNodeHooks is true', async () => {
securityConfig.enableGitNodeHooks = true;
await gitNode.execute.call(executeFunctions);
const options = mockSimpleGit.mock.calls[0][0] as { unsafe?: unknown };
expect(options.unsafe).toBeUndefined();
});
}); });
describe('Restricted file paths', () => { describe('Restricted file paths', () => {