Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Dnsaur is a simple DNS checker / email corrector for ruby. This gem does three things; when a user misspells a domain, it suggests the right spelling, it provide simple reverse DNS helper methods to help verifiy these emails, and splits emails into three parts(top level domain, domain, address).
The email suggestion part of the gem is based off a small javascript library called mailcheck.js. If you are looking for a more front end solution for correcting email input, I suggest checking this out.
When your user types in "user@hotnail.con", Dnsaur will suggest "user@hotmail.com". It can also suggest top level domains, where a user types "user@hotmail.cmo" and would suggest ".com"
It does this by comparing a list of popular default domains and defualt top level domains suplied to the gem.
Dnsaur can be used ether as an instance or as class methods. When creating an instance you need to supply it with email,
email = "test@example.com"
dns = Dnsaur.new email
=> #<Dnsaur:0x007fb8ea17d590 @original_email="test@example.com", ...
custom domains and/or custom top level domains are optional.
For more information on custom domain, see the Domains
section below.
In the suggest method, you can pass an email and it will return a suggested email in a hash example:
# Class Methods
email = "test@hotnail.con"
Dnsaur.suggest email
=>
{
address: 'test', // the address; part before the @ sign
domain: 'hotmail.com', // the suggested domain
top_level_domain: 'com', // the suggested top level domain
full: 'test@hotmail.com' // the full suggested email
}
If there is no match, or it is an exact match to a defualt domain, it will return false.
The DNS lookup for this gem uses Resolv
from the ruby stdlib, but I supplied class/instanced helper methods
for ease of use. If you have an instances of the class, it
#Class Methods
email = "test@example.com"
Dnsaur.valid_dns? email
=> true || false
#Instant Methods
email = "test@hotnail.com"
dns = Dnsaur.new email
dns.valid_original_dns?
=> true || false
dns.valid_suggested_email?
=> true || false
The split_email method is used to split the email into three parts
email = "test@exmaple.com"
Dnsaur.split_email email
{
top_level_domain: 'com', // the top level domain
domain: 'example.com', // the domain
address: 'test' // the address; part before the @ sign
}
Just like mailcheck.js, you can and should give Dnsaur a custom list of domains/top level domains that your user will most likely use to sign up.
This can be done in two different way, ether by giving a completly new list and passing it into and instance:
email = "test@example.com"
domains = ['customdomain.com', 'anotherdomain.net']
top_level_domains = ['com.au', 'ru']
Dnsaur.default_domains = domains
Dnsaur.default_top_level_domains = top_level_domains
Dnsaur.default_domains
=> ["customdomain.com", "anotherdomain.net"]
Dnsaur.default_top_level_domains
=> ["com.au", "ru"]
Or if you want to just add values to the default domains provided, you can pushing new values into the class constants:
Dnsaur.default_domains.push('customdomain.com', 'anotherdomain.net')
Dnsaur.default_top_level_domains.push('com.au', 'ru')
default_domains
and default_top_level_domains
are class members, with one change, all other instances of your class will have your custom list of domains
Add this line to your application's Gemfile:
gem 'dnsaur'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dnsaur
There is still alot of polish that I would like to do to the code in this gem, and I would also like to add some more functionality for validating emails:
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that dnsaur demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.