Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] DFA Scan InternalExecutionError on Decimal.divide method #1462

Open
OpenWaccaCH opened this issue May 8, 2024 · 0 comments
Open

[BUG] DFA Scan InternalExecutionError on Decimal.divide method #1462

OpenWaccaCH opened this issue May 8, 2024 · 0 comments
Labels
SFGE Issues related to the Salesforce Graph Engine

Comments

@OpenWaccaCH
Copy link

Description:
Getting an InternalExecutionError during DFA scan on code that includes a call to the Decimal.divide instance method.

Documentation:
sfge.log

The Apex class file contains the following code block:

if(reportRows != null && reportRows.size() > 0){
Integer reportRowsSize = reportRows.size();
Decimal countReportRows = Decimal.valueOf(reportRowsSize);
Decimal oneHundred = 100.00;
Decimal totalDetailRows = countReportRows.divide(oneHundred, 2);

The scanner throws an InternalExecutionError on the line with the call to the 'divide' method

Steps To Reproduce:
Scan Apex code that includes a call to the Decimal.divide instance method using this command
sf scanner run dfa --format csv --outfile CodeAnalyzerDFA.csv --target ./ --projectdir ./ --category Security

The scanner generates a report that includes an InternalExecutionError at the code line that calls the divide method.

Expected Behavior:
I expect the scanner not to produce an error for calls to the divide method

Screenshots:
N/A

Desktop:

  • Operating System: Windows 11 Pro 10.0.22631
  • Code Analyzer version: 4.1.0 (I was originally running with version 3.23.0, but ran into problems with it not recognizing the 'as' keyword)
  • Salesforce CLI version: @salesforce/cli/2.39.6

Additional Context:
Based on the code in https://github.com/forcedotcom/sfdx-scanner, it looks like the 'apply' methods in the ApexDecimalValue.java, and ApexNumberValue.java classes do not include support for any methods other than longValue, intValue and format. The default is to bubble up to ApexSimleValue.java, where the 'apply' method simply throws an exception.

Workaround:
I can write an explanation of the error into our submission for AppExchange security review.

Urgency:
There is a work-around, but it would be great to implement support for all of the apex Decimal methods so people don't spend a bunch of time trying to troubleshoot things that aren't actually a problem.

@stephen-carter-at-sf stephen-carter-at-sf added the SFGE Issues related to the Salesforce Graph Engine label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SFGE Issues related to the Salesforce Graph Engine
Projects
None yet
Development

No branches or pull requests

2 participants