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.
Manages configuration coming from config files, environment variables, command line arguments, code defaults or other sources
.. image:: https://badge.fury.io/py/layeredconfig.png :target: http://badge.fury.io/py/layeredconfig
.. image:: https://travis-ci.org/staffanm/layeredconfig.png?branch=master :target: https://travis-ci.org/staffanm/layeredconfig
.. image:: https://ci.appveyor.com/api/projects/status/nnfqv9jhxh3afgn0/branch/master :target: https://ci.appveyor.com/project/staffanm/layeredconfig/branch/master
.. image:: https://coveralls.io/repos/staffanm/layeredconfig/badge.png?branch=master :target: https://coveralls.io/r/staffanm/layeredconfig
.. image:: https://landscape.io/github/staffanm/layeredconfig/master/landscape.png :target: https://landscape.io/github/staffanm/layeredconfig/master :alt: Code Health
.. image:: https://pypip.in/d/layeredconfig/badge.png :target: https://pypi.python.org/pypi/layeredconfig
Full documentation: https://layeredconfig.readthedocs.org/
LayeredConfig compiles configuration from files, environment variables, command line arguments, hard-coded default values, or other backends, and makes it available to your code in a simple way::
from layeredconfig import (LayeredConfig, Defaults, INIFile,
Environment, Commandline)
# This represents four different way of specifying the value of the
# configuration option "hello":
# 1. hard-coded defaults
defaults = {"hello": "is it me you're looking for?"}
# 2. INI configuration file
with open("myapp.ini", "w") as fp:
fp.write("""
[__root__]
hello = kitty
""")
# 3. enironment variables
import os
os.environ['MYAPP_HELLO'] = 'goodbye'
# 4.command-line arguments
import sys
sys.argv = ['./myapp.py', '--hello=world']
# Create a config object that gets settings from these four
# sources.
config = LayeredConfig(Defaults(defaults),
INIFile("myapp.ini"),
Environment(prefix="MYAPP_"),
Commandline())
# Prints "Hello world!", i.e the value provided by command-line
# arguments. Latter sources take precedence over earlier sources.
print("Hello %s!" % config.hello)
config.downloading.refresh
) and if a
subsection does not contain a requested setting, it can optionally
be fetched from the main configuration (if config.module.retry
is missing, config.retry
can be used instead).datetime.date
object, not a str
). If
settings are fetched from backends that do not themselves provide
typed data (ie. environment variables, which by themselves are
strings only), a system for type coercion makes it possible to
specify how data should be converted.dump
, which returns the content of the passed
config object as a dict. This is also used as a printable
representation of a config object (through __repr__
).All of the above was done by @jedipi. Many thanks!
A number of unreported bugs, mostly concerning unicode handling and type conversion in various sources, was also fixed.
Fixed a bug when using a class in a Default configuration for automatic coercion, where the type of the class isn't type (as is the case with the "newint" and other classes from the future module).
Fixed a bug where loading configuration from multiple config files would crash if latter configs lacked subsections present in earlier. Thanks to @badkapitan!
FAQs
Manages configuration coming from config files, environment variables, command line arguments, code defaults or other sources
We found that layeredconfig 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.