Make sure we use a different version.txt to prevent having to redownload DB

This commit is contained in:
Reinier Criel 2025-10-24 09:59:53 -07:00
parent b5988e19c1
commit 15785fad73
4 changed files with 28 additions and 22 deletions

View file

@ -3,22 +3,13 @@ import { getEcoSystem } from "../config/settings.js";
const malwareDatabaseUrls = {
js: "https://malware-list.aikido.dev/malware_predictions.json",
py: "https://malware-list.aikido.dev/malware_predictions_python.json",
py: "https://malware-list.aikido.dev/malware_pypi.json",
};
export async function fetchMalwareDatabase() {
const ecosystem = getEcoSystem() || "js";
const malwareDatabaseUrl = malwareDatabaseUrls[ecosystem];
const response = await fetch(malwareDatabaseUrl);
// Python malware database doesn't exist yet, return empty database
if (!response.ok && ecosystem === "py" && response.status === 403) {
return {
malwareDatabase: [],
version: undefined,
};
}
if (!response.ok) {
throw new Error(`Error fetching ${ecosystem} malware database: ${response.statusText}`);
}
@ -41,12 +32,7 @@ export async function fetchMalwareDatabaseVersion() {
const response = await fetch(malwareDatabaseUrl, {
method: "HEAD",
});
// Python malware database doesn't exist yet, return undefined
if (!response.ok && ecosystem === "py" && response.status === 403) {
return undefined;
}
if (!response.ok) {
throw new Error(
`Error fetching ${ecosystem} malware database version: ${response.statusText}`