From 87e029f9a30ef8471d0922b37e21fcc9ad4e3d48 Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Sun, 15 Nov 2020 04:32:50 +0100 Subject: [PATCH] fix for some missing ipv6 prefixes (#4) --- package-lock.json | 6 +++--- package.json | 4 ++-- src/csvParser.js | 2 +- src/finder.js | 13 ++++++------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ccca54..866aac7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1851,9 +1851,9 @@ "dev": true }, "bulk-whois-parser": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/bulk-whois-parser/-/bulk-whois-parser-1.0.7.tgz", - "integrity": "sha512-rM81AAhdInvnbZFiJRiCyuv3SN0KO+i+4g4ke+PQ2Atf/PWC7I4E/mqS4ce1DNTwLNPIeIeObNzv4L2rvino1A==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/bulk-whois-parser/-/bulk-whois-parser-1.0.8.tgz", + "integrity": "sha512-LwkrNL5L5CzY4d1UwNOnd58Dwebd7wQddMab0Pk70hhPv41WxNsjuyTiZBxSwz7lFhQIPy6WTVH4xBEqIFck3Q==", "requires": { "axios": "^0.21.0", "batch-promises": "0.0.3", diff --git a/package.json b/package.json index 163507d..6d97c6a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "./build.sh", "compile": "babel src -d dist", "release": "dotenv release-it", - "serve": "babel-node index.js", + "serve": "babel-node src/index.js", "inspect": "node --inspect --require @babel/register index.js", "test": "echo \"Error: no test specified\" && exit 1" }, @@ -46,7 +46,7 @@ "dependencies": { "axios": "^0.20.0", "batch-promises": "0.0.3", - "bulk-whois-parser": "^1.0.7", + "bulk-whois-parser": "^1.0.8", "cli-progress": "^3.8.2", "ip-address": "^6.4.0", "ip-sub": "^1.0.14", diff --git a/src/csvParser.js b/src/csvParser.js index 954e84a..c650407 100644 --- a/src/csvParser.js +++ b/src/csvParser.js @@ -5,7 +5,7 @@ const checkPrefix = (prefix) => { prefix += (ipUtils.getAddressFamily(prefix) === 4) ? "/32" : "/128"; } - return prefix; + return (ipUtils.isValidPrefix(prefix)) ? prefix.toLowerCase() : null; }; class Geofeed { diff --git a/src/finder.js b/src/finder.js index 8fbd508..475c010 100644 --- a/src/finder.js +++ b/src/finder.js @@ -136,11 +136,10 @@ export default class Finder { validateGeofeeds = (geofeeds) => { return geofeeds - .filter(geofeed => - geofeed && - !!geofeed.inetnum && geofeed.inetnum === geofeed.prefix || - ipUtils.isSubnet(geofeed.inetnum, geofeed.prefix) - ); + .filter(geofeed => { + return geofeed && !!geofeed.inetnum && !!geofeed.prefix && + (geofeed.inetnum === geofeed.prefix || ipUtils.isSubnet(geofeed.inetnum, geofeed.prefix)); + }); }; @@ -173,9 +172,9 @@ export default class Finder { // If there is a less specific inetnum contradicting a more specific inetnum // Contradicting here means, the less specific is declaring something in the more specific range if (lessSpecificInetnum.valid && - (moreSpecificInetnumPrefix === lessSpecificInetnumPrefix || ipUtils.isSubnet(lessSpecificInetnumPrefix, moreSpecificInetnumPrefix))) { + (moreSpecificInetnumPrefix === lessSpecificInetnumPrefix || + ipUtils.isSubnet(moreSpecificInetnumPrefix, lessSpecificInetnumPrefix))) { lessSpecificInetnum.valid = false; - // console.log(`WARNING: prefix:${moreSpecificInetnumPrefix} declared in inetnum:${moreSpecificInetnum.inetnum} conflicts with prefix:${lessSpecificInetnumPrefix} declared in inetnum:${lessSpecificInetnum.inetnum}`); } }