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] Graph scan throws Internal Exception in output and log when scanning a method that contains Describe Tabs code #1191

Closed
vc4u opened this issue Sep 21, 2023 · 4 comments
Labels
BUG P2 Malfunctioning Often duplicate This issue or pull request already exists SFGE Issues related to the Salesforce Graph Engine

Comments

@vc4u
Copy link

vc4u commented Sep 21, 2023

Describe the bug
DFA scan generated output report and log files are showing an internal exception.

Error:

2023-09-22 02:18:35 ERROR ThreadableRuleExecutor:208 - Internal Error executing rule. submission=RuleRunnerSubmission{pathEntry=Method{properties={FirstChild=false, BeginLine=106, DefiningType_CaseSafe=util, LastChild=false, DefiningType=util, Constructor=false, EndLine=106, Name_CaseSafe=geticonname, childIdx=17, ReturnType=String, Name=getIconName, Arity=1, ReturnType_CaseSafe=string, BeginColumn=26}}, rules=[com.salesforce.rules.ApexFlsViolationRule@49b5d1e7, com.salesforce.rules.UseWithSharingOnDatabaseOperation@42442b03]}
com.salesforce.exception.UnexpectedException: ApexStandardValue{apexType='System.Schema'} ApexValue(SystemSchema) {status=INITIALIZED, declarationVertex=null, valueVertex=null, resolvedValues={}, returnedFrom=null, invocableExpression=null, method=null}
at com.salesforce.graph.symbols.apex.system.SystemSchema.executeMethod(SystemSchema.java:106) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.symbols.PathScopeVisitor.afterMethodCall(PathScopeVisitor.java:659) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.symbols.DefaultSymbolProviderVertexVisitor.afterMethodCall(DefaultSymbolProviderVertexVisitor.java:318) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.handleMethodCall(ApexPathExpander.java:681) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:532) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:523) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:523) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:452) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.handleMethodCall(ApexPathExpander.java:676) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:532) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:523) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:452) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpanderUtil$ApexPathExpansionHandler.expand(ApexPathExpanderUtil.java:223) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpanderUtil$ApexPathExpansionHandler.expand(ApexPathExpanderUtil.java:162) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpanderUtil$ApexPathExpansionHandler._expand(ApexPathExpanderUtil.java:96) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpanderUtil$ApexPathExpansionHandler.access$100(ApexPathExpanderUtil.java:70) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.expander.ApexPathExpanderUtil.expand(ApexPathExpanderUtil.java:55) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.ApexPathUtil.getPaths(ApexPathUtil.java:201) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.graph.ops.ApexPathUtil.summarizeForwardPaths(ApexPathUtil.java:80) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.rules.PathBasedRuleRunner.getPathSummary(PathBasedRuleRunner.java:222) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.rules.PathBasedRuleRunner.runRules(PathBasedRuleRunner.java:75) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.runRules(ThreadableRuleExecutor.java:230) ~[sfge-1.0.1-pilot.jar:?]
at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.call(ThreadableRuleExecutor.java:167) [sfge-1.0.1-pilot.jar:?]
at com.salesforce.rules.ThreadableRuleExecutor$CallableExecutor.call(ThreadableRuleExecutor.java:127) [sfge-1.0.1-pilot.jar:?]
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1428) [?:?]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) [?:?]
at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:686) [?:?]
at java.util.concurrent.ForkJoinTask$AdaptedCallable.run(ForkJoinTask.java:1436) [?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395) [?:?]
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) [?:?]
at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) [?:?]
at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) [?:?]
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) [?:?]
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) [?:?]
2023-09-22 02:18:35 INFO ThreadableRuleExecutor:216 - Finished. method=util:getIconName:106

Method:

global static String getIconName(String sObjectName, boolean returnDefaultIfNone) {
	String u;
	List<Schema.DescribeTabSetResult> tabSetDesc    = Schema.describeTabs();
	List<Schema.DescribeTabResult> tabDesc          = new List<Schema.DescribeTabResult>();
	List<Schema.DescribeIconResult> iconDesc        = new List<Schema.DescribeIconResult>();

	for(Schema.DescribeTabSetResult tsr : tabSetDesc) { tabDesc.addAll(tsr.getTabs()); }

	for(Schema.DescribeTabResult tr : tabDesc) {
		if( sObjectName == tr.getSobjectName() ) {
			if( tr.isCustom() == true ) {
				iconDesc.addAll(tr.getIcons());
			} else {
				u = 'standard:' + sObjectName.toLowerCase();
			}
		}
	}
	for (Schema.DescribeIconResult ir : iconDesc) {
		if (ir.getContentType() == 'image/svg+xml'){
			u = 'custom:' + ir.getUrl().substringBetween('custom/','.svg').substringBefore('_');
			break;
		}
	}
	if (string.isBlank(u) && returnDefaultIfNone == true) {
		u = 'standard:custom';
	}
	return u;
}

To Reproduce

Execute following command for the method provided above:
sf scanner run dfa -f html -o CodeAnalyzerDFA.html -p ./force-app/main/default -t ./force-app/main/default/classes/util.cls#getIconName --category "Security" --rule-thread-count 10 --sfgejvmargs "-Xmx4g" --pathexplimit "-1" --rule-thread-timeout 90000

Expected behavior
Error should not be thrown, there is NO FLS or CRUD violation in provided method.

Desktop (please complete the following information):

  • OS: Windows 10 x64
  • Scanner Version: v3.16.0

"Workaround":
No

"Urgency":
"Business stopping" as unable to scan project due to multiple errors thrown on similar lines all over the code base.

@jfeingold35 jfeingold35 added the BUG P2 Malfunctioning Often label Sep 22, 2023
@git2gus
Copy link

git2gus bot commented Sep 22, 2023

This issue has been linked to a new work item: W-14169354

@vc4u
Copy link
Author

vc4u commented Sep 22, 2023

Is there any workaround to this? Or is there a way we can suppress scanning for this method?

Since no Error code being generated for this, I don't know how to suppress scanning of this - our scanner logs are bombarded with this and almost all other classes (after running for hours) are reporting either timeout or Internal Server Error like this:

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: ApexStandardValue{apexType='System.Schema'} ApexValue(SystemSchema) {status=INITIALIZED, declarationVertex=null, valueVertex=null, resolvedValues={}, returnedFrom=null, invocableExpression=null, method=null}: com.salesforce.graph.symbols.apex.system.SystemSchema.executeMethod(SystemSchema.java:106);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);com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:532);com.salesforce.graph.ops.expander.ApexPathExpander.visit(ApexPathExpander.java:523)

@jfeingold35
Copy link
Collaborator

@vc4u , I understand your frustration, but unfortunately I don't think there's a workaround for this. We've added it to our backlog, and we can assess the level of effort that would be involved in a fix. We appreciate your patience in the meantime.

@johnbelosf johnbelosf changed the title Graph scan throws Internal Exception in output and log when scanning a method that contains Describe Tabs code [BUG] Graph scan throws Internal Exception in output and log when scanning a method that contains Describe Tabs code Feb 20, 2024
@stephen-carter-at-sf stephen-carter-at-sf added the SFGE Issues related to the Salesforce Graph Engine label May 23, 2024
@stephen-carter-at-sf stephen-carter-at-sf added the duplicate This issue or pull request already exists label Jun 3, 2024
@stephen-carter-at-sf
Copy link
Collaborator

Marking this as a duplicate of #1497

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BUG P2 Malfunctioning Often duplicate This issue or pull request already exists SFGE Issues related to the Salesforce Graph Engine
Projects
None yet
Development

No branches or pull requests

3 participants