Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 75 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@influxdata/influxdb-client": "^1.35.0",
"@octokit/rest": "^22.0.0",
"@octokit/rest": "^22.0.1",
"@sentry/node": "^10.22.0",
"axios": "^1.13.1",
"badge-maker": "^5.0.2",
Expand All @@ -23,7 +23,7 @@
"debug": "^4.4.3",
"express": "^5.1.0",
"jsonpath": "^1.1.1",
"lucide-static": "^0.548.0",
"lucide-static": "^0.552.0",
"node-schedule": "^2.1.1",
"nodemon": "^3.1.10",
"pug": "^3.0.3",
Expand All @@ -33,8 +33,8 @@
"yaml": "^2.8.1"
},
"devDependencies": {
"@eslint/js": "^9.38.0",
"eslint": "^9.38.0",
"@eslint/js": "^9.39.0",
"eslint": "^9.39.0",
"prettier": "^3.6.2"
}
}
20 changes: 18 additions & 2 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,21 @@ export async function getVTReleaseStats(req) {
/**
* Get VT Stats for a File ID/Hash
* @param {string} hash
* @return {Promise<object>}
* @typedef {object} Stats
* @property {number} malicious
* @property {number} suspicious
* @property {number} undetected
* @return {Promise<Stats>}
*/
export async function getVTStats(hash) {
const key = `/vt/id/${hash}`
const timeout = 60 * 60 * 24 * 5
debug('key:', key)
// NOTE: Duplicate Code - 5 lines
const cached = await cacheGet(key)
if (cached) {
if (cached.errorMessage) throw new Error(cached.errorMessage)
client.expire(key, timeout).catch(console.error) // reset expire on get
return cached
}
debug(`-- CACHE MISS: ${key}`)
Expand All @@ -195,7 +201,7 @@ export async function getVTStats(hash) {
stats = data?.data?.attributes?.last_analysis_stats
}
if (!stats) await cacheError(key, 'VT Stats Not Found')
await cacheSet(key, stats, 60 * 60 * 48)
await cacheSet(key, stats, timeout)
return stats
}

Expand Down Expand Up @@ -275,6 +281,16 @@ export async function incrKey(key) {
await client.incr(key)
}

// export async function incrPurge(result) {
// const multi = client.multi().incr('purge_count')
// // multi.incr('purge_count')
// if (result) {
// multi.incr('purge_hit')
// } else {
// multi.incr('purge_miss')
// }
// }

export async function sendInflux() {
if (!influxClient) return debug('InfluxDB Not Configured.')
debug(`Processing Influx: ${new Date().toLocaleString()}`)
Expand Down
Loading