Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dnslint

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dnslint - npm Package Compare versions

Comparing version 1.1.11 to 1.1.13

2

dnslint.json

@@ -10,3 +10,3 @@ {

"reverseDNS": {
"enabled": false
"enabled": true
}

@@ -13,0 +13,0 @@ },

{
"name": "dnslint",
"version": "1.1.11",
"version": "1.1.13",
"description": "XYO Internal Domain Tool",

@@ -26,6 +26,6 @@ "main": "src/index.js",

"commander": "^2.19.0",
"deepmerge": "^3.2.0",
"dotenv-expand": "^5.0.0",
"load-json-file": "^5.2.0",
"lodash": "^4.17.11",
"merge": "^1.2.1",
"ts-optchain": "^0.1.3"

@@ -32,0 +32,0 @@ },

@@ -63,3 +63,4 @@ {

"include": [
"^api\\."
"^api\\.",
"^devapi\\."
],

@@ -88,3 +89,3 @@ "records": [

"include": [
"\\._domainkey\\."
"._domainkey."
],

@@ -94,3 +95,9 @@ "records": [

"type": "txt",
"allowed": [1]
"allowed": [1],
"expected": [
{
"required": true,
"value": "^v=DKIM1; k=rsa; "
}
]
}

@@ -97,0 +104,0 @@ ]

import { RecordsConfig } from "./records"
import { RecordConfig } from "./record"
import { stringify } from "querystring"
import _ from 'lodash'
export class DomainConfig {
public name: string
public records?: RecordsConfig = undefined
public enabled = true
public timeout = 1000
public records?: RecordsConfig
public enabled?: boolean
public timeout?: number
constructor(name: string) {
constructor(name: string, init?: any[]) {
this.name = name
if (init) {
for (const obj of init) {
_.merge(this, obj)
}
}
this.records = new RecordsConfig().concat(this.records || [])
}
public getTimeout() {
return this.timeout || 1000
}
public isRecordEnabled(type: string): boolean {

@@ -16,0 +27,0 @@ if (!this.enabled) {

@@ -15,7 +15,5 @@ import { DomainConfig } from "./domain"

public getConfig(domain: string, serverType?: string): DomainConfig {
const result = new DomainConfig(domain)
public getConfig(domain: string): DomainConfig {
const map = this.getMap()
Object.assign(result, map.get("default"))
Object.assign(result, map.get(domain))
const result = new DomainConfig(domain, [map.get("default"), map.get(domain)])
result.name = domain

@@ -22,0 +20,0 @@ return result

@@ -7,3 +7,3 @@ import loadJsonFile from 'load-json-file'

import defaultConfig from './default.json'
import merge from 'merge'
import _ from 'lodash'
import { ServersConfig } from './servers'

@@ -18,6 +18,5 @@ import Ajv from 'ajv'

try {
const defaultJson = await loadJsonFile(`${__dirname}/default.json`)
const ajv = new Ajv({ schemaId: 'id' })
const validate = ajv.compile(schema)
if (!validate(defaultJson)) {
if (!validate(defaultConfig)) {
console.error(chalk.red(`${validate.errors}`))

@@ -28,3 +27,3 @@ } else {

try {
const userJson = await loadJsonFile(filename)
const userJson: object = await loadJsonFile(filename)
if (!validate(userJson)) {

@@ -36,3 +35,8 @@ console.error(chalk.red(`${validate.errors}`))

console.log(chalk.gray("Loaded User Config"))
return new Config(merge.recursive(true, defaultConfig, userJson))
const result = new Config(_.mergeWith(defaultConfig, userJson,
(objValue: any, srcValue: any, key: any, object: any, source: any, stack: any) => {
return undefined
}
))
return result
} catch (ex) {

@@ -49,4 +53,4 @@ console.log(chalk.yellow("No dnslint.json config file found. Using defaults."))

public aws ?: AWS = undefined
public domains ?: DomainsConfig
public servers ?: ServersConfig
public domains?: DomainsConfig
public servers?: ServersConfig

@@ -61,12 +65,61 @@ constructor(config?: any) {

public getRecordConfig(serverType: string, domainName: string, recordType: string) {
public getDomains() {
if (!this.domains) {
this.domains = new DomainsConfig()
}
return this.domains
}
public getServers() {
if (!this.servers) {
this.servers = new ServersConfig()
}
return this.servers
}
public getRecordConfig(domain: string, recordType: string) {
const serverType = this.getServerType(domain)
const result = new RecordConfig(recordType)
if (this.servers !== undefined) {
Object.assign(result, this.servers.getConfig(serverType))
const records = this.servers.getConfig(serverType).records
if (records) {
Object.assign(result, records.getConfig(recordType))
}
}
if (this.domains !== undefined) {
Object.assign(result, this.domains.getConfig(domainName))
const records = this.domains.getConfig(domain).records
if (records) {
Object.assign(result, records.getConfig(recordType))
}
}
return result
}
public getDomainConfig(domain: string) {
const result = new DomainConfig(domain)
if (this.domains !== undefined) {
Object.assign(result, this.domains.getConfig(domain))
}
return result
}
public getServerType(domain: string) {
let defaultName = "unknown"
if (this.servers) {
for (const server of this.servers) {
const include = server.include
if (include) {
for (const filter of include) {
if (domain.match(filter)) {
return server.name
}
if (server.default) {
defaultName = server.name
}
}
}
}
}
return defaultName
}
}

@@ -6,4 +6,4 @@ import { DomainConfig } from "./domain"

public name: string
public type?: string
public enabled?: boolean
public timeout?: number

@@ -15,2 +15,3 @@ public reverseDNS?: {

public allowed?: number[]
public expected?: any[]

@@ -21,6 +22,2 @@ constructor(name: string) {

public getTimeout() {
return this.timeout || 1000
}
public isEnabled() {

@@ -27,0 +24,0 @@ if (this.enabled !== undefined) {

@@ -5,2 +5,10 @@ import { RecordConfig } from './record'

public concat(records: RecordConfig[]): RecordsConfig {
for (const record of records) {
const recordsConfig = Object.assign(new RecordConfig(record.name), record)
this.push(recordsConfig)
}
return this
}
public isEnabled(type: string): boolean {

@@ -7,0 +15,0 @@ const map = this.getMap()

import { RecordsConfig } from "./records"
import _ from 'lodash'

@@ -10,5 +11,11 @@ export class ServerConfig {

constructor(name: string) {
constructor(name: string, init?: any[]) {
this.name = name
if (init) {
for (const obj of init) {
_.merge(this, obj)
}
}
this.records = new RecordsConfig().concat(this.records || [])
}
}
import { ServerConfig } from "./server"
import { RecordsConfig } from "./records"

@@ -19,2 +20,7 @@ export class ServersConfig extends Array <ServerConfig> {

result.name = serverType
// make sure it is a full object
const records = new RecordsConfig()
Object.assign(records, result.records)
result.records = records
return result

@@ -21,0 +27,0 @@ }

@@ -45,3 +45,3 @@ import { AWS } from './aws'

console.log(`Domain:[${completedDomains}/${domains.size}]: ${domain.name} [${domain.serverType}]`)
result.errorCount += await domain.validate(this.config)
result.errorCount += await domain.validate()
} catch (ex) {

@@ -59,32 +59,12 @@ result.errorCount++

private getServerType(domain: string) {
let defaultName = "unknown"
if (this.config.servers) {
for (const server of this.config.servers) {
const include = server.include
if (include) {
for (const filter of include) {
if (domain.match(filter)) {
return server.name
}
if (server.default) {
defaultName = server.name
}
}
}
}
}
return defaultName
}
private createValidator(domain: string) {
switch (this.getServerType(domain)) {
private createDomainValidator(name: string) {
switch (this.config.getServerType(name)) {
case "website":
return new DomainValidatorWebsite({ name: domain })
return new DomainValidatorWebsite(this.config, name)
case "api":
return new DomainValidatorApi({ name: domain })
return new DomainValidatorApi(this.config, name)
case "domainkey":
return new DomainValidatorDomainKey({ name: domain })
return new DomainValidatorDomainKey(this.config, name)
}
return new DomainValidatorWebsite({ name: domain })
return new DomainValidatorWebsite(this.config, name)
}

@@ -98,3 +78,3 @@

for (const domain of awsDomains) {
domains.set(domain, this.createValidator(domain))
domains.set(domain, this.createDomainValidator(domain))
}

@@ -112,3 +92,3 @@ } catch (ex) {

if (domain.name !== "default") {
domains.set(domain.name, this.createValidator(domain.name))
domains.set(domain.name, this.createDomainValidator(domain.name))
}

@@ -115,0 +95,0 @@ }

@@ -26,5 +26,13 @@ {

"type": "array",
"items": {
"items": {}
},
"expected": {
"type": "array",
"items": {
"type": "object",
"properties": {
"required": {"type": "boolean"},
"value": {"type": "string"}
}
}
},

@@ -31,0 +39,0 @@ "addresses": {

import chalk from 'chalk'
import { ValidationError } from './error'
import _ from 'lodash'
import { Config } from '../config'

@@ -8,7 +9,7 @@ export class BaseValidator {

public errors?: ValidationError[]
public valid?: boolean
protected config: any
public errorCount = 0
protected config: Config
constructor(config: {name: string}) {
this.name = config.name
constructor(config: any, name: string) {
this.name = name
this.config = config

@@ -21,13 +22,10 @@ }

public async validate(config: {}) {
public async validate() {
if (this.errors) {
this.valid = false
return this.errors.length
this.errorCount += this.addErrors.length
}
this.valid = true
return 0
return this.errorCount
}
public addError(action: string, error: any) {
this.valid = false
this.errors = this.errors || []

@@ -34,0 +32,0 @@ this.errors.push(new ValidationError(action, error))

import { Config } from '../../config'
import { DomainValidator } from '.'
import { DomainConfig } from '../../config/domain'
export class DomainValidatorApi extends DomainValidator {
constructor(config: {name: string}) {
super({ name: config.name, serverType:"api" })
constructor(config: Config, name: string) {
super(config, name, "api")
}
public async validate(config: Config): Promise<number> {
const recordConfigA = config.getRecordConfig(this.serverType, this.name, "A")
const recordConfigCname = config.getRecordConfig(this.serverType, this.name, "CNAME")
const recordConfigMx = config.getRecordConfig(this.serverType, this.name, "MX")
const recordConfigTxt = config.getRecordConfig(this.serverType, this.name, "TXT")
public async validate(): Promise<number> {
const recordConfigA = this.config.getRecordConfig(this.name, "A")
const recordConfigCname = this.config.getRecordConfig(this.name, "CNAME")
const recordConfigMx = this.config.getRecordConfig(this.name, "MX")
const recordConfigTxt = this.config.getRecordConfig(this.name, "TXT")
if (recordConfigA.isEnabled()) {
this.records = this.records.concat(
await this.validateA(
{ resolve: true, timeout: recordConfigA.getTimeout() }
))
await this.validateA()
)
}
if (recordConfigCname.isEnabled()) {
this.records = this.records.concat(
await this.validateCname(
{ resolve: false, timeout: recordConfigCname.getTimeout() }
))
await this.validateCname()
)
}

@@ -34,3 +33,3 @@ if (recordConfigMx.isEnabled()) {

}
return super.validate(config)
return super.validate()
}

@@ -37,0 +36,0 @@

import { Config } from '../../config'
import { DomainValidator } from '.'
import { DomainConfig } from '../../config/domain'
export class DomainValidatorDomainKey extends DomainValidator {
constructor(config: {name: string}) {
super({ name: config.name, serverType: "domainkey" })
constructor(config: Config, name: string) {
super(config, name, "domainkey")
}
public async validate(config: Config): Promise<number> {
const recordConfigA = config.getRecordConfig(this.serverType, this.name, "A")
const recordConfigCname = config.getRecordConfig(this.serverType, this.name, "CNAME")
const recordConfigMx = config.getRecordConfig(this.serverType, this.name, "MX")
const recordConfigTxt = config.getRecordConfig(this.serverType, this.name, "TXT")
public async validate(): Promise<number> {
const recordConfigA = this.config.getRecordConfig(this.name, "A")
const recordConfigCname = this.config.getRecordConfig(this.name, "CNAME")
const recordConfigMx = this.config.getRecordConfig(this.name, "MX")
const recordConfigTxt = this.config.getRecordConfig(this.name, "TXT")
if (recordConfigA.isEnabled()) {
this.records = this.records.concat(
await this.validateA(
{ resolve: true, timeout: recordConfigA.getTimeout() }
))
await this.validateA()
)
}
if (recordConfigCname.isEnabled()) {
this.records = this.records.concat(
await this.validateCname(
{ resolve: false, timeout: recordConfigCname.getTimeout() }
))
await this.validateCname()
)
}

@@ -34,3 +33,3 @@ if (recordConfigMx.isEnabled()) {

}
return super.validate(config)
return super.validate()
}

@@ -37,0 +36,0 @@

@@ -11,2 +11,4 @@ import { RecordValidatorA } from '../record/a'

import _ from 'lodash'
import { RecordConfig } from '../../config/record'
import { DomainConfig } from '../../config/domain'

@@ -17,30 +19,26 @@ export class DomainValidator extends BaseValidator {

constructor(config: {name: string, serverType: string}) {
super({ name: config.name })
this.serverType = config.serverType
constructor(config: Config, name: string, serverType: string) {
super(config, name)
this.name = name
this.serverType = serverType
}
public async validate(config: Config): Promise<number> {
let errorCount = 0
const recordConfigA = config.getRecordConfig(this.serverType, this.name, "A")
const recordConfigMx = config.getRecordConfig(this.serverType, this.name, "MX")
const recordConfigTxt = config.getRecordConfig(this.serverType, this.name, "TXT")
public async validate(): Promise<number> {
const recordConfigA = this.config.getRecordConfig(this.name, "A")
const recordConfigMx = this.config.getRecordConfig(this.name, "MX")
const recordConfigTxt = this.config.getRecordConfig(this.name, "TXT")
try {
if (recordConfigA.isEnabled()) {
const record = await this.validateA(
{ resolve: true, timeout: recordConfigA.getTimeout() }
)
const record = await this.validateA()
this.records = this.records.concat(record)
for (const item of record) {
errorCount += await item.validate({ timeout: recordConfigA.getTimeout() })
this.errorCount += await item.validate()
}
}
const recordConfigCname = config.getRecordConfig(this.serverType, this.name, "CNAME")
const recordConfigCname = this.config.getRecordConfig(this.name, "CNAME")
if (recordConfigCname.isEnabled()) {
const record = await this.validateCname(
{ resolve: true, timeout: recordConfigCname.getTimeout() }
)
const record = await this.validateCname()
this.records = this.records.concat(record)
for (const item of record) {
errorCount += await item.validate({ timeout: recordConfigCname.getTimeout() })
this.errorCount += await item.validate()
}

@@ -52,3 +50,3 @@ }

for (const item of record) {
errorCount += await item.validate({ timeout: recordConfigMx.getTimeout() })
this.errorCount += await item.validate()
}

@@ -60,3 +58,3 @@ }

for (const item of record) {
errorCount += await item.validate({ timeout: recordConfigTxt.getTimeout() })
this.errorCount += await item.validate()
}

@@ -66,9 +64,8 @@ }

if (this.errors) {
errorCount += this.errors.length
this.errorCount += this.errors.length
}
if (errorCount === 0) {
if (this.errorCount === 0) {
console.log(chalk.green(`${this.name}: OK`))
} else {
this.addError("validate", `Errors Detected[${this.name}]: ${errorCount}`)
console.error(chalk.red(`${this.name}: ${errorCount} Errors`))
console.error(chalk.red(`${this.name}: ${this.errorCount} Errors`))
}

@@ -78,6 +75,3 @@ } catch (ex) {

}
if (this.errors) {
return this.errors.length + errorCount
}
return super.validate(config)
return super.validate()
}

@@ -101,3 +95,3 @@

protected async validateA(config: {resolve: boolean, timeout: number}) {
protected async validateA() {
const validators: RecordValidatorA[] = []

@@ -107,3 +101,3 @@ try {

for (const record of records) {
const validator = new RecordValidatorA(_.merge({ name: this.name, value: record }, this.config))
const validator = new RecordValidatorA(this.config, this.name, record)
validators.push(validator)

@@ -117,3 +111,3 @@ }

protected async validateCname(config: {resolve: boolean, timeout: number}) {
protected async validateCname() {
const validators: RecordValidatorCname[] = []

@@ -123,3 +117,3 @@ try {

for (const record of records) {
const validator = new RecordValidatorCname(_.merge({ name: this.name, value: record }, this.config))
const validator = new RecordValidatorCname(this.config, this.name, record)
validators.push(validator)

@@ -138,3 +132,3 @@ }

for (const record of records) {
const validator = new RecordValidatorMx({ name: this.name, value: record })
const validator = new RecordValidatorMx(this.config, this.name, record)
validators.push(validator)

@@ -153,3 +147,3 @@ }

for (const record of records) {
const validator = new RecordValidatorTxt({ name: this.name, value: record })
const validator = new RecordValidatorTxt(this.config, this.name, record)
validators.push(validator)

@@ -156,0 +150,0 @@ }

import { Config } from '../../config'
import { DomainValidator } from '.'
import { DomainConfig } from '../../config/domain'
export class DomainValidatorWebsite extends DomainValidator {
constructor(config: {name: string}) {
super({ name: config.name, serverType: "website" })
constructor(config: Config, name: string) {
super(config, name, "website")
}
public async validate(config: Config): Promise<number> {
const recordConfigA = config.getRecordConfig(this.serverType, this.name, "A")
const recordConfigCname = config.getRecordConfig(this.serverType, this.name, "CNAME")
const recordConfigMx = config.getRecordConfig(this.serverType, this.name, "MX")
const recordConfigTxt = config.getRecordConfig(this.serverType, this.name, "TXT")
public async validate(): Promise<number> {
const recordConfigA = this.config.getRecordConfig(this.name, "A")
const recordConfigCname = this.config.getRecordConfig(this.name, "CNAME")
const recordConfigMx = this.config.getRecordConfig(this.name, "MX")
const recordConfigTxt = this.config.getRecordConfig(this.name, "TXT")
if (recordConfigA.isEnabled()) {
this.records = this.records.concat(
await this.validateA(
{ resolve: true, timeout: recordConfigA.getTimeout() }
))
await this.validateA())
}
if (recordConfigCname.isEnabled()) {
this.records = this.records.concat(
await this.validateCname(
{ resolve: false, timeout: recordConfigCname.getTimeout() }
))
await this.validateCname())
}

@@ -34,3 +31,3 @@ if (recordConfigMx.isEnabled()) {

}
return super.validate(config)
return super.validate()
}

@@ -37,0 +34,0 @@

import { RecordValidator } from './base'
import { Config } from '../../config'
import { RecordConfig } from '../../config/record'

@@ -8,17 +9,22 @@ export class RecordValidatorA extends RecordValidator {

constructor(config: { name: string, value: string }) {
super({ name: config.name, type: "A" })
this.value = config.value
constructor(config: Config, name: string, value: string) {
super(config, name, "A")
this.value = value
}
public async validate(config: { timeout: number }) {
public async validate() {
try {
this.http = await this.checkHttp(this.value, this.name, config.timeout)
this.https = await this.checkHttps(this.value, this.name, config.timeout)
this.reverseDns = await this.reverseLookup(this.value, this.name, config.timeout)
const domainConfig = this.config.getDomainConfig(this.name)
const recordConfig = this.getRecordConfig()
const timeout = domainConfig.getTimeout()
this.http = await this.checkHttp(this.value, this.name, timeout)
this.https = await this.checkHttps(this.value, this.name, timeout)
if (recordConfig.reverseDNS) {
this.reverseDns = await this.reverseLookup(this.value, this.name, timeout)
}
} catch (ex) {
this.addError("validate", `Unexpected Error[${this.name}]: ${ex}`)
}
return super.validate(config)
return super.validate()
}
}

@@ -7,2 +7,3 @@ import { BaseValidator } from '../base'

import chalk from 'chalk'
import { RecordConfig } from '../../config/record'
export class RecordValidator extends BaseValidator {

@@ -16,7 +17,11 @@

constructor(config: { name: string, type: string }) {
super(config)
this.type = config.type
constructor(config: Config, name: string, type: string) {
super(config, name)
this.type = type
}
public getRecordConfig() {
return this.config.getRecordConfig(this.name, this.type)
}
protected async checkHttp(ip: string, hostname: string, timeout: number) {

@@ -23,0 +28,0 @@ try {

import { RecordValidator } from './base'
import { Config } from '../../config'
import { DNS } from '../../dns'
import { RecordConfig } from '../../config/record'

@@ -9,15 +10,19 @@ export class RecordValidatorCname extends RecordValidator {

constructor(config: {name: string, value: string, resolve: boolean, timeout: number}) {
super({ name: config.name, type: "CNAME" })
this.value = config.value
config.timeout = config.timeout || 1000
constructor(config: Config, name: string, value: string) {
super(config, name, "CNAME")
this.value = value
}
public async validate(config: { timeout: number }) {
public async validate(resolve: boolean = true) {
try {
const domainConfig = this.config.getDomainConfig(this.name)
const recordConfig = this.getRecordConfig()
const timeout = domainConfig.getTimeout()
const ip = await DNS.lookup(this.value)
if (ip && this.config.resolve) {
this.http = await this.checkHttp(ip, this.name, this.config.timeout)
this.https = await this.checkHttps(ip, this.name, this.config.timeout)
this.reverseDns = await this.reverseLookup(ip, this.name, this.config.timeout)
if (ip && resolve) {
this.http = await this.checkHttp(ip, this.name, timeout)
this.https = await this.checkHttps(ip, this.name, timeout)
if (recordConfig.reverseDNS) {
this.reverseDns = await this.reverseLookup(ip, this.name, timeout)
}
}

@@ -27,4 +32,4 @@ } catch (ex) {

}
return super.validate(config)
return super.validate()
}
}

@@ -5,2 +5,3 @@ import { RecordValidator } from './base'

import { RecordValidatorTxt } from './txt'
import { RecordConfig } from '../../config/record'

@@ -10,12 +11,19 @@ export class RecordValidatorDmarc extends RecordValidator {

public value: string[]
public missing: string[]
public missing: string[] = []
public found: string[] = []
constructor(config: { name: string, value: string[], expected: string[] }) {
super({ name: config.name, type: "TXT(DMARC)" })
this.value = config.value
this.missing = config.expected
constructor(config: Config, name: string, value: string[]) {
super(config, name, "TXT(DMARC)")
this.value = value
const recordConfig = this.getRecordConfig()
if (recordConfig.expected) {
for (const exp of recordConfig.expected) {
if (exp.required) {
this.missing.push(exp.value)
}
}
}
}
public async validate(config: {timeout: number}) {
public async validate() {
try {

@@ -43,3 +51,3 @@ for (let i = 1; i < this.value.length; i++) {

}
return super.validate(config)
return super.validate()
}

@@ -46,0 +54,0 @@

@@ -5,2 +5,3 @@ import { RecordValidator } from './base'

import { MxRecord } from 'dns'
import { RecordConfig } from '../../config/record'

@@ -11,8 +12,8 @@ export class RecordValidatorMx extends RecordValidator {

constructor(config: {name: string, value: MxRecord}) {
super({ name: config.name, type:"MX" })
this.value = config.value
constructor(config: Config, name: string, value: MxRecord) {
super(config, name, "MX")
this.value = value
}
public async validate(config: { timeout: number }) {
public async validate() {
try {

@@ -67,4 +68,4 @@ switch (this.value.exchange) {

}
return super.validate(config)
return super.validate()
}
}

@@ -5,2 +5,3 @@ import { RecordValidator } from './base'

import { RecordValidatorTxt } from './txt'
import { RecordConfig } from '../../config/record'

@@ -10,12 +11,19 @@ export class RecordValidatorSpf extends RecordValidator {

public value: string[]
public missing: string[]
public missing: string[] = []
public found: string[] = []
constructor(config: {name: string, value: string[], expected: string[]}) {
super({ name: config.name, type: "TXT(SPF)" })
this.value = config.value
this.missing = config.expected
constructor(config: Config, name: string, value: string[]) {
super(config, name, "TXT(SPF)")
this.value = value
const recordConfig = this.getRecordConfig()
if (recordConfig.expected) {
for (const exp of recordConfig.expected) {
if (exp.required) {
this.missing.push(exp.value)
}
}
}
}
public async validate(config: {timeout: number}) {
public async validate() {
try {

@@ -43,3 +51,3 @@ for (let i = 1; i < this.value.length; i++) {

}
return super.validate(config)
return super.validate()
}

@@ -46,0 +54,0 @@

@@ -7,2 +7,3 @@ import { RecordValidator } from './base'

import { RecordValidatorDmarc } from './dmarc'
import { RecordConfig } from '../../config/record'

@@ -16,8 +17,8 @@ export class RecordValidatorTxt extends RecordValidator {

constructor(config: {name: string, value: string[]}) {
super({ name: config.name, type: "TXT" })
this.value = config.value
constructor(config: Config, name: string, value: string[]) {
super(config, name, "TXT")
this.value = value
}
public async validate(config: {timeout: number}) {
public async validate() {
try {

@@ -28,10 +29,4 @@ const spaceSplit = this.value[0].split(" ")

case "v=DMARC1;": {
const validateDmarc = new RecordValidatorDmarc({name: this.name, value: this.value, expected: [
"p=none;",
"adkim=r;",
"aspf=r;",
"pct=100;",
"sp=none;"
]})
await validateDmarc.validate(config)
const validateDmarc = new RecordValidatorDmarc(this.config, this.name, this.value)
await validateDmarc.validate()
this.addErrors(validateDmarc.errors)

@@ -41,6 +36,4 @@ break

case "k=rsa;": {
const validateDmarc = new RecordValidatorDmarc({name: this.name, value: this.value, expected: [
"t=s;"
]})
await validateDmarc.validate(config)
const validateDmarc = new RecordValidatorDmarc(this.config, this.name, this.value)
await validateDmarc.validate()
this.addErrors(validateDmarc.errors)

@@ -50,7 +43,4 @@ break

case "v=spf1": {
const validateSpf = new RecordValidatorSpf({name: this.name, value: this.value, expected: [
"include:mail.zendesk.com",
"include:_spf.google.com"
]})
await validateSpf.validate(config)
const validateSpf = new RecordValidatorSpf(this.config, this.name, this.value)
await validateSpf.validate()
this.addErrors(validateSpf.errors)

@@ -88,4 +78,4 @@ break

}
return super.validate(config)
return super.validate()
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc