Skip to content

Commit

Permalink
Merge pull request #920 from blacklanternsecurity/config-comment-notice
Browse files Browse the repository at this point in the history
insert comment notice in yaml configs
  • Loading branch information
TheTechromancer authored Dec 20, 2023
2 parents fd8b72e + 07a43fe commit affb308
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bbot/core/configurator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def ensure_config_files():
secrets_strings = ["api_key", "username", "password", "token", "secret", "_id"]
exclude_keys = ["modules", "output_modules", "internal_modules"]

comment_notice = (
"# NOTICE: THESE ENTRIES ARE COMMENTED BY DEFAULT\n"
+ "# Please be sure to uncomment when inserting API keys, etc.\n"
)

# ensure bbot.yml
if not files.config_filename.exists():
log_to_stderr(f"Creating BBOT config at {files.config_filename}")
Expand All @@ -77,7 +82,7 @@ def ensure_config_files():
exclude_keys=exclude_keys,
)
yaml = OmegaConf.to_yaml(no_secrets_config)
yaml = "\n".join(f"# {line}" for line in yaml.splitlines())
yaml = comment_notice + "\n".join(f"# {line}" for line in yaml.splitlines())
with open(str(files.config_filename), "w") as f:
f.write(yaml)

Expand All @@ -92,7 +97,7 @@ def ensure_config_files():
exclude_keys=exclude_keys,
)
yaml = OmegaConf.to_yaml(secrets_only_config)
yaml = "\n".join(f"# {line}" for line in yaml.splitlines())
yaml = comment_notice + "\n".join(f"# {line}" for line in yaml.splitlines())
with open(str(files.secrets_filename), "w") as f:
f.write(yaml)
files.secrets_filename.chmod(0o600)

0 comments on commit affb308

Please sign in to comment.