Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ Refer to https://docs.gitlab.com/ee/ci/jobs/job_rules.html#unexpected-behavior-f
});

// Convert all null.match functions to false
evalStr = evalStr.replace(/null.match\(.+?\) != null/g, "false");
evalStr = evalStr.replace(/null.match\(.+?\) == null/g, "false");
evalStr = evalStr.replace(/null.match\(.+?\)\s*!=\s*null/g, "false");
evalStr = evalStr.replace(/null.match\(.+?\)\s*==\s*null/g, "false");

let res;
try {
Expand Down
5 changes: 5 additions & 0 deletions tests/rules-regex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ const tests = [
jsExpression: '"23".match(/1234/) != null',
evalResult: false,
},
{
rule: '$CI_COMMIT_BRANCH && $GITLAB_FEATURES =~ /\bdependency_scanning\b/ && $CI_GITLAB_FIPS_MODE == "true"',
jsExpression: 'null && false&& null == "true"',
evalResult: false,
},
];
/* eslint-enable @typescript-eslint/quotes */

Expand Down