mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Only load the malware database once
This commit is contained in:
parent
a6980d5108
commit
53bfb14fea
1 changed files with 8 additions and 1 deletions
|
|
@ -8,7 +8,13 @@ import {
|
|||
} from "../config/configFile.js";
|
||||
import { ui } from "../environment/userInteraction.js";
|
||||
|
||||
let cachedMalwareDatabase = null;
|
||||
|
||||
export async function openMalwareDatabase() {
|
||||
if (cachedMalwareDatabase) {
|
||||
return cachedMalwareDatabase;
|
||||
}
|
||||
|
||||
const malwareDatabase = await getMalwareDatabase();
|
||||
|
||||
function getPackageStatus(name, version) {
|
||||
|
|
@ -25,13 +31,14 @@ export async function openMalwareDatabase() {
|
|||
return packageData.reason;
|
||||
}
|
||||
|
||||
return {
|
||||
cachedMalwareDatabase = {
|
||||
getPackageStatus,
|
||||
isMalware: (name, version) => {
|
||||
const status = getPackageStatus(name, version);
|
||||
return isMalwareStatus(status);
|
||||
},
|
||||
};
|
||||
return cachedMalwareDatabase;
|
||||
}
|
||||
|
||||
async function getMalwareDatabase() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue