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.
Transparently persist objects to disk as YAML or PStore files.
$ gem install pobject
Or with bundler:
gem 'pobject'
Your object should inherit from PObject
.
require 'pobject'
class Settings < PObject
end
Now, any time you access a property, it is saved to a file. By default, we will save a YAML file with the same name as the class.
class Settings < PObject
end
config = Settings.new
config.port = 3000
# Will create a 'settings.yml' file and store the port value
You can access any property by either dot notation or hash notation.
config.port
# => 3000
config[:port]
# => 3000
To change the location of the file, simply override the to_store
method.
class Settings < PObject
def to_store
"config/local.yml"
end
end
config = Settings.new
config.port = 3000
# Will create a 'config/local.yml'
Whenever you use the .yml
(or .yaml
) extension, we will store a YAML
file. If you wish to store a PStore
object instead, use any other
extension.
class Settings < PObject
def to_store
"config/local.pstore"
end
end
To store several objects in one store file, your to_store
method should
return an array with two elements: The first, is the path to the file and
the second is any unique key identifying the instance.
class Hero < PObject
def initialize(id)
@id = id
end
def to_store
["heroes.yml", @id]
end
end
hammer = Hero.new :hammer
raynor = Hero.new :raynor
hammer.name = 'Sgt. Hammer'
raynor.name = 'Raynor'
puts File.read 'heroes.yml'
# =>
# ---
# :hammer:
# :name: Sgt. Hammer
# :raynor:
# :name: Raynor
By default, PObject will raise an error when accessing a property that does
not exist. To change this behavior, call allow_missing
at the beinning of
your class.
class Book < PObject
allow_missing
end
book = Book.new
book.author
# => nil
FAQs
Unknown package
We found that pobject 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.