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 bafflingly simple, JSON-backed configuration manager for Python programs.
I kept implementing roughly the same thing from scratch in my various projects, so I figured it was time to do it properly.
The confjson.Config
class is similar to a ChainMap, and works by means of two JSON files in the same directory:
default.config.json
user.config.json
The path given when initializing the Config object can be either a directory or a file. If it refers to a file, confjson will look for config files in the containing directory. The reason for this is that it enables the pattern of using __file__
to find config files in the same directory as the program.
config = confjson.Config(__file__)
config = confjson.Config(".")
config = confjson.Config(
"./configs",
user_config_filename=f"{os.getenv('username')}.cfg",
default_config_filename="global.cfg",
)
Items in the confjson config are accessed as in a dict.
if "username" in config["user"]:
do_something(config["user"]["username"])
config["user"]["something_count"] += 1
It is also possible to access items as attributes, unless they share a name with a method of the Config class.
config.my_key = "my value"
The load() method (re-)loads the Config object with values from the backing JSON files. Loading is also performed on initialization, so this is mainly for discarding changes.
config.load()
The save() method saves any changed or added items to user.config.json only.
config.save()
use_placeholders
argument to Config class. When True, doesn't raise KeyError on attempted access to a nonexistent key, instead returning a placeholder. Assignments of keys to a placeholder will propagate up through the hierarchy and add real dicts as needed.keys()
, get(key, default)
and __contains__(key)
to ConfigItemProxy to fix a few problems caused by the previous change.__init__
to also load the config files.FAQs
A bafflingly simple, JSON-backend configuration manager for python programs.
We found that confjson 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.