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.
Map options to a class. Simply create a class with the appropriate annotations, and have options automatically map to functions and parameters.
Example:
class MyApp < Thor # [1]
map "-L" => :list # [2]
desc "install APP_NAME", "install one of the available apps" # [3]
method_options :force => :boolean, :alias => :optional # [4]
def install(name)
user_alias = options[:alias]
if options.force?
# do something
end
# ... other code ...
end
desc "list [SEARCH]", "list all of the available apps, limited by SEARCH"
def list(search = "")
# list everything
end
end
Thor automatically maps commands as such:
app install myname --force
That gets converted to:
MyApp.new.install("myname")
# with {'force' => true} as options hash
--
and -
params.
In this case, a --force
and a -f
option is added.method_options
:boolean
true
:boolean
:required
:optional
:numeric
:optional
, but fall back to the given object as default valueIn case of unsatisfied requirements, Thor::Options::Error
is raised.
Examples of option parsing:
# let's say this is how we defined options for a method:
method_options(:force => :boolean, :retries => :numeric)
# here is how the following command-line invocations would be parsed:
command -f --retries 5 # => {'force' => true, 'retries' => 5}
command --force -r=5 # => {'force' => true, 'retries' => 5}
command -fr 5 # => {'force' => true, 'retries' => 5}
command --retries=5 # => {'retries' => 5}
command -r5 # => {'retries' => 5}
FAQs
Unknown package
We found that jherdman-thor 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.