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.
Turn a dict of arguments into cli commands, ideal companion of docopt.
Using the commandopt.commandopt
decorator, you are able to declare commands to be
executed depending on the input arguments of your app (required or optional).
It reduces the boilerplate code in your main()
.
def commandopt(mandopts: List, opts: List = None):
# ...
@commandopt(mandatory_arguments, optional_arguments)
def xxxx(*args, **kwargs):
#myapp/myapp.py
"""Naval Fate.
Usage:
naval_fate.py ship new <name>...
naval_fate.py new-ship [<name>]
naval_fate.py --version
Options:
--version Show version.
"""
from commandopt import Command
from docopt import docopt
import myapp.commands.ship
if __name__ == '__main__':
arguments = docopt(__doc__, version='Naval Fate 2.0')
run = Command(arguments) # get the registered function
run(arguments) # execute the function
# or
# run = Command(arguments, call=True)
#myapp/commands/ship.py
from commandopt import commandopt
class ShipCommand:
@commandopt(["ship", "new", "<name>"])
@commandopt(["new-ship"], ["<name>"])
def new(arguments):
"""You can stack the decorator if you want."""
name = arguments["<name>"] or "case when name is empty"
# ... your code here
FAQs
Turn a dict of arguments into cli commands, ideal companion of docopt.
We found that Commandopt demonstrated a healthy version release cadence and project activity because the last version was released less than 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.