Skip to content

Commit

Permalink
Additional, minor improvements. Use command.hint, clarify message.
Browse files Browse the repository at this point in the history
  • Loading branch information
erickgalinkin committed Jan 2, 2025
1 parent 68d123b commit e1ca672
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion garak/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
xdg_config_home,
xdg_data_home,
)
from garak.command import hint

DICT_CONFIG_AFTER_LOAD = False

Expand Down Expand Up @@ -116,6 +117,7 @@ def _nested_dict():
# placeholder
# generator, probe, detector, buff = {}, {}, {}, {}


def _key_exists(d: dict, key: str) -> bool:
# Check for the presence of a key in a nested dict.
if not isinstance(d, dict):
Expand Down Expand Up @@ -155,7 +157,11 @@ def _load_yaml_config(settings_filenames) -> dict:
logging.info(f"API key found in {settings_filename}. Checking readability...")
res = os.stat(settings_filename)
if res.st_mode & stat.S_IROTH or res.st_mode & stat.S_IRGRP:
logging.warn(f"A possibly secret value (`api_key`) was detected in {settings_filename}, which is readable by users other than yourself.")
msg = (f"A possibly secret value (`api_key`) was detected in {settings_filename}, "
f"which is readable by users other than yourself. "
f"Consider changing permissions on this file to only be readable by you.")
logging.warning(msg)
hint(msg)
config = _combine_into(settings, config)
return config

Expand Down

0 comments on commit e1ca672

Please sign in to comment.