Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
= ConfigParser
Parse command-line options into a configuration hash.
== Description
ConfigParser is an analogue of {OptionParser}[http://www.ruby-doc.org/core/classes/OptionParser.html] that formalizes the pattern of setting parsed options into a hash. ConfigParser uses a similar, simplified declaration syntax and provides an API that integrates well with libraries like {Configurable}[http://github.com/thinkerbot/configurable].
== Usage
Define options and their default values using +add+:
parser = ConfigParser.new parser.add :option, 'default' # regular option with a default value parser.add :switch, true # true makes a --[no-]switch parser.add :flag, false # false as a default makes a --flag parser.add :list, [] # an array makes a list-style option
parser.parse 'a b --flag --list x --list y,z c'
parser.config
The OptionParser +on+ syntax may also be used, if desired (most syntax variations will work). Use the parser as if it were the config hash:
parser = ConfigParser.new parser.on '--option OPTION', 'a standard option' do |value| parser[:option] = value end
parser.on '--[no-]switch', 'a switch' do |value| parser[:switch] = value end
parser.on '--flag', 'a flag' do parser[:flag] = true end
parser.parse 'a b --flag --switch --option value c'
parser.config
Added options may be further defined using arguments just like +on+ or with an attributes hash. Notably, the key for the config does not have to correspond to the option (although by default it does). As you may expect a block can be given to process values before they are set as configs.
parser = ConfigParser.new
parser.add(:x, nil, '-o', '--one')
parser.add(:y, nil, :short => 't', :long => 'two')
parser.add(:z, nil, :long => 'three') {|value| value.upcase }
parser.parse('a b --one uno --two dos --three tres c')
parser.config
== Installation
ConfigParser is available as a gem[http://rubygems.org/gems/config_parser].
% gem install config_parser
== Development
To get started, checkout the code from GitHub[http://github.com/thinkerbot/config_parser] and run the tests:
git clone git://github.com/thinkerbot/config_parser.git cd config_parser rake test
Please report any issues {here}[http://github.com/thinkerbot/config_parser/issues].
== Info
Developer:: {Simon Chiang}[http://github.com/thinkerbot] License:: {MIT-Style}[link:files/MIT-LICENSE.html]
FAQs
Unknown package
We found that config_parser 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.