diff --git a/bandit/core/config.py b/bandit/core/config.py index 9ab223d1f..dbc68fb7d 100644 --- a/bandit/core/config.py +++ b/bandit/core/config.py @@ -52,7 +52,9 @@ def __init__(self, config_file=None): try: with f: - self._config = tomllib.load(f)["tool"]["bandit"] + self._config = ( + tomllib.load(f).get("tool", {}).get("bandit", {}) + ) except tomllib.TOMLDecodeError as err: LOG.error(err) raise utils.ConfigError("Error parsing file.", config_file)