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.
A simple PESEL (polish personal ID number) validator (ActiveModel based), generator and personal data extractor.
Activepesel library is available as a gem. In your Gemfile add:
gem 'activepesel'
class User < ActiveRecord::Base
# you have to explicitly include it since version 0.2.0
include Activepesel::PeselAttr
# let's say we have dads_pesel and mums_pesel columns in the database
# this will give the access to methods:
# dads_pesel_personal_data, mums_pesel_personal_data
pesel_attr :dads_pesel, :mums_pesel
# keep in mind that pesel validator is not performing a presence test
# so you need another (standard) validation for this one
validates :dads_pesel, presence: true
validates :dads_pesel, pesel: true
validates :mums_pesel, pesel: true
# pesel validator returns standard rails :invalid key error message
end
When using attr_pesel :name_of_attr
in your model you will get new instance method available: name_of_attr_personal_data
.
The method returns Activepesel::PersonalData
object which has the following attributes:
date_of_birth: Date
sex: Integer
See the example:
User.find(1).dads_pesel_personal_data => Activepesel::PersonalData(...)
Sex attribute can take 3 values. 1 - for men, 2 - for women, 9 - not applicable (ISO/IEC 5218)
For the invalid PESEL numbers the date_of_birth
attribute is set to nil
and the sex
is 9 - not applicable.
It is a common practice that you'd want to save the personal data extracted from the PESEL number to be able for example to query your records against all female persons. To do this you can do something like this:
class User < ActiveRecord::Base
include Activepesel::PeselAttr
pesel_attr :pesel
validates :pesel, pesel: true
# we all don't like callbacks but for the sake of this simple example we can live with it
before_save :set_personal_data
private
def set_personal_data
self.date_of_birth = pesel_personal_data.date_of_birth
self.sex = pesel_personal_data.sex
end
end
You can use it like in the given example
pesel = Activepesel::Pesel.new('82060202039')
pesel.valid? => true
pesel.personal_data => Activepesel::PersonalData(...)
# or even quicker
pesel.date_of_birth => Wed, 02 Jun 1982
pesel.sex => 1
Since version 0.1.0 you can generate valid PESEL numbers for a given date of birth and sex of a person.
To generate one randomly picked PESEL number for let's say a male born on November 3rd 1975:
# picks one random number for the given personal data
Activepesel::Pesel.generate_one(sex: 1, date_of_birth: Date.new(1975,11,3))
To generate all (5000) PESEL numbers valid for a person of a given sex and date of birth for example a female born on May 20th 2010:
# returns all possible numbers for the given personal data in a lexicographic order
# notice that you can pass a stringified date.
Activepesel::Pesel.generate_all, sex: 2, date_of_birth: '2010-05-20')
Copyright (c) 2012 - 2023 Wojciech Pasternak released under the MIT license
FAQs
Unknown package
We found that activepesel 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
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.