feat: Add N8N_GIT_NODE_DISABLE_BARE_REPOS environment variable to allow users to disable bare repositories in Git Node (#19559)

This commit is contained in:
RomanDavydchuk
2025-09-18 18:33:32 +03:00
committed by GitHub
parent bcedf5c76f
commit 5bf3db5ba8
7 changed files with 180 additions and 0 deletions

View File

@@ -2,6 +2,16 @@
This list shows all the versions which include breaking changes and how to upgrade.
# 1.113.0
### What changed?
Support for bare repositories in Git Node was dropped in the cloud version of n8n due to security reasons. Also, an environment variable `N8N_GIT_NODE_DISABLE_BARE_REPOS` was added that allows self-hosted users to disable bare repositories as well.
### When is action necessary?
If you have workflows that use the Git Node and work with bare git repositories.
# 1.109.0
### What changed?

View File

@@ -20,6 +20,7 @@ describe('DeprecationService', () => {
// this test suite.
process.env = {
N8N_BLOCK_ENV_ACCESS_IN_NODE: 'false',
N8N_GIT_NODE_DISABLE_BARE_REPOS: 'false',
};
jest.resetAllMocks();
@@ -140,6 +141,7 @@ describe('DeprecationService', () => {
process.env = {
N8N_RUNNERS_ENABLED: 'true',
N8N_BLOCK_ENV_ACCESS_IN_NODE: 'false',
N8N_GIT_NODE_DISABLE_BARE_REPOS: 'false',
};
jest.spyOn(config, 'getEnv').mockImplementation((key) => {
@@ -239,6 +241,7 @@ describe('DeprecationService', () => {
beforeEach(() => {
process.env = {
N8N_RUNNERS_ENABLED: 'true',
N8N_GIT_NODE_DISABLE_BARE_REPOS: 'false',
};
jest.resetAllMocks();
@@ -259,4 +262,29 @@ describe('DeprecationService', () => {
},
);
});
describe('N8N_GIT_NODE_DISABLE_BARE_REPOS', () => {
beforeEach(() => {
process.env = {
N8N_RUNNERS_ENABLED: 'true',
N8N_BLOCK_ENV_ACCESS_IN_NODE: 'false',
};
jest.resetAllMocks();
});
test('should warn when N8N_GIT_NODE_DISABLE_BARE_REPOS is not set', () => {
delete process.env.N8N_GIT_NODE_DISABLE_BARE_REPOS;
deprecationService.warn();
expect(logger.warn).toHaveBeenCalled();
});
test.each(['false', 'true'])(
'should not warn when N8N_GIT_NODE_DISABLE_BARE_REPOS is %s',
(value) => {
process.env.N8N_GIT_NODE_DISABLE_BARE_REPOS = value;
deprecationService.warn();
expect(logger.warn).not.toHaveBeenCalled();
},
);
});
});

View File

@@ -109,6 +109,12 @@ export class DeprecationService {
'The default value of N8N_BLOCK_ENV_ACCESS_IN_NODE will be changed from false to true in a future version. If you need to access environment variables from the Code Node or from expressions, please set N8N_BLOCK_ENV_ACCESS_IN_NODE=false. Learn more: https://docs.n8n.io/hosting/configuration/environment-variables/security/',
checkValue: (value: string | undefined) => value === undefined || value === '',
},
{
envVar: 'N8N_GIT_NODE_DISABLE_BARE_REPOS',
message:
'Support for bare repositories in the Git Node will be removed in a future version due to security concerns. If you are not using bare repositories in the Git Node, please set N8N_GIT_NODE_DISABLE_BARE_REPOS=true. Learn more: https://docs.n8n.io/hosting/configuration/environment-variables/security/',
checkValue: (value: string | undefined) => value === undefined || value === '',
},
];
/** Runtime state of deprecation-related env vars. */