mailshield 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/mailshield/version.rb +5 -0
- data/lib/mailshield.rb +64 -0
- metadata +50 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b14ffd727fa0a54fbce427772f17317f28743bdcd87ec2f204bf89fc25530f3e
|
4
|
+
data.tar.gz: 6e593d1bac55e212d43d875692a2ae9d6ae10a451409e779f188531849bdac78
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7bff616725f5ee9c1ea1d8cf49777ad6a0e83915bf1e48639e771785b84df7e0cd3db9f55aa7093477cee93fdaf93c241c3b475d3c159f1dd31cfb95afbf7ce4
|
7
|
+
data.tar.gz: acd38d78a78e94edf2df0e8f17b5debe32aca7ce17d2657df69323ff9909fa4c72f2f9d3023c3a937f535a12242525fc9ebf54209159fcacf5790b9ccb5e3fc7
|
data/lib/mailshield.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "mailshield/version"
|
4
|
+
require 'resolv'
|
5
|
+
|
6
|
+
module MailShield
|
7
|
+
class DomainChecker
|
8
|
+
TEMP_DOMAINS = %w[mailinator.com tempmail.com guerrillamail.com].freeze # If any one want to contribute, please add the known more domains here.
|
9
|
+
|
10
|
+
def self.temporary_email?(email)
|
11
|
+
domain = extract_domain(email)
|
12
|
+
return true if known_temp_domain?(domain)
|
13
|
+
|
14
|
+
mx_records = fetch_mx_records(domain)
|
15
|
+
return true if suspicious_mx_records?(mx_records)
|
16
|
+
|
17
|
+
return true unless spf_record?(domain)
|
18
|
+
return true unless dmarc_record?(domain)
|
19
|
+
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.extract_domain(email)
|
24
|
+
email.split('@').last.downcase
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.known_temp_domain?(domain)
|
28
|
+
TEMP_DOMAINS.include?(domain)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.fetch_mx_records(domain)
|
32
|
+
Resolv::DNS.open do |dns|
|
33
|
+
mx_records = dns.getresources(domain, Resolv::DNS::Resource::IN::MX)
|
34
|
+
mx_records.map(&:exchange).map(&:to_s)
|
35
|
+
end
|
36
|
+
rescue Resolv::ResolvError
|
37
|
+
[]
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.suspicious_mx_records?(mx_records)
|
41
|
+
suspicious_patterns = [/mailinator/, /tempmail/, /guerrillamail/]
|
42
|
+
mx_records.any? { |mx| suspicious_patterns.any? { |pattern| mx.match?(pattern) } }
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.spf_record?(domain)
|
46
|
+
spf_records = fetch_txt_records(domain)
|
47
|
+
spf_records.any? { |record| record.include?('v=spf1') }
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.dmarc_record?(domain)
|
51
|
+
dmarc_records = fetch_txt_records("_dmarc.#{domain}")
|
52
|
+
dmarc_records.any? { |record| record.include?('v=DMARC1') }
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.fetch_txt_records(domain)
|
56
|
+
Resolv::DNS.open do |dns|
|
57
|
+
records = dns.getresources(domain, Resolv::DNS::Resource::IN::TXT)
|
58
|
+
records.map(&:data)
|
59
|
+
end
|
60
|
+
rescue Resolv::ResolvError
|
61
|
+
[]
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mailshield
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jana
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-08-25 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: MailShield helps secure your application by identifying temporary or
|
14
|
+
disposable email domains.
|
15
|
+
email:
|
16
|
+
- shanmugamjanarthan24@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/mailshield.rb
|
22
|
+
- lib/mailshield/version.rb
|
23
|
+
homepage: https://github.com/janarthanan-shanmugam/mailshield
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata:
|
27
|
+
allowed_push_host: https://rubygems.org
|
28
|
+
homepage_uri: https://github.com/janarthanan-shanmugam/mailshield
|
29
|
+
source_code_uri: https://github.com/janarthanan-shanmugam/mailshield
|
30
|
+
changelog_uri: https://github.com/janarthanan-shanmugam/mailshield
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.5'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubygems_version: 3.5.11
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: A gem to detect temporary or disposable email domains.
|
50
|
+
test_files: []
|