From ec9bd90a73be13023e6e462b926c2b9e09f09b05 Mon Sep 17 00:00:00 2001 From: Prabhu Subramanian Date: Tue, 9 Jan 2024 10:46:04 +0000 Subject: [PATCH] Crash fix Signed-off-by: Prabhu Subramanian --- .github/workflows/pr.yml | 1 + .../main/scala/io/appthreat/php2atom/parser/PhpParser.scala | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ec354800..aaaacef9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -80,4 +80,5 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8 -Djna.library.path=${{ env.Python3_ROOT_DIR }}" SCALAPY_PYTHON_LIBRARY: "python311" + PHP_PARSER_BIN: "${{ env.GITHUB_WORKSPACE }}\platform\frontends\php2atom\vendor\bin\php-parse" if: runner.os == 'Windows' diff --git a/platform/frontends/php2atom/src/main/scala/io/appthreat/php2atom/parser/PhpParser.scala b/platform/frontends/php2atom/src/main/scala/io/appthreat/php2atom/parser/PhpParser.scala index ecdcdca0..19625118 100644 --- a/platform/frontends/php2atom/src/main/scala/io/appthreat/php2atom/parser/PhpParser.scala +++ b/platform/frontends/php2atom/src/main/scala/io/appthreat/php2atom/parser/PhpParser.scala @@ -28,7 +28,7 @@ class PhpParser private (phpParserPath: String, phpIniPath: String): val command = phpParseCommand(inputFilePath) - ExternalCommand.runMultiple(command, inputDirectory) match + ExternalCommand.run(command, inputDirectory, true) match case Success(output) => processParserOutput(output, inputFilePath) @@ -36,9 +36,9 @@ class PhpParser private (phpParserPath: String, phpIniPath: String): logger.debug(s"Failure running php-parser with $command", exception.getMessage) None - private def processParserOutput(output: String, filename: String): Option[PhpFile] = + private def processParserOutput(output: Seq[String], filename: String): Option[PhpFile] = val maybeJson = - linesToJsonValue(output.split(System.lineSeparator()).toIndexedSeq, filename) + linesToJsonValue(output, filename) maybeJson.flatMap(jsonValueToPhpFile(_, filename)) private def linesToJsonValue(lines: Seq[String], filename: String): Option[ujson.Value] =