Skip to content

Commit 6864e8e

Browse files
authored
Updates (#44)
1 parent e25599f commit 6864e8e

4 files changed

Lines changed: 124 additions & 94 deletions

File tree

package-lock.json

Lines changed: 75 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@influxdata/influxdb-client": "^1.35.0",
16-
"@octokit/rest": "^22.0.0",
16+
"@octokit/rest": "^22.0.1",
1717
"@sentry/node": "^10.22.0",
1818
"axios": "^1.13.1",
1919
"badge-maker": "^5.0.2",
@@ -23,7 +23,7 @@
2323
"debug": "^4.4.3",
2424
"express": "^5.1.0",
2525
"jsonpath": "^1.1.1",
26-
"lucide-static": "^0.548.0",
26+
"lucide-static": "^0.552.0",
2727
"node-schedule": "^2.1.1",
2828
"nodemon": "^3.1.10",
2929
"pug": "^3.0.3",
@@ -33,8 +33,8 @@
3333
"yaml": "^2.8.1"
3434
},
3535
"devDependencies": {
36-
"@eslint/js": "^9.38.0",
37-
"eslint": "^9.38.0",
36+
"@eslint/js": "^9.39.0",
37+
"eslint": "^9.39.0",
3838
"prettier": "^3.6.2"
3939
}
4040
}

src/api.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,21 @@ export async function getVTReleaseStats(req) {
167167
/**
168168
* Get VT Stats for a File ID/Hash
169169
* @param {string} hash
170-
* @return {Promise<object>}
170+
* @typedef {object} Stats
171+
* @property {number} malicious
172+
* @property {number} suspicious
173+
* @property {number} undetected
174+
* @return {Promise<Stats>}
171175
*/
172176
export async function getVTStats(hash) {
173177
const key = `/vt/id/${hash}`
178+
const timeout = 60 * 60 * 24 * 5
174179
debug('key:', key)
175180
// NOTE: Duplicate Code - 5 lines
176181
const cached = await cacheGet(key)
177182
if (cached) {
178183
if (cached.errorMessage) throw new Error(cached.errorMessage)
184+
client.expire(key, timeout).catch(console.error) // reset expire on get
179185
return cached
180186
}
181187
debug(`-- CACHE MISS: ${key}`)
@@ -195,7 +201,7 @@ export async function getVTStats(hash) {
195201
stats = data?.data?.attributes?.last_analysis_stats
196202
}
197203
if (!stats) await cacheError(key, 'VT Stats Not Found')
198-
await cacheSet(key, stats, 60 * 60 * 48)
204+
await cacheSet(key, stats, timeout)
199205
return stats
200206
}
201207

@@ -275,6 +281,16 @@ export async function incrKey(key) {
275281
await client.incr(key)
276282
}
277283

284+
// export async function incrPurge(result) {
285+
// const multi = client.multi().incr('purge_count')
286+
// // multi.incr('purge_count')
287+
// if (result) {
288+
// multi.incr('purge_hit')
289+
// } else {
290+
// multi.incr('purge_miss')
291+
// }
292+
// }
293+
278294
export async function sendInflux() {
279295
if (!influxClient) return debug('InfluxDB Not Configured.')
280296
debug(`Processing Influx: ${new Date().toLocaleString()}`)

0 commit comments

Comments
 (0)