Skip to content

Commit 6bd51e8

Browse files
committed
fix: allow process.env in ignores
Fixes conventional-changelog#4281
1 parent fc047e2 commit 6bd51e8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

@commitlint/is-ignored/src/is-ignored.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ test('should not throw error for custom ignore functions without security risks'
256256
'function(commit) { return commit.length < 10 && commit.includes("some"); }',
257257
'function(commit) { return commit.length < 10 || commit.includes("fetch"); }',
258258
'function(commit) { return commit.includes("exec"); }',
259+
'function(commit) { return !process.env.CI && /^wip\b/.test(commit); }',
259260
];
260261

261262
safePatterns.forEach((fnString) => {

@commitlint/is-ignored/src/validate-ignore-func.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export function validateIgnoreFunction(fn: Matcher) {
55

66
// Check for dangerous patterns
77
const dangerousPattern =
8-
/(?:process|require|import|eval|fetch|XMLHttpRequest|fs|child_process)(?:\s*\.|\s*\()|(?:exec|execFile|spawn)\s*\(/;
8+
/(?:process(?!\.env)|require|import|eval|fetch|XMLHttpRequest|fs|child_process)(?:\s*\.|\s*\()|(?:exec|execFile|spawn)\s*\(/;
99
if (dangerousPattern.test(fnString)) {
1010
// Find which pattern matched for a more specific error message
1111
const match = fnString.match(dangerousPattern);

0 commit comments

Comments
 (0)