From fce460eae6b9c45e809cf44dd94c0d7bf262f21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Leuth=C3=A4user?= <1417198+max-leuthaeuser@users.noreply.github.com> Date: Mon, 19 Oct 2026 17:37:19 +0200 Subject: [PATCH 1/2] Remove better.files dependency Replace its only usage (TestProtoCpg) with java.nio and java.util.zip, and drop the dependency from sbt and bazel (incl. maven_install.json). --- MODULE.bazel | 1 - codepropertygraph/BUILD | 1 - codepropertygraph/build.sbt | 1 - .../cpgloading/TestProtoCpg.scala | 76 +++++++++++-------- maven_install.json | 15 ---- proto-bindings/build.sbt | 1 - 6 files changed, 44 insertions(+), 51 deletions(-) diff --git a/MODULE.bazel b/MODULE.bazel index 7ba661224..98f74d01f 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -47,7 +47,6 @@ maven.install( "com.google.protobuf:protobuf-java:4.34.1", "com.lihaoyi:ujson_3:4.4.3", "com.lihaoyi:os-lib_3:0.11.4", - "com.github.pathikrit:better-files_3:3.9.2", ], excluded_artifacts = [ # Exclude any scala libraries which might come in transitively. diff --git a/codepropertygraph/BUILD b/codepropertygraph/BUILD index d4a93cff9..7ae0a12fd 100644 --- a/codepropertygraph/BUILD +++ b/codepropertygraph/BUILD @@ -44,7 +44,6 @@ scala_test( ":tests_java", "//schema:domainClassesNeverLinked", "//schema:java_proto", - "@maven//:com_github_pathikrit_better_files_3", "@maven//:io_joern_flatgraph_core_3", "@maven//:io_joern_flatgraph_help_3", ], diff --git a/codepropertygraph/build.sbt b/codepropertygraph/build.sbt index f335e1138..04599ac70 100644 --- a/codepropertygraph/build.sbt +++ b/codepropertygraph/build.sbt @@ -7,7 +7,6 @@ libraryDependencies ++= Seq( "io.joern" %% "flatgraph-help" % Versions.flatgraph, "io.joern" %% "flatgraph-odb-convert" % Versions.flatgraph, "com.github.scopt" %% "scopt" % "4.0.1", - "com.github.pathikrit" %% "better-files" % "3.9.2", "org.slf4j" % "slf4j-api" % "2.0.6", "org.scalatest" %% "scalatest" % Versions.scalatest % Test ) diff --git a/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala b/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala index 9bb1c4fae..4e06b3f42 100644 --- a/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala +++ b/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala @@ -1,46 +1,58 @@ package io.shiftleft.codepropertygraph.cpgloading -import better.files.File import io.shiftleft.proto.cpg.Cpg import io.shiftleft.proto.cpg.Cpg.CpgStruct -import java.io.FileOutputStream import java.nio.file.{Files, Path} +import java.util.zip.{ZipEntry, ZipOutputStream} object TestProtoCpg { def createTestProtoCpg: Path = { - val outDir = better.files.File.newTemporaryDirectory("cpgloadertests") - val outStream = new FileOutputStream((outDir / "1.proto").pathAsString) - CpgStruct - .newBuilder() - .addNode( - CpgStruct.Node - .newBuilder() - .setKey(1) - .setType(CpgStruct.Node.NodeType.valueOf("METHOD")) - .addProperty( - CpgStruct.Node.Property - .newBuilder() - .setName(Cpg.NodePropertyName.valueOf("FULL_NAME")) - .setValue( - Cpg.PropertyValue - .newBuilder() - .setStringValue("foo") - .build() - ) - .build - ) - .build() - ) - .build() - .writeTo(outStream) - outStream.close() + val outDir = Files.createTempDirectory("cpgloadertests") + val protoFile = outDir.resolve("1.proto") + val outStream = Files.newOutputStream(protoFile) + try { + CpgStruct + .newBuilder() + .addNode( + CpgStruct.Node + .newBuilder() + .setKey(1) + .setType(CpgStruct.Node.NodeType.valueOf("METHOD")) + .addProperty( + CpgStruct.Node.Property + .newBuilder() + .setName(Cpg.NodePropertyName.valueOf("FULL_NAME")) + .setValue( + Cpg.PropertyValue + .newBuilder() + .setStringValue("foo") + .build() + ) + .build + ) + .build() + ) + .build() + .writeTo(outStream) + } finally { + outStream.close() + } - val zipFile = better.files.File.newTemporaryFile("cpgloadertests", ".bin.zip") - outDir.zipTo(zipFile) - outDir.delete() - zipFile.path + val zipFile = Files.createTempFile("cpgloadertests", ".bin.zip") + val zipStream = new ZipOutputStream(Files.newOutputStream(zipFile)) + try { + zipStream.putNextEntry(new ZipEntry("1.proto")) + Files.copy(protoFile, zipStream) + zipStream.closeEntry() + } finally { + zipStream.close() + } + + Files.delete(protoFile) + Files.delete(outDir) + zipFile } } diff --git a/maven_install.json b/maven_install.json index 18d4808e0..75343a6d3 100644 --- a/maven_install.json +++ b/maven_install.json @@ -1,7 +1,6 @@ { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", "__INPUT_ARTIFACTS_HASH": { - "com.github.pathikrit:better-files_3": 2078137804, "com.google.code.findbugs:jsr305": 495355163, "com.google.code.gson:gson": 597770368, "com.google.errorprone:error_prone_annotations": -1035138750, @@ -23,8 +22,6 @@ "__RESOLVED_ARTIFACTS_HASH": { "com.github.luben:zstd-jni": 1886873774, "com.github.luben:zstd-jni:jar:sources": -1190847340, - "com.github.pathikrit:better-files_3": -730147472, - "com.github.pathikrit:better-files_3:jar:sources": -1753499885, "com.github.scopt:scopt_3": 148843063, "com.github.scopt:scopt_3:jar:sources": 776003799, "com.google.code.findbugs:jsr305": 870839855, @@ -100,13 +97,6 @@ }, "version": "1.5.7-11" }, - "com.github.pathikrit:better-files_3": { - "shasums": { - "jar": "136c1770a63aa33b2710745bf7f8441cbbe0eeef0cab6b832bd0a46804158989", - "sources": "5a3d4cc0c63605353b1c528abfdc180ae4d74b6c50d6693eee4389dcec923e61" - }, - "version": "3.9.2" - }, "com.github.scopt:scopt_3": { "shasums": { "jar": "7cfb80743b761b3df8630a818265eb91fd93cd77b32ed5ebd6fba1bb7cff6a3f", @@ -395,9 +385,6 @@ "com.github.luben.zstd", "com.github.luben.zstd.util" ], - "com.github.pathikrit:better-files_3": [ - "better.files" - ], "com.github.scopt:scopt_3": [ "scopt" ], @@ -773,8 +760,6 @@ "https://repo1.maven.org/maven2/": [ "com.github.luben:zstd-jni", "com.github.luben:zstd-jni:jar:sources", - "com.github.pathikrit:better-files_3", - "com.github.pathikrit:better-files_3:jar:sources", "com.github.scopt:scopt_3", "com.github.scopt:scopt_3:jar:sources", "com.google.code.findbugs:jsr305", diff --git a/proto-bindings/build.sbt b/proto-bindings/build.sbt index 9740f2d36..5f2f4e76d 100644 --- a/proto-bindings/build.sbt +++ b/proto-bindings/build.sbt @@ -27,7 +27,6 @@ lazy val installProtoc = installProtoc := { import sys.process._ import java.nio.file.Files - // import better.files.FileExtensions val protocVersion = (ProtobufConfig / version).value val protocBinary = new File(protocBinaryPath) val isAlreadyInstalled = protocBinary.exists && s"$protocBinaryPath --version".!!.contains(protocVersion) From 108699f84fb163daa115edcd79ae1af83cbd9a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Leuth=C3=A4user?= <1417198+max-leuthaeuser@users.noreply.github.com> Date: Mon, 19 Oct 2026 18:07:38 +0200 Subject: [PATCH 2/2] format --- .../shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala b/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala index 4e06b3f42..4f3a5c753 100644 --- a/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala +++ b/codepropertygraph/src/test/scala/io/shiftleft/codepropertygraph/cpgloading/TestProtoCpg.scala @@ -9,7 +9,7 @@ import java.util.zip.{ZipEntry, ZipOutputStream} object TestProtoCpg { def createTestProtoCpg: Path = { - val outDir = Files.createTempDirectory("cpgloadertests") + val outDir = Files.createTempDirectory("cpgloadertests") val protoFile = outDir.resolve("1.proto") val outStream = Files.newOutputStream(protoFile) try {