Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// bypass auth'ed or relay'ing hosts if told to
const skip_reason = exports.skip_hosts(connection);
if (skip_reason) {
connection.results.add(plugin, {skip: `helo(${skip_reason})`});
return next();
}
// Bypass private IPs
if (connection.remote.is_private) {
connection.results.add(plugin, {skip: 'helo(private_ip)'});
return next();
}
// RFC 4408, 2.1: "SPF clients must be prepared for the "HELO"
// identity to be malformed or an IP address literal.
if (net_utils.is_ip_literal(helo)) {
connection.results.add(plugin, {skip: 'helo(ip_literal)'});
return next();
}
// avoid 2nd EHLO evaluation if EHLO host is identical
const results = connection.results.get(plugin);
if (results && results.domain === helo) return next();
let timeout = false;
const spf = new SPF();
const timer = setTimeout(() => {
timeout = true;
connection.loginfo(plugin, 'timeout');
return next();
}, plugin.cfg.lookup_timeout * 1000);
exports.get_domain = function (hook, connection, params) {
switch (hook) {
case 'connect':
if (!connection.remote.host) return;
if (connection.remote.host === 'DNSERROR') return;
if (connection.remote.host === 'Unknown') return;
return connection.remote.host;
case 'helo':
case 'ehlo':
if (net_utils.is_ip_literal(params)) return;
return params;
case 'mail':
case 'rcpt':
if (params && params[0]) {
return params[0].host;
}
}
return;
};
exports.big_company = function (next, connection, helo) {
const plugin = this;
if (plugin.should_skip(connection, 'big_company')) { return next(); }
if (net_utils.is_ip_literal(helo)) {
connection.results.add(plugin, {skip: 'big_co(literal)'});
return next();
}
if (!plugin.cfg.bigco) {
connection.results.add(plugin, {err: 'big_co(config missing)'});
return next();
}
if (!plugin.cfg.bigco[helo]) {
connection.results.add(plugin, {pass: 'big_co(not)'});
return next();
}
const rdns = connection.remote.host;
if (!rdns || rdns === 'Unknown' || rdns === 'DNSERROR') {