-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add fingerprints for JDK classes #63
Conversation
watchdog-agent/src/main/java/io/github/algomaster99/Options.java
Outdated
Show resolved
Hide resolved
Oh, so some class is not recognized if we index the jdk classes. |
The error is:
Super interesting that we have different hashes |
Here is the list of all classes:
I am also getting some un-whitelisted classes. |
The GeneratedClasses are a Result of reflection and should be detectable hopefully, see https://support.oracle.com/knowledge/Middleware/1669883_1.html. |
Okay. Should I look into it, or are you doing it? |
I am doing it |
@MartinWitt added method to skip the ASM generated classes. We can merge this once we identify the difference between the JDK classes. |
--- foo.txt/who-2023-08-25 18:13:56.580294255 +0200iff -u foo.txt moduleFinder.txt ✔ at 18:14:15
+++ moduleFinder.txt 2023-08-25 18:14:15.760310815 +0200
@@ -1,15 +1,15 @@
17.0.5
-Classfile /home/aman/personal/who-are-you/foo.class
- Last modified Aug 25, 2023; size 13513 bytes
- SHA-256 checksum a3c9aea8fdc0c03ddf28ce1134f7b0436cf518254b2522ed59b2b2d262f295d7
+Classfile /home/aman/personal/who-are-you/moduleFinder.class
+ Last modified Aug 25, 2023; size 13539 bytes
+ SHA-256 checksum 91909cea1f05909dccbd419b6fd21f605a199685b16599d7304e742ea21bda26
Compiled from "JrtFileSystemProvider.java"
public final class jdk.internal.jrtfs.JrtFileSystemProvider extends java.nio.file.spi.FileSystemProvider
minor version: 0
- major version: 52
+ major version: 61
flags: (0x0031) ACC_PUBLIC, ACC_FINAL, ACC_SUPER
this_class: #35 // jdk/internal/jrtfs/JrtFileSystemProvider
super_class: #2 // java/nio/file/spi/FileSystemProvider
- interfaces: 0, fields: 2, methods: 30, attributes: 2
+ interfaces: 0, fields: 2, methods: 30, attributes: 3
Constant pool:
#1 = Methodref #2.#3 // java/nio/file/spi/FileSystemProvider."<init>":()V
#2 = Class #4 // java/nio/file/spi/FileSystemProvider
@@ -447,15 +447,16 @@
#434 = Utf8 value
#435 = Utf8 SourceFile
#436 = Utf8 JrtFileSystemProvider.java
- #437 = Utf8 InnerClasses
- #438 = Class #439 // java/nio/file/DirectoryStream$Filter
- #439 = Utf8 java/nio/file/DirectoryStream$Filter
- #440 = Class #441 // java/nio/file/DirectoryStream
- #441 = Utf8 java/nio/file/DirectoryStream
- #442 = Utf8 Filter
- #443 = Class #444 // jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader
- #444 = Utf8 jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader
- #445 = Utf8 JrtFsLoader
+ #437 = Utf8 NestMembers
+ #438 = Class #439 // jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader
+ #439 = Utf8 jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader
+ #440 = Utf8 InnerClasses
+ #441 = Class #442 // java/nio/file/DirectoryStream$Filter
+ #442 = Utf8 java/nio/file/DirectoryStream$Filter
+ #443 = Class #444 // java/nio/file/DirectoryStream
+ #444 = Utf8 java/nio/file/DirectoryStream
+ #445 = Utf8 Filter
+ #446 = Utf8 JrtFsLoader
{
private volatile java.nio.file.FileSystem theFileSystem;
descriptor: Ljava/nio/file/FileSystem;
@@ -622,10 +623,10 @@
1: invokestatic #76 // Method java/util/Objects.requireNonNull:(Ljava/lang/Object;)Ljava/lang/Object;
4: pop
5: aload_0
- 6: invokespecial #82 // Method checkPermission:()V
+ 6: invokevirtual #82 // Method checkPermission:()V
9: aload_0
10: aload_1
- 11: invokespecial #84 // Method checkUri:(Ljava/net/URI;)V
+ 11: invokevirtual #84 // Method checkUri:(Ljava/net/URI;)V
14: aload_2
15: ldc #88 // String java.home
17: invokeinterface #90, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
@@ -637,7 +638,7 @@
34: checkcast #38 // class java/lang/String
37: aload_1
38: aload_2
- 39: invokespecial #98 // Method newFileSystem:(Ljava/lang/String;Ljava/net/URI;Ljava/util/Map;)Ljava/nio/file/FileSystem;
+ 39: invokevirtual #98 // Method newFileSystem:(Ljava/lang/String;Ljava/net/URI;Ljava/util/Map;)Ljava/nio/file/FileSystem;
42: areturn
43: new #102 // class jdk/internal/jrtfs/JrtFileSystem
46: dup
@@ -846,7 +847,7 @@
Code:
stack=3, locals=3, args_size=2
0: aload_0
- 1: invokespecial #82 // Method checkPermission:()V
+ 1: invokevirtual #82 // Method checkPermission:()V
4: aload_1
5: invokevirtual #28 // Method java/net/URI.getScheme:()Ljava/lang/String;
8: aload_0
@@ -902,7 +903,7 @@
113: invokespecial #47 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
116: athrow
117: aload_0
- 118: invokespecial #223 // Method getTheFileSystem:()Ljava/nio/file/FileSystem;
+ 118: invokevirtual #223 // Method getTheFileSystem:()Ljava/nio/file/FileSystem;
121: new #132 // class java/lang/StringBuilder
124: dup
125: invokespecial #134 // Method java/lang/StringBuilder."<init>":()V
@@ -950,7 +951,7 @@
Code:
stack=5, locals=5, args_size=1
0: aload_0
- 1: invokespecial #82 // Method checkPermission:()V
+ 1: invokevirtual #82 // Method checkPermission:()V
4: aload_0
5: getfield #228 // Field theFileSystem:Ljava/nio/file/FileSystem;
8: astore_1
@@ -1031,12 +1032,12 @@
Code:
stack=2, locals=2, args_size=2
0: aload_0
- 1: invokespecial #82 // Method checkPermission:()V
+ 1: invokevirtual #82 // Method checkPermission:()V
4: aload_0
5: aload_1
- 6: invokespecial #84 // Method checkUri:(Ljava/net/URI;)V
+ 6: invokevirtual #84 // Method checkUri:(Ljava/net/URI;)V
9: aload_0
- 10: invokespecial #223 // Method getTheFileSystem:()Ljava/nio/file/FileSystem;
+ 10: invokevirtual #223 // Method getTheFileSystem:()Ljava/nio/file/FileSystem;
13: areturn
LineNumberTable:
line 222: 0
@@ -1517,7 +1518,10 @@
throws java.io.IOException
}
SourceFile: "JrtFileSystemProvider.java"
+NestMembers:
+ jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader
+ jdk/internal/jrtfs/JrtFileSystemProvider$1
InnerClasses:
#198; // class jdk/internal/jrtfs/JrtFileSystemProvider$1
- public static #442= #438 of #440; // Filter=class java/nio/file/DirectoryStream$Filter of class java/nio/file/DirectoryStream
- private static #445= #443 of #35; // JrtFsLoader=class jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader of class jdk/internal/jrtfs/JrtFileSystemProvider
+ public static #445= #441 of #443; // Filter=class java/nio/file/DirectoryStream$Filter of class java/nio/file/DirectoryStream
+ private static #446= #438 of #35; // JrtFsLoader=class jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader of class jdk/internal/jrtfs/JrtFileSystemProvider There is at least a difference in class file versions. This is so weird. Why is it even getting a class from
|
Okay, the |
Okay I found three different versions of the same class file with the modulefinder. Will investigate. |
I found the problem in a way too long debugging section. We will switch from modulefinder to classgraph. |
This reverts commit c6eddf3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Let's merge this tomorrow :D
...-commons/src/main/java/io/github/algomaster99/terminator/commons/fingerprint/JdkIndexer.java
Outdated
Show resolved
Hide resolved
...mons/src/main/java/io/github/algomaster99/terminator/commons/fingerprint/provenance/Jdk.java
Show resolved
Hide resolved
// FIXME: we need to check inner classes without loading them. Maybe add the hashes for inner classes in the | ||
// fingerprints? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is added by default.
public class A {
static class B { }
}
will be compiled to A.class
and A$B.class
. Or do you mean something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be compiled to a single class file. The files are currently missing in the index for jars.
Co-authored-by: Aman Sharma <[email protected]>
This reverts commit 6ff64f3.
Fixes #62