forcedotcom / sfdx-scanner

MIT License
209 stars 49 forks source link

[BUG] InternalExecutionError on Standard Salesforce methods #1409

Closed jaelee125 closed 3 months ago

jaelee125 commented 4 months ago

Decimal.setScale method is causing InternalExecution Error

Double value = Decimal.valueOf(Double.valueOf(fieldValue)).setScale(scale);

Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: UnexpectedException: MethodCallExpressionVertex{fullMethodName=setScale, referenceVertex=LazyVertex{result=ReferenceExpression{properties={FirstChild=true, BeginLine=1453, DefiningType_CaseSafe=sn_networkcontroller, LastChild=false, DefiningType=SN_NetworkController, EndLine=1453, Name_CaseSafe=, childIdx=0, BeginColumn=65, ReferenceType=METHOD, Name=}}}, chainedNames=[], properties={FirstChild=true, FullMethodName=setScale, BeginLine=1453, FullMethodName_CaseSafe=setscale, DefiningType_CaseSafe=sn_networkcontroller, LastChild=false, DefiningType=SN_NetworkController, EndLine=1453, MethodName_CaseSafe=setscale, childIdx=0, BeginColumn=65, MethodName=setScale}}: com.salesforce.graph.symbols.apex.ApexSimpleValue.apply(ApexSimpleValue.java:55);com.salesforce.graph.symbols.apex.ApexNumberValue.apply(ApexNumberValue.java:42);com.salesforce.graph.symbols.apex.ApexDecimalValue.apply(ApexDecimalValue.java:49);com.salesforce.graph.symbols.PathScopeVisitor.handleApexValueMethod(PathScopeVisitor.java:1487);com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:1242);com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterVisit(DefaultSymbolProviderVertexVisitor.java:800)","https://forcedotcom.github.io/sfdx-scanner/en/v3.x/salesforce-graph-engine/rules/#ApexFlsViolationRule","InternalExecutionError","sfge"

jaelee125 commented 4 months ago

Url.getOrgDomainUrl().toExternalForm() is causing InternalExecution Error

String url = Url.getOrgDomainUrl().toExternalForm() + '/lightning/n/Specright_Network?ctab=Search&cobject=' + objectApiName + '&c__uuid=' + recordId;

"Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: UnimplementedMethodException: ApexStringValue:getOrgDomainUrl, vertex=MethodCallExpressionVertex{fullMethodName=Url.getOrgDomainUrl, referenceVertex=LazyVertex{result=ReferenceExpression{properties={FirstChild=true, Names=[Url], BeginLine=51, DefiningType_CaseSafe=sn_commentcallback, LastChild=true, DefiningType=SN_CommentCallback, EndLine=51, Name_CaseSafe=url, childIdx=0, BeginColumn=17, ReferenceType=METHOD, Name=Url}}}, chainedNames=[Url], properties={FirstChild=true, FullMethodName=Url.getOrgDomainUrl, BeginLine=51, FullMethodName_CaseSafe=url.getorgdomainurl, DefiningType_CaseSafe=sn_commentcallback, LastChild=true, DefiningType=SN_CommentCallback, EndLine=51, MethodName_CaseSafe=getorgdomainurl, childIdx=0, BeginColumn=21, MethodName=getOrgDomainUrl}}: com.salesforce.graph.symbols.apex.ApexStringValue.apply(ApexStringValue.java:708);com.salesforce.graph.symbols.PathScopeVisitor.handleApexValueMethod(PathScopeVisitor.java:1487);com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:1242);com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterVisit(DefaultSymbolProviderVertexVisitor.java:800);com.salesforce.graph.vertex.MethodCallExpressionVertex.afterVisit(MethodCallExpressionVertex.java:79);com.salesforce.graph.ops.expander.ApexPathExpander.performAfterVisit(ApexPathExpander.java:577)","https://forcedotcom.github.io/sfdx-scanner/en/v3.x/salesforce-graph-engine/rules/#ApexFlsViolationRule","InternalExecutionError","sfge"

jaelee125 commented 4 months ago

Schema.SObjectType: newSObjectType method is causing Internal Execution Error

Schema.SObjectType sObjectType = ((SObject) (Type.forName('Schema.' + sObjectAPIName).newInstance())).getSObjectType(); SObject record = sObjectType.newSObject(recordTypeId, false);

"1","3","/Users/jae/code/specright-network/specright-network/main/default/classes/SN_NetworkController.cls","903","19","SN_NetworkController","saveNetworkRecord","","","","InternalExecutionError","Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: UnexpectedException: MethodCallExpressionVertex{fullMethodName=sObjectType.newSObject, referenceVertex=LazyVertex{result=ReferenceExpression{properties={FirstChild=true, Names=[sObjectType], BeginLine=962, DefiningType_CaseSafe=sn_networkcontroller, LastChild=false, DefiningType=SN_NetworkController, EndLine=962, Name_CaseSafe=sobjecttype, childIdx=0, BeginColumn=14, ReferenceType=METHOD, Name=sObjectType}}}, chainedNames=[sObjectType], properties={FirstChild=false, FullMethodName=sObjectType.newSObject, BeginLine=962, FullMethodName_CaseSafe=sobjecttype.newsobject, DefiningType_CaseSafe=sn_networkcontroller, LastChild=true, DefiningType=SN_NetworkController, EndLine=962, MethodName_CaseSafe=newsobject, childIdx=1, BeginColumn=26, MethodName=newSObject}}: com.salesforce.graph.symbols.apex.ApexValue.validateParameterSize(ApexValue.java:610);com.salesforce.graph.symbols.apex.schema.SObjectType._applyMethod(SObjectType.java:131);com.salesforce.graph.symbols.apex.schema.SObjectType.executeMethod(SObjectType.java:121);com.salesforce.graph.symbols.PathScopeVisitor.afterMethodCall(PathScopeVisitor.java:659);com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterMethodCall(DefaultSymbolProviderVertexVisitor.java:318);com.salesforce.graph.ops.expander.ApexPathExpander.handleMethodCall(ApexPathExpander.java:681)","https://forcedotcom.github.io/sfdx-scanner/en/v3.x/salesforce-graph-engine/rules/#ApexFlsViolationRule","InternalExecutionError","sfge"

sagar-j-sfdc commented 3 months ago

This is a duplicate of #1044. As a workaround, try not to use the variable names same as the class name for e.g url and Url.

nwcm commented 3 months ago

@sagar-j-sfdc The original raised exception is not the same as the one you suggest this is a duplicate of. Additionally your work around doesn't work.

public with sharing class AllThingsDFAHates {
  @AuraEnabled
  public static void noSetScale(){
    Decimal dec = 1.00;

    dec.setScale(2);
  }
}
Graph Engine identified your source and sink, but you must manually verify that you have a sanitizer in this path. Then, add an engine directive to skip the path. Next, create a Github issue for the Code Analyzer team that includes the error and stack trace. After we fix this issue, check the Code Analyzer release notes for more info. Error and stacktrace: UnexpectedException: MethodCallExpressionVertex{fullMethodName=dec.setScale, referenceVertex=LazyVertex{result=ReferenceExpression{properties={FirstChild=true, Names=[dec], BeginLine=116, DefiningType_CaseSafe=allthingsdfahates, LastChild=false, DefiningType=AllThingsDFAHates, EndLine=116, Name_CaseSafe=dec, childIdx=0, BeginColumn=5, ReferenceType=METHOD, Name=dec}}}, chainedNames=[dec], properties={FirstChild=true, FullMethodName=dec.setScale, BeginLine=116, FullMethodName_CaseSafe=dec.setscale, DefiningType_CaseSafe=allthingsdfahates, LastChild=true, DefiningType=AllThingsDFAHates, EndLine=116, MethodName_CaseSafe=setscale, childIdx=0, BeginColumn=9, MethodName=setScale}}: com.salesforce.graph.symbols.apex.ApexSimpleValue.apply(ApexSimpleValue.java:55);com.salesforce.graph.symbols.apex.ApexNumberValue.apply(ApexNumberValue.java:42);com.salesforce.graph.symbols.apex.ApexDecimalValue.apply(ApexDecimalValue.java:49);com.salesforce.graph.symbols.PathScopeVisitor.handleApexValueMethod(PathScopeVisitor.java:1487);com.salesforce.graph.symbols.PathScopeVisitor.afterVisit(PathScopeVisitor.java:1242);com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterVisit(DefaultSymbolProviderVertexVisitor.java:800)