Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Fix redos #2

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/dns-sync.js
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@
var util = require('util'),
path = require('path'),
shell = require('shelljs'),
isValidHostName = require('is-valid-hostname'),
debug = require('debug')('dns-sync');

//source - http://stackoverflow.com/questions/106179/regular-expression-to-match-dns-hostname-or-ip-address
var ValidHostnameRegex = new RegExp("^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$");

// https://nodejs.org/api/dns.html#dns_dns_resolve_hostname_rrtype_callback
var RRecordTypes = [
'A',
@@ -22,9 +20,6 @@ var RRecordTypes = [
'TXT',
'ANY'];

function isValidHostName(hostname) {
return ValidHostnameRegex.test(hostname);
}
/**
* Resolve hostname to IP address,
* returns null in case of error
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -22,11 +22,12 @@
"readmeFilename": "README.md",
"dependencies": {
"debug": "^4",
"is-valid-hostname": "^0.0.1",
"shelljs": "~0.8"
},
"devDependencies": {
"mocha": "^6",
"eslint": "^6",
"eslint-plugin-standard": "^4"
"eslint-plugin-standard": "^4",
"mocha": "^6"
}
}