Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This gem adds the capability of validating URLs to ActiveRecord and ActiveModel.
Add this to your Gemfile
:
gem "validate_url"
Or install it yourself:
sudo gem install validate_url
class Pony < ActiveRecord::Base
# standard validation
validates :homepage, url: true
# with allow_nil
validates :homepage, url: { allow_nil: true }
# with allow_blank
validates :homepage, url: { allow_blank: true }
# without local hostnames
validates :homepage, url: { no_local: true }
# with custom schemes
validates :homepage, url: { schemes: ['https'] }
# with public suffix database https://publicsuffix.org/
validates :homepage, url: { public_suffix: true }
# with Postgres array of urls, described [here](https://guides.rubyonrails.org/active_record_postgresql.html#array)
validates :homepage, url: { accept_array: true }
end
class Unicorn
include ActiveModel::Validations
attr_accessor :homepage
# with legacy syntax (the syntax above works also)
validates_url :homepage, allow_blank: true
end
Require the matcher in spec_helper.rb
or rails_helper.rb
:
require 'validate_url/rspec_matcher'
In your spec:
RSpec.describe Unicorn
it { is_expected.to validate_url_of(:homepage) }
end
The default error message is not a valid URL
.
You can pass the message: "my custom error"
option to your validation to define your own, custom message.
Big thanks to Tanel Suurhans, Tarmo Lehtpuu, Steve Smith and all the contributors! We appreciate all your work on new features and bugfixes.
Validates URL is created and maintained by PerfectLine, LLC.
Validates URL is Copyright © 2010-2014 PerfectLine, LLC. It is free software, and may be redistributed under the terms specified in the LICENSE file.
rake version:bump:patch
rake gemspec
Manually update validate_url.gemspec
to remove incorrect strings.
gem build validate_url.gemspec
gem push validate_url-1.0.8.gem
FAQs
Unknown package
We found that validate_url demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.