
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
MissingValidators is a collection of custom validators that are often required in Rails applications plus shoulda-style RSpec matchers to test the validation rules.
Add this line to your application's Gemfile:
gem 'missing_validators'
And then execute:
$ bundle
Or install it yourself as:
$ gem install missing_validators
With an ActiveRecord model:
class User < ActiveRecord::Base
attr_accessor :email, :name
validates :email, email: true
end
Or any ruby class:
class User
include ActiveModel::Validations
attr_accessor :email, :name
validates :email, email: true
end
You can specify domains to which the email domain should belong in one of the folowing ways:
validates :email, email: { domains: '.com' }
validates :email, email: { domains: 'example.org' }
validates :email, email: { domains: ['.com', '.edu', 'example.org'] }
Please note that if a domain is specified as a sting starting with "." (for example, ".com") then the valid values should be in the subdomains of this domain (for example, "email@example.com" or "user@subdomain.example.com"). If a domain is specified without leading "." (for example, "example.org"), then the valid values should be in this domain only (for example, "user@example.org" or "email@example.org", but not "email@subdomain.example.org").
RSpec matcher is also available for your convenience:
describe User do
it { should ensure_valid_email_format_of(:email) }
end
With an ActiveRecord model:
class User < ActiveRecord::Base
attr_accessor :blog, :name
validates :blog, url: true
end
Or any ruby class:
class User
include ActiveModel::Validations
attr_accessor :blog, :name
validates :blog, url: true
end
You can specify domains to which the URL domain should belong in one of the folowing ways:
validates :url, url: { domains: 'com' }
validates :url, url: { domains: :com }
validates :url, url: { domains: [:com, 'edu'] }
You can specify if the URL should the site root:
validates :url, url: { root: true }
You can specify the URL scheme:
validates :url, url: { scheme: :http }
validates :url, url: { scheme: [:http, 'https'] }
RSpec matcher is also available for your convenience:
describe User do
it { should ensure_valid_url_format_of(:url) }
end
With an ActiveRecord model:
class Flight < ActiveRecord::Base
attr_accessor :origin, :destination
validates :origin, inequality: { to: ->(o) { o.destination } }
end
Or any ruby class:
class Flight
include ActiveModel::Validations
attr_accessor :origin, :destination
validates :origin, inequality: { to: ->(o) { o.destination } }
end
Ensures that MAC address is in one of the following formats:
'08:00:2b:01:02:03'
'08-00-2b-01-02-03'
'08002b:010203'
'08002b-010203'
'0800.2b01.0203'
'08002b010203'
With an ActiveRecord model:
class Device < ActiveRecord::Base
attr_accessor :mac
validates :mac, mac_address: true
end
Or any ruby class:
class Device
include ActiveModel::Validations
attr_accessor :mac
validates :mac, mac_address: true
end
RSpec matcher is also available for your convenience:
describe Device do
it { should ensure_valid_mac_address_format_of }
end
Ensures that IP address is in the correct format:
'192.168.0.10'
With an ActiveRecord model:
class Host < ActiveRecord::Base
attr_accessor :ip
validates :ip, ip_address: true
end
Or any ruby class:
class Host
include ActiveModel::Validations
attr_accessor :ip
validates :ip, ip_address: true
end
RSpec matcher is also available for your convenience:
describe Host do
it { should ensure_valid_ip_address_format_of }
end
Ensures that the color is a hexadecimal value starting with '#':
With an ActiveRecord model:
class Widget < ActiveRecord::Base
attr_accessor :color
validates :color, color: true
end
Or any ruby class:
class Widget
include ActiveModel::Validations
attr_accessor :color
validates :color, color: true
end
RSpec matcher is not available yet.
Ensures that IMEI is in one of the following formats:
'356843052637512'
'35-6843052-637512'
'35.6843052.637512'
and its check digit is correct.
With an ActiveRecord model:
class Phone < ActiveRecord::Base
attr_accessor :imei
validates :imei, imei: true
end
Or any ruby class:
class Phone
include ActiveModel::Validations
attr_accessor :imei
validates :imei, imei: true
end
RSpec matcher is also available for your convenience:
describe Phone do
it { should ensure_valid_imei_format_of }
end
Ensures that the value is between -90 and 90:
With an ActiveRecord model:
class Coordinate < ActiveRecord::Base
attr_accessor :latitude
validates :latitude, latitude: true
end
Or any ruby class:
class Coordinate
include ActiveModel::Validations
attr_accessor :latitude
validates :latitude, latitude: true
end
RSpec matcher is not available yet.
Ensures that the value is between -180 and 180:
With an ActiveRecord model:
class Coordinate < ActiveRecord::Base
attr_accessor :longitude
validates :longitude, longitude: true
end
Or any ruby class:
class Coordinate
include ActiveModel::Validations
attr_accessor :longitude
validates :longitude, longitude: true
end
RSpec matcher is not available yet.
Your contribution is welcome.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that missing_validators 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.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.