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.
pluginaweek-polymorphic_identity
Advanced tools
= polymorphic_identity
+polymorphic_identity+ dynamically generates aliases for polymorphic associations based on the class names of those associations.
== Resources
API
Bugs
Development
Source
== Description
Polymorphic associations are not very descriptive when it comes to easily knowing the type of model your interacting with. For example, a typical polymorphic assocation looks like the following:
class Tag < ActiveRecord::Base belongs_to :taggable, :polymorphic => true end
When getting the taggable record, you would normally have to call tag.taggable. However, if you know that the taggable record is just an instance of the Article model, then it would feel more comfortable if you could just call tag.article. polymoprhic_identity makes this possible by dynamically checking the name of the polymorphic record's class and creating methods that allow you to access the polymorphic association based on that class name.
== Usage
=== Example
class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true belongs_to :commenter, :polymorphic => true end
class Article < ActiveRecord::Base has_many :comments, :as => :commentable end
class User < ActiveRecord::Base has_many :comments, :as => :commenter end
c = Comment.find(1) # => #<Tag id: 1, commentable_id: 1, commentable_type: "Article", commenter_id: 1, commenter_type: "User"}> c.commentable # => #<Article id: 1> c.article # => #<Article id: 1> c.commenter # => #<User id: 1> c.user # => #<User id: 1>
== Testing
Before you can run any tests, the following gem must be installed:
To run against a specific version of Rails:
rake test RAILS_FRAMEWORK_ROOT=/path/to/rails
== Dependencies
FAQs
Unknown package
We found that pluginaweek-polymorphic_identity 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.