[add] implement vulnerability checking and advisory fetching, enhance repo processing, and add utility functions

This commit is contained in:
2025-08-19 19:13:24 +01:00
parent 52d0c7b649
commit 2c30fce7c8
14 changed files with 700 additions and 15 deletions

26
src_vuln/lib.mjs Normal file
View File

@@ -0,0 +1,26 @@
import assert from "assert";
/**
* Bifurcate an array into two arrays based on a predicate function.
* @template T
* @param {T[]} arr
* @param {(T)=>boolean} predicate
* @returns {[T[], T[]]}
*/
export function bifurcateArray(arr, predicate) {
const truthy = [];
const falsy = [];
for (const item of arr) {
if (predicate(item)) {
truthy.push(item);
} else {
falsy.push(item);
}
}
return [truthy, falsy];
}
export function getGithubTokenFromEnvironment() {
assert(process.env.GITHUB_TOKEN, "No token :(");
const githubToken = process.env.GITHUB_TOKEN;
return githubToken;
}