Compare commits
No commits in common. "master" and "v1.0.8" have entirely different histories.
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@apiclient.xyz/abuse.ch",
|
"name": "@apiclient.xyz/abuse.ch",
|
||||||
"version": "1.0.12",
|
"version": "1.0.8",
|
||||||
"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",
|
||||||
|
@ -13,11 +13,4 @@ tap.test('should deal with UrlHouse data', async () => {
|
|||||||
console.log(data.length);
|
console.log(data.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
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();
|
||||||
|
@ -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.8',
|
||||||
description: 'an unofficial client to retrieve abuse.ch data'
|
description: 'an unofficial client to retrieve abuse.ch data'
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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';
|
||||||
|
@ -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');
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user