Compare commits

..

No commits in common. "master" and "v1.0.3" have entirely different histories.

11 changed files with 7 additions and 161 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@apiclient.xyz/abuse.ch", "name": "@apiclient.xyz/abuse.ch",
"version": "1.0.12", "version": "1.0.3",
"private": false, "private": false,
"description": "an unofficial client to retrieve abuse.ch data", "description": "an unofficial client to retrieve abuse.ch data",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
@ -41,8 +41,6 @@
"@push.rocks/smartfile": "^10.0.28", "@push.rocks/smartfile": "^10.0.28",
"@push.rocks/smartpath": "^5.0.5", "@push.rocks/smartpath": "^5.0.5",
"csv-parser": "^3.0.0", "csv-parser": "^3.0.0",
"https-proxy-agent": "^7.0.1",
"node-fetch": "^3.3.2",
"unzipper": "^0.10.14" "unzipper": "^0.10.14"
} }
} }

64
pnpm-lock.yaml generated
View File

@ -14,12 +14,6 @@ dependencies:
csv-parser: csv-parser:
specifier: ^3.0.0 specifier: ^3.0.0
version: 3.0.0 version: 3.0.0
https-proxy-agent:
specifier: ^7.0.1
version: 7.0.1
node-fetch:
specifier: ^3.3.2
version: 3.3.2
unzipper: unzipper:
specifier: ^0.10.14 specifier: ^0.10.14
version: 0.10.14 version: 0.10.14
@ -1913,15 +1907,6 @@ packages:
- supports-color - supports-color
dev: true dev: true
/agent-base@7.1.0:
resolution: {integrity: sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==}
engines: {node: '>= 14'}
dependencies:
debug: 4.3.4
transitivePeerDependencies:
- supports-color
dev: false
/agentkeepalive@4.3.0: /agentkeepalive@4.3.0:
resolution: {integrity: sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==} resolution: {integrity: sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
@ -2414,11 +2399,6 @@ packages:
minimist: 1.2.8 minimist: 1.2.8
dev: false dev: false
/data-uri-to-buffer@4.0.1:
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
engines: {node: '>= 12'}
dev: false
/dayjs@1.11.9: /dayjs@1.11.9:
resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==} resolution: {integrity: sha512-QvzAURSbQ0pKdIye2txOzNaHmxtUBXerpY0FJsFXUMKbIZeFm5ht1LS/jFsrncjnmtv8HsG0W2g6c0zUjZWmpA==}
@ -2825,14 +2805,6 @@ packages:
xml-js: 1.6.11 xml-js: 1.6.11
dev: true dev: true
/fetch-blob@3.2.0:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13}
dependencies:
node-domexception: 1.0.0
web-streams-polyfill: 3.2.1
dev: false
/figures@5.0.0: /figures@5.0.0:
resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==}
engines: {node: '>=14'} engines: {node: '>=14'}
@ -2899,13 +2871,6 @@ packages:
combined-stream: 1.0.8 combined-stream: 1.0.8
mime-types: 2.1.35 mime-types: 2.1.35
/formdata-polyfill@4.0.10:
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
engines: {node: '>=12.20.0'}
dependencies:
fetch-blob: 3.2.0
dev: false
/forwarded@0.2.0: /forwarded@0.2.0:
resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==}
engines: {node: '>= 0.6'} engines: {node: '>= 0.6'}
@ -3159,16 +3124,6 @@ packages:
- supports-color - supports-color
dev: true dev: true
/https-proxy-agent@7.0.1:
resolution: {integrity: sha512-Eun8zV0kcYS1g19r78osiQLEFIRspRUDd9tIfBCTBPBeMieF/EsJNL8VI3xOIdYRDEkjQnqOYPsZ2DsWsVsFwQ==}
engines: {node: '>= 14'}
dependencies:
agent-base: 7.1.0
debug: 4.3.4
transitivePeerDependencies:
- supports-color
dev: false
/humanize-ms@1.2.1: /humanize-ms@1.2.1:
resolution: {integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=} resolution: {integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=}
dependencies: dependencies:
@ -3817,11 +3772,6 @@ packages:
lower-case: 1.1.4 lower-case: 1.1.4
dev: true dev: true
/node-domexception@1.0.0:
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
engines: {node: '>=10.5.0'}
dev: false
/node-fetch@2.6.7: /node-fetch@2.6.7:
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==} resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
engines: {node: 4.x || >=6.0.0} engines: {node: 4.x || >=6.0.0}
@ -3834,15 +3784,6 @@ packages:
whatwg-url: 5.0.0 whatwg-url: 5.0.0
dev: true dev: true
/node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
data-uri-to-buffer: 4.0.1
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
dev: false
/normalize-newline@4.1.0: /normalize-newline@4.1.0:
resolution: {integrity: sha512-ff4jKqMI8Xl50/4Mms/9jPobzAV/UK+kXG2XJ/7AqOmxIx8mqfqTIHYxuAnEgJ2AQeBbLnlbmZ5+38Y9A0w/YA==} resolution: {integrity: sha512-ff4jKqMI8Xl50/4Mms/9jPobzAV/UK+kXG2XJ/7AqOmxIx8mqfqTIHYxuAnEgJ2AQeBbLnlbmZ5+38Y9A0w/YA==}
engines: {node: '>=12'} engines: {node: '>=12'}
@ -4856,11 +4797,6 @@ packages:
resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==} resolution: {integrity: sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==}
dev: true dev: true
/web-streams-polyfill@3.2.1:
resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
engines: {node: '>= 8'}
dev: false
/webidl-conversions@3.0.1: /webidl-conversions@3.0.1:
resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=} resolution: {integrity: sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=}
dev: true dev: true

View File

@ -4,20 +4,13 @@ import * as abuseCh from '../ts/index.js';
tap.test('should deal with UrlHouse data', async () => { tap.test('should deal with UrlHouse data', async () => {
const urlHouse = new abuseCh.UrlHouse(); const urlHouse = new abuseCh.UrlHouse();
const data = await urlHouse.getData(); const data = await urlHouse.getData();
console.log(data.length); console.log(data);
}); });
tap.test('should deal with UrlHouse data', async () => { tap.test('should deal with UrlHouse data', async () => {
const threatFox = new abuseCh.ThreatFox(); const threatFox = new abuseCh.ThreatFox();
const data = await threatFox.getData(); const data = await threatFox.getData();
console.log(data.length); console.log(data);
});
tap.test('should deal with FeodoTracker data', async () => {
const feodoTracker = new abuseCh.FeodoTracker();
const data = await feodoTracker.getData();
console.log(data.length);
console.log(data[1]);
}); });
tap.start(); tap.start();

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@apiclient.xyz/abuse.ch', name: '@apiclient.xyz/abuse.ch',
version: '1.0.12', version: '1.0.3',
description: 'an unofficial client to retrieve abuse.ch data' description: 'an unofficial client to retrieve abuse.ch data'
} }

View File

@ -1,52 +0,0 @@
import * as plugins from './plugins.js';
import * as paths from './paths.js';
import * as helpers from './helpers.js';
export interface IFeodoTrackerData {
ip_address: string;
port: number;
status: string;
hostname: string | null;
as_number: number;
as_name: string;
country: string;
first_seen: string;
last_online: string;
malware: string;
}
export class FeodoTracker {
private static readonly FEODO_TRACKER_API_URL: string = 'https://feodotracker.abuse.ch/downloads/ipblocklist.json';
public async getData(): Promise<IFeodoTrackerData[]> {
const response = await plugins.nodeFetch(FeodoTracker.FEODO_TRACKER_API_URL, {
...(helpers.findProxy() ? {
agent: helpers.getAgent(),
} : {})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data: IFeodoTrackerData[] = await response.json() as IFeodoTrackerData[];
// Ensure the data is an array and has the expected structure
if (!Array.isArray(data) || !data.every(item =>
typeof item.ip_address === 'string' &&
typeof item.port === 'number' &&
(typeof item.hostname === 'string' || item.hostname === null) &&
typeof item.as_number === 'number' &&
typeof item.as_name === 'string' &&
typeof item.country === 'string' &&
typeof item.first_seen === 'string' &&
typeof item.last_online === 'string' &&
typeof item.malware === 'string'
)) {
throw new Error(`Invalid data structure!`);
}
return data;
}
}

View File

@ -1,6 +1,5 @@
import * as plugins from './plugins.js'; import * as plugins from './plugins.js';
import * as paths from './paths.js'; import * as paths from './paths.js';
import * as helpers from './helpers.js';
export interface IThreatFoxData { export interface IThreatFoxData {
ID: string; ID: string;
@ -21,11 +20,7 @@ export class ThreatFox {
const zipPath = plugins.path.join(paths.threatFoxTmp, 'threatfox.zip'); const zipPath = plugins.path.join(paths.threatFoxTmp, 'threatfox.zip');
const csvPath = plugins.path.join(paths.threatFoxTmp, 'full.csv'); const csvPath = plugins.path.join(paths.threatFoxTmp, 'full.csv');
const response = await plugins.nodeFetch(ThreatFox.THREATFOX_API_URL, { const response = await fetch(ThreatFox.THREATFOX_API_URL);
...(helpers.findProxy() ? {
agent: helpers.getAgent(),
} : {})
});
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); throw new Error(`HTTP error! status: ${response.status}`);
} }

View File

@ -1,6 +1,5 @@
import * as plugins from './plugins.js'; import * as plugins from './plugins.js';
import * as paths from './paths.js'; import * as paths from './paths.js';
import * as helpers from './helpers.js';
export interface IUrlHouseData { export interface IUrlHouseData {
ID: string; ID: string;
@ -21,11 +20,7 @@ export class UrlHouse {
const zipPath = plugins.path.join(paths.urlHouseTmp, 'urlhaus.zip'); const zipPath = plugins.path.join(paths.urlHouseTmp, 'urlhaus.zip');
const csvPath = plugins.path.join(paths.urlHouseTmp, 'csv.txt'); const csvPath = plugins.path.join(paths.urlHouseTmp, 'csv.txt');
const response = await plugins.nodeFetch(UrlHouse.URLHOUSE_API_URL, { const response = await fetch(UrlHouse.URLHOUSE_API_URL);
...(helpers.findProxy() ? {
agent: helpers.getAgent(),
} : {})
});
if (!response.ok) { if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`); throw new Error(`HTTP error! status: ${response.status}`);
} }

View File

@ -1,8 +0,0 @@
import * as plugins from './plugins.js';
export const findProxy = () => {
return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy
}
export const getAgent = () => {
return new plugins.httpsProxy.HttpsProxyAgent(findProxy());
}

View File

@ -1,3 +1,2 @@
export * from './abuse.ch.classes.feodotracker.js';
export * from './abuse.ch.classes.threatfox.js';
export * from './abuse.ch.classes.urlhouse.js'; export * from './abuse.ch.classes.urlhouse.js';
export * from './abuse.ch.classes.threatfox.js';

View File

@ -5,4 +5,3 @@ export const nogitDir = plugins.path.join(packageDir, '.nogit');
export const urlHouseTmp = plugins.path.join(nogitDir, 'tmp.urlhaus'); export const urlHouseTmp = plugins.path.join(nogitDir, 'tmp.urlhaus');
export const threatFoxTmp = plugins.path.join(nogitDir, 'tmp.threatfox'); export const threatFoxTmp = plugins.path.join(nogitDir, 'tmp.threatfox');
export const feodoTrackerTmp = plugins.path.join(nogitDir, 'tmp.feodotracker');

View File

@ -23,12 +23,3 @@ export {
smartfile, smartfile,
smartpath, smartpath,
} }
// third party
import nodeFetch from 'node-fetch';
import * as httpsProxy from 'https-proxy-agent';
export {
nodeFetch,
httpsProxy,
}