diff --git a/README.md b/README.md index f521b88..40450b0 100644 --- a/README.md +++ b/README.md @@ -26,3 +26,5 @@ - Start development web app with: `npm run start:dev` (recommended) - Start production web app with: `npm run start:prod` (warning: please use a dev instance on first run, for configuration purposes) - Navigate to http://localhost:5111 in your browser, and you should be shown a fresh instance of CryptoScamDB :sparkles: + +**Remember to clean your cache (located in `data/`) when you go to a new branch!** \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c7f5a39..2852066 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7993,7 +7993,7 @@ }, "utf8": { "version": "2.1.1", - "resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", + "resolved": "http://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz", "integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g=" } } diff --git a/package.json b/package.json index 089936c..a358802 100644 --- a/package.json +++ b/package.json @@ -71,6 +71,7 @@ "request": "2.88.0", "sqlite3": "^4.0.4", "typescript": "3.1.6", + "uuid": "^3.3.2", "web3": "1.0.0-beta.36", "web3-utils": "^1.0.0-beta.55" }, diff --git a/src/routes/v1/domain.ts b/src/routes/v1/domain.ts index 6bd051b..b6f7614 100644 --- a/src/routes/v1/domain.ts +++ b/src/routes/v1/domain.ts @@ -1,5 +1,9 @@ import * as db from '../../utils/db'; import { Request, Response } from 'express'; +import generateAbuseReport from '../../utils/abusereport'; +import Scam from '../../classes/scam.class'; +import { getGoogleSafeBrowsing, getURLScan, getVirusTotal } from '../../utils/lookup'; +import config from '../../utils/config'; export default async (req: Request, res: Response) => { const entry: any = await db.all( @@ -30,6 +34,22 @@ export default async (req: Request, res: Response) => { entry[0].addresses = addressesByCoin; } + const objScam = new Scam(entry[0]); + entry[0].abusereport = generateAbuseReport(objScam); + + entry[0].lookups = {}; + if (config.apiKeys.Google_SafeBrowsing) { + entry[0].lookups.Google_SafeBrowsing = await getGoogleSafeBrowsing(entry[0].url); + } else { + entry[0].lookups.Google_SafeBrowsing = ''; + } + if (config.apiKeys.VirusTotal) { + entry[0].lookups.VirusTotal = await getVirusTotal(entry[0].url); + } else { + entry[0].lookups.VirusTotal = ''; + } + entry[0].lookups.URLScan = await getURLScan(entry[0].hostname); + res.json({ success: true, result: entry }); } }; diff --git a/src/routes/v1/featured.ts b/src/routes/v1/featured.ts index 4825003..c2592de 100644 --- a/src/routes/v1/featured.ts +++ b/src/routes/v1/featured.ts @@ -5,7 +5,7 @@ export default async (req: Request, res: Response) => { res.json({ success: true, result: await db.all( - "SELECT id,name,description FROM entries WHERE type='verified' AND featured=1" + "SELECT id,name,description,url FROM entries WHERE type='verified' AND featured=1" ) }); }; diff --git a/src/routes/v1/postReport.ts b/src/routes/v1/postReport.ts index 2071f7d..99dc9e1 100644 --- a/src/routes/v1/postReport.ts +++ b/src/routes/v1/postReport.ts @@ -2,8 +2,10 @@ import config from '../../utils/config'; import * as captcha from '../../utils/gcaptcha'; import * as slack from '../../utils/slack'; import { Request, Response } from 'express'; +const uuidv1 = require('uuid/v1'); export default async (req: Request, res: Response) => { + const strReportId = uuidv1(); if ( config.apiKeys.Google_Captcha && config.apiKeys.Slack_Webhook && @@ -11,11 +13,13 @@ export default async (req: Request, res: Response) => { req.body.args && req.body.args.captcha ) { + req.body.args.report_id = strReportId; const isValidCaptcha = await captcha.verifyResponse(req.body.args.captcha); if (isValidCaptcha) { slack.sendReport(req.body); res.json({ - success: true + success: true, + report_id: strReportId }); } else { res.json({ @@ -26,7 +30,8 @@ export default async (req: Request, res: Response) => { } else if (config.apiKeys.Slack_Webhook && req.body && req.body.args && req.body.args.captcha) { slack.sendReport(req.body); res.json({ - success: true + success: true, + report_id: strReportId }); } else { res.json({ diff --git a/src/routes/v1/stats.ts b/src/routes/v1/stats.ts index cf65ced..fe7bbb6 100644 --- a/src/routes/v1/stats.ts +++ b/src/routes/v1/stats.ts @@ -23,12 +23,15 @@ export default async (req: Request, res: Response) => { featured: featured.count, addresses: addresses.count, ips: ips.count, - actives: statuses.find(en => en.status === 'Active').count, + actives: statuses.length > 0 ? statuses.find(en => en.status === 'Active').count : -1, inactives: - statuses.find(en => en.status === 'Inactive').count + - statuses.find(en => en.status === 'Offline').count, - offline: statuses.find(en => en.status === 'Offline').count, - suspended: statuses.find(en => en.status === 'Suspended').count, + statuses.length > 0 + ? statuses.find(en => en.status === 'Inactive').count + + statuses.find(en => en.status === 'Offline').count + : -1, + offline: statuses.length > 0 ? statuses.find(en => en.status === 'Offline').count : -1, + suspended: + statuses.length > 0 ? statuses.find(en => en.status === 'Suspended').count : -1, reporters: await db.all( 'SELECT reporter,count(reporter) as count FROM entries WHERE reporter IS NOT NULL GROUP BY reporter' ), diff --git a/src/utils/db.ts b/src/utils/db.ts index 9c90684..183413e 100644 --- a/src/utils/db.ts +++ b/src/utils/db.ts @@ -43,7 +43,7 @@ export const init = async (): Promise => { export const get = (query, data?) => { return new Promise((resolve, reject) => { - debug('GET %s %o', query, data); + //debug('GET %s %o', query, data); db.get(query, data, (error, row) => { if (error) { debug('ERROR %s %o', query, data); @@ -57,7 +57,7 @@ export const get = (query, data?) => { export const all = (query, data?) => { return new Promise((resolve, reject) => { - debug('ALL %s %o', query, data); + //debug('ALL %s %o', query, data); db.all(query, data, (error, rows) => { if (error) { debug('ERROR %s %o', query, data); @@ -71,7 +71,7 @@ export const all = (query, data?) => { export const run = (query, data?) => { return new Promise((resolve, reject) => { - debug('RUN %s %o', query, data); + //debug('RUN %s %o', query, data); db.run(query, data, function(error) { if (error) { debug('ERROR %s %o', query, data);