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
  • 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
Apex

Apex static code analysis

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

  • All rules 97
  • Vulnerability2
  • Bug26
  • Security Hotspot3
  • Code Smell66
 
Tags
    Impact
      Clean code attribute
        1. Apex REST services should implement comprehensive exception handling

           Vulnerability
        2. Sharing level should be specified in Apex Classes with SOQL/SOSL Queries or DML Statements

           Vulnerability

        Apex REST services should implement comprehensive exception handling

        intentionality - complete
        security
        reliability
        maintainability
        Vulnerability
        • security
        • rest
        • exception-handling
        • salesforce

        This rule raises an issue when Apex REST service methods (annotated with @HttpGet, @HttpPost, @HttpPut, @HttpDelete, or @HttpPatch) do not implement proper exception handling with try-catch blocks and explicit HTTP response management.

        Why is this an issue?

        How can I fix it?

        More Info

        Apex REST services without proper exception handling create several serious problems for your application and its users.

        When exceptions occur in REST methods without try-catch blocks, Salesforce automatically generates error responses that may expose sensitive system information. These default error messages can reveal internal implementation details, database schema information, or system configuration that attackers could exploit.

        Unhandled exceptions also result in generic HTTP 500 errors with unhelpful messages, making it difficult for API consumers to understand what went wrong or how to fix their requests. This leads to poor developer experience and increased support burden.

        Additionally, without explicit response handling, your API cannot provide consistent, well-structured responses. Modern REST APIs should return appropriate HTTP status codes (200 for success, 400 for client errors, 500 for server errors) and structured JSON responses that help clients handle both success and error scenarios gracefully.

        Proper exception handling also enables better logging and monitoring, allowing you to track API usage patterns and identify issues before they impact users.

        What is the potential impact?

        Unhandled exceptions in REST services can lead to information disclosure vulnerabilities where sensitive system details are exposed to external callers. This creates security risks and may violate data protection requirements.

        Poor error handling also degrades API reliability and user experience, potentially causing integration failures and increased support costs.

          Available In:
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories

        © 2025 SonarSource Sàrl. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use