Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Acb is a gem for formatting and outputting csv data from ActiveRecord data
Install the gem and add to the application's Gemfile by executing:
$ bundle add acb
ActiveRecord::Schema.define do
create_table :users, force: true do |t|
t.string :name
end
create_table :posts, force: true do |t|
t.integer :user_id
t.timestamps
end
create_table :comments, force: true do |t|
t.integer :post_id
t.string :content
end
end
class User < ActiveRecord::Base
has_many :posts
end
class Post < ActiveRecord::Base
belongs_to :user
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
class PostCsvBuilder
include Acb
add_column name: 'id'
add_column name: 'User Name', index: 'user.name'
add_column name: 'created_at', format: '%Y-%m-%d'
add_column name: 'Comment Amount', index: 'comments.size'
add_column name: 'First Comment', index: ->(post) { post.comments.first&.content }
def initialize(user_id)
@data = Post.where(user_id: user_id)
end
def relations
[:user, :comments]
end
end
PostCsvBuilder.new(user_id).to_csv
# or
class PostCsvBuilder
include Acb
add_column name: 'id'
add_column name: 'User Name', index: 'user.name'
add_column name: 'created_at', format: '%Y-%m-%d'
add_column name: 'Comment Amount', index: 'comments.size'
add_column name: 'First Comment', index: ->(post) { post.comments.first&.content }
end
builder = PostCsvBuilder.new
relations = Post.where(user_id: user_id).preload(:user, :comments)
builder.load_from(relations)
builder.to_csv
Everyone interacting in the Acb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that acb demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.