Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
A straighforward extension for ActiveRecord models which makes it easy to reorder objects by a given column's values.
Add this line to your application's Gemfile:
gem 'me_first'
And then execute:
$ bundle
Or install it yourself as:
$ gem install me_first
To use MeFirst, you need to:
integer
ordering column to your model.attr_orderable
method with the ordering column as an argument.So:
$ rails g migration add_column_order_to_fake_models order:integer
$ rake db:migrate
class FakeModel
include MeFirst
attr_orderable :order
end
That's it! You're now ready to reorder by order
(or whichever column name you want) at will.
MeFirst gives you a number of commands, named based on the given column. For the above example, you're given two scopes:
FakeModel.by_order
FakeModel.by_reverse_order
And a number of useful instance methods:
instance = FakeModel.first
instance.move_order_up!(2) # Moves the instance's order up by 2 places
instance.move_order_down!(1) # Moves the instance's order down by 1 place
instance.move_order_to_end!
instance.move_order_to_beginning!
instance.set_order!(5) # Sets the current instance's order to 5, and reorders other instances around it.
To get a clearer sense of what exactly these methods do, check out the specs.
Note that these methods are all dependent upon the column name:
class FakeModel
include MeFirst
attr_orderable :position
end
FakeModel.by_position
FakeModel.first.move_position_up!(5)
This works great for relatively small numbers of objects. When dealing with a large table of ordered objects, MeFirst (and ordering by column in general), will not be particularly performant -- resetting a single instance's order requires changing the order of all the objects which followed its initial location.
After checking out the repo, run bin/setup
to install dependencies. Then, run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
to create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that me_first 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.