Rule Definition
Throwing overly broad exceptions promotes complex error handling code that is more likely to contain security vulnerabilities.
Remediation
You should use Specific Exception instead of directly catching "CX_ROOT"
more detail can be found here : https://help.sap.com/doc/saphelp_nwpi71/7.1/de-DE/97/16934258a5c76ae10000000a155106/content.htm?no_cache=true
Violation Code Sample
report zdiv_zero.
data x type i.
try.
x = 1 / 0.
catch CX_ROOT.// VIOLATION
write 'Divide by zero.'.
endtry.
Fixed Code Sample
report zdiv_zero.
data x type i.
try.
x = 1 / 0.
catch CX_SY_ZERODIVIDE. //VIOLATION FIXED
write 'Divide by zero.'.
endtry.
Reference
https://help.sap.com/doc/saphelp_nwpi71/7.1/de-DE/97/16934258a5c76ae10000000a155106/content.htm?no_cache=true
https://cwe.mitre.org/data/definitions/397.html
Related Technologies
Technical Criterion
Programming Practices - Error and Exception Handling
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.