Skip to content

Commit 1f77338

Browse files
committed
fix(appsec): capture all FileChannel.open args to avoid CSI generator partial-arg path
beforeOpenSet previously captured only 2 of 3 arguments, triggering the partial-argument code path in AdviceGeneratorImpl which calls Stream.sorted() without a comparator on ArgumentSpecification (not Comparable). Adding the unused FileAttribute[] third parameter makes the capture complete and sequential, so isPositionalArguments() returns false and the sorted() path is never entered.
1 parent b27caf4 commit 1f77338

File tree

1 file changed

+3
-1
lines changed
  • dd-java-agent/instrumentation/java/java-io-1.8/src/main/java/datadog/trace/instrumentation/java/lang

1 file changed

+3
-1
lines changed

dd-java-agent/instrumentation/java/java-io-1.8/src/main/java/datadog/trace/instrumentation/java/lang/FileChannelCallSite.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.nio.file.OpenOption;
66
import java.nio.file.Path;
77
import java.nio.file.StandardOpenOption;
8+
import java.nio.file.attribute.FileAttribute;
89
import java.util.Set;
910
import javax.annotation.Nullable;
1011

@@ -31,7 +32,8 @@ public static void beforeOpenArray(
3132
"java.nio.channels.FileChannel java.nio.channels.FileChannel.open(java.nio.file.Path, java.util.Set, java.nio.file.attribute.FileAttribute[])")
3233
public static void beforeOpenSet(
3334
@CallSite.Argument(0) @Nullable final Path path,
34-
@CallSite.Argument(1) @Nullable final Set<? extends OpenOption> options) {
35+
@CallSite.Argument(1) @Nullable final Set<? extends OpenOption> options,
36+
@CallSite.Argument(2) @Nullable final FileAttribute<?>[] attrs) {
3537
if (path != null) {
3638
String pathStr = path.toString();
3739
FileIORaspHelper.INSTANCE.beforeFileLoaded(pathStr);

0 commit comments

Comments
 (0)