
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
activerecord_uuid_as_pk
Advanced tools
activerecord_uuid_as_pk
is a extension for ActiveRecord to enable to use uuid for id
attribute (v1.0.0 tested only MySQL).
Add this line to your application's Gemfile:
gem 'activerecord_uuid_as_pk'
And then execute:
$ bundle
Or install it yourself as:
$ gem install activerecord_uuid_as_pk
In a migration file, prevent generate id column and add uuid column (tinyblob).
class CreateUsers < ActiveRecord::Migration
def up
create_table :users, :id => false do |t|
t.column :uuid, :tinyblob
t.string :user_name
end
execute "ALTER TABLE users ADD PRIMARY KEY (`uuid`(16))"
end
def down
drop_table :users
end
end
Call uuid_as_primary_key
method in a model class.
class User < ActiveRecord::Base
uuid_as_primary_key
end
The uuid_as_primary_key
method hooks before_create
callback to set automatically generated uuid as 16 byte binary data to id attirbute. And this method adds #formatted_id
to the model to refer formatted uuid.
user = User.create(:user_name => "foo")
user.id #=> "3~\x05v\xCBfAQ\xA2\xE1\xE0\xFC\x04\xFB3\xD1"
user.formatted_id #=> "337e0576-cb66-4151-a2e1-e0fc04fb33d1"
Of course you can set arbitrary uuid if you set 16 byte binary, a formatted uuid string or UUIDTools::UUID object to id
attribute. A formatted uuid string and UUIDTools::UUID object will be converted 16 byte binary data when you save a model.
user1 = User.create(:id => UUIDTools::UUID.parse("f311427a-954c-46f5-92df-3d37f56b5b41").raw, :user_name => "user1")
user1.formatted_id
#=> "f311427a-954c-46f5-92df-3d37f56b5b41"
user2 = User.create(:id => "206b38d7-3b5f-4645-b5b2-5e7efea1d3ca", :user_name => "user2")
user2.formatted_id
#=> "206b38d7-3b5f-4645-b5b2-5e7efea1d3ca"
user3 = User.create(:id => UUIDTools::UUID.parse("c81836c5-309a-4608-bf1a-5fe343081a92"), :user_name => "user3")
user3.formatted_id
#=> "c81836c5-309a-4608-bf1a-5fe343081a92"
The uuid_as_primary_key
method also adds find_by_formatted_id
class method to retrive model from data store with a formatted uuid string.
User.find_by_formatted_id("337e0576-cb66-4151-a2e1-e0fc04fb33d1")
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that activerecord_uuid_as_pk 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.