Skip to content

Commit 8fcaf14

Browse files
committed
[antispam] experimenting (WIP)
1 parent 51b8871 commit 8fcaf14

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

.github/workflows/scripts/antispam.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,29 @@ module.exports = async ({ github, context, core }) => {
153153
// for other checks
154154
// then use a weights/factors instead of booleans,
155155
// compute a confidence score to check against a threshold => if below, then reject
156-
const failed_checks = checks.filter(check => ! check.pass());
157-
158-
const threshold = 0;
159-
if (failed_checks.length <= threshold){
160-
console.info("Not suspicious");
161-
return;
156+
157+
158+
async function filterChecks(checks) {
159+
const results = await Promise.all(
160+
checks.map(async (check) => ({
161+
check,
162+
passed: await check.pass(),
163+
}))
164+
);
165+
return results.filter(({ passed }) => passed).map(({ check }) => check);
162166
}
167+
// const failed_checks = checks.filter(check => ! check.pass());
168+
169+
filterChecks(checks).then(filteredChecks => {
170+
const threshold = 0;
171+
if (failed_checks.length <= threshold) {
172+
console.info("Not suspicious");
173+
return;
174+
}
163175

164-
when_suspicious({ github, context, failed_checks});
176+
when_suspicious({ github, context, failed_checks});
165177

166-
const user_information_as_comment = collect_user_information_report();
167-
// do stuffs with user_information_as_comment
178+
const user_information_as_comment = collect_user_information_report();
179+
// do stuffs with user_information_as_comment
180+
});
168181
};

0 commit comments

Comments
 (0)