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.
benjaminkrause-restful
Advanced tools
!!! Refactor this shice. Seriously, this has devolved into some nasty-ass code.
Aims to provide a production quality Rest API to your Rails app, with the following features:
In order to make your models apiable add
apiable
to your model. Next, define which properties you want to export, so within the model write something like:
self.restful_publish(:name, :current-location, :pets)
Some example configurations:
restful_publish :name, :pets, :restful_options => { :expansion => :expanded } # default on level 1-2: expanded. default above: collapsed. restful_publish :name, :pets, :wallet => :contents, :restful_options => { :expansion => :expanded } # combined options and expansion rules restful_publish :name, :pets, :restful_options => { :collapsed => :pets } # collapsed pets, even though they are on the second level. restful_publish :name, :pets, :restful_options => { :force_expanded => [:pets, :wallet] }
restful_publish :name, :person # expands person per default because it is on the second level. Does not expand person.pets.first.person, since this is higher than second level.
You can add includes to your call like this:
pet.to_restful_json :include => :owner.
This format sticks to xml_simple, adding links as <association-name-restful-url>
nodes of type "link".
Person.last.to_restful.serialize(:xml)
OR
Person.last.to_restful_xml
results in something like...
Person.last.to_restful.serialize(:atom_like)
OR
Person.last.to_restful_atom_like
results in something like...
Person.last.to_restful.serialize(:params)
OR
Person.last.to_restful_params
results in something like...
{:sex_attributes => {:sex=>"male"}, :current_location=>"Under a tree", :name=>"Joe Bloggs", :pets_attributes=> [ {:person_id=>1, :name=>nil} ] }
Hash. Spits out a plain ole hash, no nested attributes or such like. Useful for further conversions.
Use Restful.from_atom_like(xml).serialize(:hash)
to convert from an atom-like formatted xml create to a params hash. Takes care of dereferencing the urls back to ids. Generally, use Restful.from_<serializer name>(xml)
to get a Resource.
Serializing uses Rails 2.3 notation of nested attributes. For deserializing you will need Rails 2.3 for having nested attributes support and the respective model must have the
accepts_nested_attributes_for :<table name>
set accordingly.
FAQs
Unknown package
We found that benjaminkrause-restful demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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.