
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
Data replication as templates for Ruby ORMs.
DNA replication. The double helix is unwound and each strand acts as a template for the next strand. Bases are matched to synthesize the new partner strands.
Add this line to your application's Gemfile:
gem 'replication'
And then execute:
$ bundle
Or install it yourself as:
$ gem install replication
Extend Replication::Process
in your models and declare it.
class Model
extend Replication::Process
can_replicate
end
Customize the 'pairs' method if you want.
class Model
extend Replication::Process
can_replicate :attributes_alias # default method is 'attributes'
end
Customize the class of the strands if you want.
class Model
extend Replication::Process
can_replicate strand_class: WeirdStrandClass
end
You can whitelist an array of attributes. They'll be replicated in the new strand.
can_replicate only: [:some_column, :other_column]
You can blacklist an array of attributes. They'll not be replicated in the new strand.
can_replicate except: [:id, :name]
To 'unwound' a strand, do:
model_instance = Model.new(attrs)
model_instance.unwound(name: 'The Original Model') # returns a new strand
To 'unwound' and save a strand, do:
model_instance = Model.new(attrs)
model_instance.replicate(name: 'The Original Model') # returns a new persisted strand
To be able to 'unwound' only when the object is valid, include Proofreading.
Right now it needs a valid?
method to check.
class Model
extend Replication::Process
can_replicate with: :proofreading
end
model_instance = Model.new(invalid_attrs)
model_instance.unwound(name: 'The Original Model') # returns nil
model_instance.replicate(name: 'The Original Model') # raises UnwoundError
To initialize a object that's descendant from the strand of another object, do:
Model.new_from_strand([name or id])
# or
strand.replicate
For ActiveRecord strands, [:id, :created_at, :updated_at]
will be blacklisted by default.
It's highly recommended that you save your model instances before trying to replicate, since it needs the 'id' and 'type' references for the association.
In some cases you don't want/won't need the strands to be associated, so, be free.
There's also a Association module, that is experimental and should be used with care. It uses the same parameters as the accepts_nested_attributes_for
.
Model.can_replicate with: { associations: [:children, reject_if: :all_blank] }
Migrations are be provided by:
rake replication_engine:install:migrations
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that replication 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 clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.