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.
A functional programming styled CLI console application framework based on argparse.
The easiest way to install konsoru is to use pip:
$ pip install konsoru
Konsoru enables you to build CLI applications quickly: either a text-based console or a program with multiple subcommands that executes in terminal.
Below is a bare minimum helloworld.py
program that launches a text-based console:
from konsoru import CLI
def helloworld():
print('Hello world!')
cli = CLI()
cli.add_function(helloworld)
cli.loop()
The console comes with 3 default commands: help, quit, exit. And every command added into the console, including default commands, will come with a -h
option that displays its help message.
When the above program runs, it looks like this:
$ python3 helloworld.py
Type 'help' to see help message.
Type 'quit' or 'exit' to exit the program.
> help
Available commands:
exit helloworld help quit
See help for a specific command by specifying the command name.
Help message for multi-layered command can still be seen by using quotation marks around them.
> helloworld -h
usage: helloworld [-h]
optional arguments:
-h, --help show this help message and exit
> helloworld
Hello world!
> quit
Alternatively, you can add your function as a command using the subroutine()
decorator. The decorator should be stacked on top of other decorators, if any. Also, by default, the framework will print the return of added functions, unless the return is None
. So the program below is completely equivalent to the example above:
from konsoru import CLI
cli = CLI()
@cli.subroutine()
def helloworld():
return 'Hello world!'
cli.loop()
To convert this into a program with subcommands that is interacted with through terminal, simply change cli.loop()
into cli.run()
at the end. Then, the program will behave like this:
$ python3 helloworld.py helloworld
Hello world!
Note that default commands under the console mode, i.e. help
, exit
, quit
, will not be added when using cli.run()
.
Put the script in a directory in your $PATH
and give it executable permissions to call it anywhere in your filesystem without python3
in the front.
For more sophisticated examples, check the examples/
directory in the github repository.
FAQs
A functional programming styled CLI console application framework based on argparse
We found that konsoru 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.