mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
fix(Git Node): Restore Clone and other operations on simple-git 3.36+ (#30223)
This commit is contained in:
parent
c75a45ba15
commit
a8aa95551e
|
|
@ -337,6 +337,10 @@ export class Git implements INodeType {
|
|||
const gitOptions: Partial<SimpleGitOptions> = {
|
||||
baseDir: resolvedRepositoryPath,
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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 () => {
|
||||
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', () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user