All environment variables should be defined in a centralized location (`checkov/common/util/env_vars_config.py`) rather than scattered throughout the codebase. This approach enhances maintainability, promotes consistency, and simplifies tracking of configuration settings.
All environment variables should be defined in a centralized location (checkov/common/util/env_vars_config.py
) rather than scattered throughout the codebase. This approach enhances maintainability, promotes consistency, and simplifies tracking of configuration settings.
When adding a new environment variable:
os.getenv()
callsAlways use strtobool()
for boolean environment variables since bool('False')
evaluates to True
.
Example:
# In checkov/common/util/env_vars_config.py
from distutils.util import strtobool
# Controls whether to ignore hidden directories (default: True)
IGNORE_HIDDEN_DIRECTORY_ENV = strtobool(os.getenv("CKV_IGNORE_HIDDEN_DIRECTORIES", "True"))
# In your code
from checkov.common.util.env_vars_config import IGNORE_HIDDEN_DIRECTORY_ENV
if IGNORE_HIDDEN_DIRECTORY_ENV:
# Skip hidden directories logic here
Enter the URL of a public GitHub repository