mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Make sure we use a different version.txt to prevent having to redownload DB
This commit is contained in:
parent
b5988e19c1
commit
15785fad73
4 changed files with 28 additions and 22 deletions
|
|
@ -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}`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue