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.
Ruby gem to manage undelivered/ read status of ActiveRecord objects
Most of the logic shamelessly stolen from unread
gem
Add this line to your application's Gemfile:
gem 'undelivered'
And then execute:
$ bundle install
Install migration yourself (as of now):
class CreateUndeliveredReadMarks < ActiveRecord::Migration[6.1]
def change
create_table :undelivered_read_marks do |t|
t.references :reader, polymorphic: { null: false }
t.references :readable, polymorphic: { null: false }
t.integer :status, index: true
t.datetime :timestamp
t.timestamps
end
add_index :undelivered_read_marks, [:reader_id, :reader_type, :readable_type, :readable_id, :status], name: 'undelivered_read_marks_reader_readable_status_index', unique: true
end
end
Run migration:
$ rails db:migrate
By following idea from this
issue of unread
gem.
class User < ApplicationRecord
acts_as_reader
end
class Conversation < ApplicationRecord
acts_as_readable on: :updated_at
has_many :messages, dependent: :destroy
def undelivered_messages(reader)
chain = messages
rm = find_read_mark(reader, :delivered) # this method comes from `undelivered` gem
if rm.present?
chain = chain.where('created_at > ?', rm.timestamp)
end
return chain
end
def unread_messages(reader)
chain = messages
rm = find_read_mark(reader, :read)
if rm.present?
chain = chain.where('created_at > ?', rm.timestamp)
end
return chain
end
end
class Message < ApplicationRecord
belongs_to :conversation, touch: true
end
# Suppose we got 1 users and 1 conversation
current_user = User.find(1)
conversation = Conversation.find(1)
message1 = conversation.messages.create
message2 = conversation.messages.create
# Get undelivered messages for current_user, using method of conversation class
conversation.undelivered_messages(current_user)
# => [ message1, message2 ]
# Mark them as delivered for current_user
conversation.mark_as_delivered_for!(current_user)
# Get unread messages for current_user
conversation.unread_messages(current_user)
# => [ message1, message2 ]
# Mark them as read for current_user
conversation.mark_as_read_for!(current_user)
Bug reports and pull requests are welcome on GitHub at https://github.com/vivekmiyani/undelivered. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Undelivered project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that undelivered 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.