org.sonar.l10n.py.rules.python.S4507.html Maven / Gradle / Ivy
Development tools and frameworks usually have options to make debugging easier for developers. Although these features are useful during
development, they should never be enabled for applications deployed in production. Debug instructions or error messages can leak detailed information
about the system, like the application’s path or file names.
Ask Yourself Whether
- The code or configuration enabling the application debug features is deployed on production servers or distributed to end users.
- The application runs by default with debug features activated.
There is a risk if you answered yes to any of those questions.
Recommended Secure Coding Practices
Do not enable debugging features on production servers or applications distributed to end users.
Sensitive Code Example
Django application startup:
from django.conf import settings
settings.configure(DEBUG=True) # Sensitive when set to True
settings.configure(DEBUG_PROPAGATE_EXCEPTIONS=True) # Sensitive when set to True
def custom_config(config):
settings.configure(default_settings=config, DEBUG=True) # Sensitive
Inside settings.py
or global_settings.py
, which are the default configuration files for a Django application:
DEBUG = True # Sensitive
DEBUG_PROPAGATE_EXCEPTIONS = True # Sensitive
Flask application startup:
from flask import Flask
app = Flask()
app.debug = True # Sensitive
app.run(debug=True) # Sensitive
Compliant Solution
from django.conf import settings
settings.configure(DEBUG=False)
settings.configure(DEBUG_PROPAGATE_EXCEPTIONS=False)
def custom_config(config):
settings.configure(default_settings=config, DEBUG=False)
DEBUG = False
DEBUG_PROPAGATE_EXCEPTIONS = False
from flask import Flask
app = Flask()
app.debug = False
app.run(debug=False)
See
© 2015 - 2024 Weber Informatics LLC | Privacy Policy