Skip to content

Commit d9d8b18

Browse files
authored
Merge pull request #1158 from jescalada/fix-fuzz-test-errors
fix: flaky fuzz test errors
2 parents 9679618 + 802ba27 commit d9d8b18

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"react-router-dom": "6.30.1",
8181
"simple-git": "^3.28.0",
8282
"uuid": "^11.1.0",
83+
"validator": "^13.15.15",
8384
"yargs": "^17.7.2"
8485
},
8586
"devDependencies": {
@@ -96,6 +97,7 @@
9697
"@types/node": "^22.17.0",
9798
"@types/react-dom": "^17.0.26",
9899
"@types/react-html-parser": "^2.0.7",
100+
"@types/validator": "^13.15.2",
99101
"@types/yargs": "^17.0.33",
100102
"@typescript-eslint/eslint-plugin": "^8.38.0",
101103
"@typescript-eslint/parser": "^8.38.0",

src/proxy/processors/push-action/checkAuthorEmails.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
import { Action, Step } from '../../actions';
22
import { getCommitConfig } from '../../../config';
33
import { Commit } from '../../actions/Action';
4+
import { isEmail } from 'validator';
45

56
const commitConfig = getCommitConfig();
67

78
const isEmailAllowed = (email: string): boolean => {
8-
if (!email) {
9+
if (!email || !isEmail(email)) {
910
return false;
1011
}
1112

1213
const [emailLocal, emailDomain] = email.split('@');
1314

14-
if (!emailLocal || !emailDomain) {
15-
return false;
16-
}
17-
1815
if (
1916
commitConfig.author.email.domain.allow &&
20-
!emailDomain.match(new RegExp(commitConfig.author.email.domain.allow, 'g'))
17+
!new RegExp(commitConfig.author.email.domain.allow, 'g').test(emailDomain)
2118
) {
2219
return false;
2320
}
2421

2522
if (
2623
commitConfig.author.email.local.block &&
27-
emailLocal.match(new RegExp(commitConfig.author.email.local.block, 'g'))
24+
new RegExp(commitConfig.author.email.local.block, 'g').test(emailLocal)
2825
) {
2926
return false;
3027
}

test/processors/checkAuthorEmails.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('checkAuthorEmails', () => {
181181
exec({}, action);
182182
}),
183183
{
184-
numRuns: 100
184+
numRuns: 1000
185185
}
186186
);
187187

@@ -200,7 +200,7 @@ describe('checkAuthorEmails', () => {
200200
exec({}, action);
201201
}),
202202
{
203-
numRuns: 100
203+
numRuns: 1000
204204
}
205205
);
206206
expect(action.step.error).to.be.undefined;
@@ -215,7 +215,7 @@ describe('checkAuthorEmails', () => {
215215
exec({}, action);
216216
}),
217217
{
218-
numRuns: 100
218+
numRuns: 1000
219219
}
220220
);
221221

@@ -232,7 +232,7 @@ describe('checkAuthorEmails', () => {
232232
exec({}, action);
233233
}),
234234
{
235-
numRuns: 100
235+
numRuns: 1000
236236
}
237237
);
238238
expect(action.step.error).to.be.undefined;

test/processors/checkCommitMessages.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ describe('checkCommitMessages', () => {
164164
fc.integer(),
165165
fc.double(),
166166
fc.boolean(),
167-
fc.object(),
168167
),
169168
author: fc.string()
170169
}),
@@ -193,7 +192,8 @@ describe('checkCommitMessages', () => {
193192
[{ message: null, author: 'me' }],
194193
[{ message: {}, author: 'me' }],
195194
[{ message: 'SeCrEt', author: 'me' }]
196-
]
195+
],
196+
numRuns: 1000
197197
}
198198
);
199199
});

0 commit comments

Comments
 (0)