
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
=====================
Regexes are not enough sometimes. We should go all the way and fully parse the email and knock on the server's door to see if they really have a mailbox.
require 'pre'
validator = Pre::Validator.new
validator.valid? "me@apple.com"
Pre by default has built in validators for RFC2822 and DNS MX record verification. Validators can be passed through the :validators
option.
require 'pre'
# validate with no domain validation
validator = Pre::Validator.new :validators => :format
validator.valid? "foo@nonexistent201233.com" # => true
Pre can take blocks for custom validators
require 'pre'
no_gmail = lambda do |address|
address !~ /gmail.com$/
end
validator = Pre::Validator.new :validators => [:format, no_gmail]
validator.valid? "foo@gmail.com" # => false
Pre can take any object that implements the valid? method
require 'pre'
class ComplexValidator
def valid? address
return true unless address =~ /gmail.com$/
# do not allow user+label@gmail.com
address !~ /\+.+@/
end
end
validator = Pre::Validator.new :validators => [:domain, ComplexValidator.new]
validator.valid? "john+spam@gmail.com" # => false
Pre can also take alternate configuration for a single address
require 'pre'
validator = Pre::Validator.new :validators => :format
validator.valid? "john@example.co.uk", :validators => lambda { |address|
address =~ /example.co.nz$/
} # => false
Certain strategies may be more "intense" than others. MX Record lookup and other expensive operations can benefit from providing Pre with a cache store. A cache store must respond to :write(key, val)
and :read(key)
methods. The cache abstraction layer provided by Rails' ActiveSupport::Cache::Store fits this interface.
require 'pre'
memcache = ActiveSupport::Cache::MemCacheStore.new("localhost", "server-downstairs.localnetwork:8229")
validator = Pre::Validator.new :cache_store => memcache
validator.valid? "foo@gmail.com" # => true
The RFC treetop grammars are pulled from the fantastic mail gem.
FAQs
Unknown package
We found that pre 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
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.