joern icon indicating copy to clipboard operation
joern copied to clipboard

[Bug][csharpsrc2cpg]Unable to create cpg for c# code

Open wooyune1 opened this issue 1 year ago • 1 comments

Describe the bug Unable to create cpg for c# code.The following error occurs:

[main] INFO io.joern.csharpsrc2cpg.utils.DotNetAstGenRunner - Running dotnetastgen on 'D:\Workspace\Java\CsharpAnalysis\src\main\resources'
[main] ERROR io.joern.csharpsrc2cpg.utils.DotNetAstGenRunner - 	- running dotnetastgen failed!
java.lang.RuntimeException: 
	at io.joern.x2cpg.utils.ExternalCommand.handleRunResult(ExternalCommand.scala:22)
	at io.joern.x2cpg.utils.ExternalCommand.handleRunResult$(ExternalCommand.scala:8)
	at io.joern.x2cpg.utils.ExternalCommand$.handleRunResult(ExternalCommand.scala:39)
	at io.joern.x2cpg.utils.ExternalCommand.run(ExternalCommand.scala:34)
	at io.joern.x2cpg.utils.ExternalCommand.run$(ExternalCommand.scala:8)
	at io.joern.x2cpg.utils.ExternalCommand$.run(ExternalCommand.scala:39)
	at io.joern.csharpsrc2cpg.utils.DotNetAstGenRunner.runAstGenNative(DotNetAstGenRunner.scala:67)
	at io.joern.x2cpg.astgen.AstGenRunnerBase.execute(AstGenRunner.scala:181)
	at io.joern.x2cpg.astgen.AstGenRunnerBase.execute$(AstGenRunner.scala:83)
	at io.joern.csharpsrc2cpg.utils.DotNetAstGenRunner.execute(DotNetAstGenRunner.scala:14)
	at io.joern.csharpsrc2cpg.CSharpSrc2Cpg.createCpg$$anonfun$1$$anonfun$1(CSharpSrc2Cpg.scala:36)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
	at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
	at better.files.Dispose.apply(Dispose.scala:75)
	at better.files.Dispose.foreach(Dispose.scala:91)
	at better.files.File$.usingTemporaryDirectory(File.scala:1320)
	at io.joern.csharpsrc2cpg.CSharpSrc2Cpg.createCpg$$anonfun$1(CSharpSrc2Cpg.scala:68)
	at scala.runtime.function.JProcedure2.apply(JProcedure2.java:15)
	at scala.runtime.function.JProcedure2.apply(JProcedure2.java:10)
	at io.joern.x2cpg.X2Cpg$.withNewEmptyCpg$$anonfun$1$$anonfun$1(X2Cpg.scala:322)
	at io.joern.x2cpg.X2Cpg$.$anonfun$adapted$1(X2Cpg.scala:323)
	at scala.util.Try$.apply(Try.scala:210)
	at io.joern.x2cpg.X2Cpg$.withNewEmptyCpg$$anonfun$1(X2Cpg.scala:323)
	at scala.util.Try$.apply(Try.scala:210)
	at io.joern.x2cpg.X2Cpg$.withNewEmptyCpg(X2Cpg.scala:329)
	at io.joern.csharpsrc2cpg.CSharpSrc2Cpg.createCpg(CSharpSrc2Cpg.scala:69)
	at TaintAnalysis$.run(TaintAnalysis.scala:39)
	at Main$.main(Main.scala:3)
	at Main.main(Main.scala)

To Reproduce my code

  def run(): Unit = {
    val config = Config()
      .withInputPath("src\\main\\resources")

    implicit val cpg: Cpg = new CSharpSrc2Cpg().createCpg(config).get
  }

c# code to parse

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int a = i + 1;
            Console.WriteLine(a);
        }
    }
}

Desktop (please complete the following information):

  • Windows11
  • io.joern:csharpsrc2cpg_3:4.0.35
  • jdk 17

wooyune1 avatar Aug 15 '24 07:08 wooyune1

same question

wozhendeshuai avatar Oct 03 '24 03:10 wozhendeshuai