SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • GroovyGroovy
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
Python

Python static code analysis

Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your PYTHON code

  • All rules 414
  • Vulnerability45
  • Bug104
  • Security Hotspot50
  • Code Smell215

  • Quick Fix 33
Filtered: 88 rules found
cwe
    Impact
      Clean code attribute
        1. Functions and methods should only return expected values

           Bug
        2. The number and name of arguments passed to a function should match its parameters

           Bug
        3. Non-empty statements should change control flow or have at least one side-effect

           Bug
        4. AI agent code execution without sandboxing is security-sensitive

           Security Hotspot
        5. Server-side requests should not be vulnerable to traversing attacks

           Vulnerability
        6. GraphQL introspection should be disabled in production

           Vulnerability
        7. JWT secret keys should not be disclosed

           Vulnerability
        8. Flask secret keys should not be disclosed

           Vulnerability
        9. Loop boundaries should not be vulnerable to injection attacks

           Vulnerability
        10. Memory allocations should not be vulnerable to Denial of Service attacks

           Vulnerability
        11. Allowing unrestricted outbound communications is security-sensitive

           Security Hotspot
        12. Hard-coded secrets are security-sensitive

           Security Hotspot
        13. Constructing arguments of system commands from user input is security-sensitive

           Security Hotspot
        14. Creating public APIs is security-sensitive

           Security Hotspot
        15. Using unencrypted EFS file systems is security-sensitive

           Security Hotspot
        16. Using unencrypted SQS queues is security-sensitive

           Security Hotspot
        17. Allowing public network access to cloud resources is security-sensitive

           Security Hotspot
        18. Using unencrypted SNS topics is security-sensitive

           Security Hotspot
        19. Administration services access should be restricted to specific IP addresses

           Vulnerability
        20. Using unencrypted SageMaker notebook instances is security-sensitive

           Security Hotspot
        21. AWS IAM policies should limit the scope of permissions given

           Vulnerability
        22. Using unencrypted OpenSearch domains is security-sensitive

           Security Hotspot
        23. Policies granting access to all resources of an account are security-sensitive

           Security Hotspot
        24. Using unencrypted RDS DB resources is security-sensitive

           Security Hotspot
        25. Policies granting all privileges are security-sensitive

           Security Hotspot
        26. Applications should not create session cookies from untrusted input

           Vulnerability
        27. Allowing public ACLs or policies on a S3 bucket is security-sensitive

           Security Hotspot
        28. Using unencrypted EBS volumes is security-sensitive

           Security Hotspot
        29. Policies authorizing public access to resources are security-sensitive

           Security Hotspot
        30. Granting access to S3 buckets to all or authenticated users is security-sensitive

           Security Hotspot
        31. Authorizing HTTP communications with S3 buckets is security-sensitive

           Security Hotspot
        32. Using slow regular expressions is security-sensitive

           Security Hotspot
        33. JWT should be signed and verified

           Vulnerability
        34. Cipher algorithms should be robust

           Vulnerability
        35. Encryption algorithms should be used with secure mode and padding scheme

           Vulnerability
        36. Server hostnames should be verified during SSL/TLS connections

           Vulnerability
        37. Server-side templates should not be vulnerable to injection attacks

           Vulnerability
        38. Insecure temporary file creation methods should not be used

           Vulnerability
        39. Using publicly writable directories is security-sensitive

           Security Hotspot
        40. Passwords should not be stored in plaintext or with a fast hashing algorithm

           Vulnerability
        41. Dynamic code execution should not be vulnerable to injection attacks

           Vulnerability
        42. Using clear-text protocols is security-sensitive

           Security Hotspot
        43. Disabling auto-escaping in template engines is security-sensitive

           Security Hotspot
        44. NoSQL operations should not be vulnerable to injection attacks

           Vulnerability
        45. HTTP request redirections should not be open to forging attacks

           Vulnerability
        46. Logging should not be vulnerable to injection attacks

           Vulnerability
        47. Server-side requests should not be vulnerable to forging attacks

           Vulnerability
        48. Deserialization should not be vulnerable to injection attacks

           Vulnerability
        49. Endpoints should not be vulnerable to reflected cross-site scripting (XSS) attacks

           Vulnerability
        50. Having a permissive Cross-Origin Resource Sharing policy is security-sensitive

           Security Hotspot
        51. Expanding archive files without controlling resource consumption is security-sensitive

           Security Hotspot
        52. Server certificates should be verified during SSL/TLS connections

           Vulnerability
        53. Signaling processes is security-sensitive

           Security Hotspot
        54. Using weak hashing algorithms is security-sensitive

           Security Hotspot
        55. Delivering code in production with debug features activated is security-sensitive

           Security Hotspot
        56. Disabling CSRF protections is security-sensitive

           Security Hotspot
        57. Unread "private" attributes should be removed

           Code Smell
        58. LDAP connections should be authenticated

           Vulnerability
        59. Cryptographic key generation should be based on strong parameters

           Vulnerability
        60. Weak SSL/TLS protocols should not be used

           Vulnerability
        61. Allowing both safe and unsafe HTTP methods is security-sensitive

           Security Hotspot
        62. Database queries should not be vulnerable to injection attacks

           Vulnerability
        63. Zero should not be a possible denominator

           Bug
        64. Creating cookies without the "HttpOnly" flag is security-sensitive

           Security Hotspot
        65. Cipher Block Chaining IVs should be unpredictable

           Vulnerability
        66. XML parsers should not be vulnerable to XXE attacks

           Vulnerability
        67. Regular expressions should not be vulnerable to Denial of Service attacks

           Vulnerability
        68. Setting loose POSIX file permissions is security-sensitive

           Security Hotspot
        69. Boolean expressions should not be gratuitous

           Code Smell
        70. Conditionally executed code should be reachable

           Bug
        71. Attributes should not be accessed on "None" values

           Bug
        72. Using non-standard cryptographic algorithms is security-sensitive

           Security Hotspot
        73. Using pseudorandom number generators (PRNGs) is security-sensitive

           Security Hotspot
        74. A secure password should be used when connecting to a database

           Vulnerability
        75. Creating cookies without the "secure" flag is security-sensitive

           Security Hotspot
        76. XPath expressions should not be vulnerable to injection attacks

           Vulnerability
        77. I/O function calls should not be vulnerable to path injection attacks

           Vulnerability
        78. LDAP queries should not be vulnerable to injection attacks

           Vulnerability
        79. Formatting SQL queries is security-sensitive

           Security Hotspot
        80. OS commands should not be vulnerable to command injection attacks

           Vulnerability
        81. Hard-coded passwords are security-sensitive

           Security Hotspot
        82. Password hashing functions should use an unpredictable salt

           Vulnerability
        83. Unused assignments should be removed

           Code Smell
        84. All code should be reachable

           Bug
        85. Break, continue and return statements should not occur in "finally" blocks

           Bug
        86. Track uses of "TODO" tags

           Code Smell
        87. Track uses of "FIXME" tags

           Code Smell
        88. "Exception" and "BaseException" should not be raised

           Code Smell

        Delivering code in production with debug features activated is security-sensitive

        consistency - conventional
        security
        Security Hotspot
        • cwe
        • error-handling
        • debug
        • user-experience

        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
        

        The following code defines a GraphQL endpoint with GraphiQL enabled. While this might be a useful configuration during development, it should never be enabled for applications deployed in production:

        from flask import Flask
        from graphql_server.flask import GraphQLView
        
        app = Flask(__name__)
        
        app.add_url_rule(
            '/graphql',
            view_func=GraphQLView.as_view(
                'graphql',
                schema=schema,
                graphiql=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)
        
        from flask import Flask
        from graphql_server.flask import GraphQLView
        
        app = Flask(__name__)
        
        app.add_url_rule(
            '/graphql',
            view_func=GraphQLView.as_view(
                'graphql',
                schema=schema
            )
        )
        

        See

        • OWASP - Top 10 2021 Category A5 - Security Misconfiguration
        • OWASP - Top 10 2017 Category A3 - Sensitive Data Exposure
        • CWE - CWE-489 - Active Debug Code
        • CWE - CWE-215 - Information Exposure Through Debug Information
          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube Community BuildAnalyze code in your
          on-premise CI
          Available Since
          9.1
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2026 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use