forked from whwlsfb/JDumpSpider
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cn.wanghw.spider; | ||
|
||
import cn.wanghw.ISpider; | ||
import cn.wanghw.utils.HashMapUtils; | ||
import org.graalvm.visualvm.lib.jfluid.heap.Heap; | ||
import org.graalvm.visualvm.lib.profiler.oql.engine.api.OQLEngine; | ||
|
||
import java.util.HashMap; | ||
|
||
public class DataSource04 implements ISpider { | ||
@Override | ||
public String getName() { | ||
return "AliDruidDataSourceWrapper"; | ||
} | ||
|
||
@Override | ||
public String sniff(Heap heap) { | ||
final String[] result = {""}; | ||
try { | ||
OQLEngine oqlEngine = new OQLEngine(heap); | ||
oqlEngine.executeQuery("select {'username':x.username.toString(), 'password':x.password.toString(), 'jdbcUrl': x.jdbcUrl.toString()} from com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper x", o -> { | ||
if (o instanceof HashMap) { | ||
HashMap<String, String> hashMap = (HashMap<String, String>) o; | ||
result[0] += HashMapUtils.dumpString(hashMap, false) + "\r\n"; | ||
} | ||
return false; | ||
}); | ||
} catch (Exception ex) { | ||
if (!result[0].equals("")) { | ||
result[0] = "not found!"; | ||
} | ||
} | ||
return result[0]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cn.wanghw.utils; | ||
|
||
public class OQLSnippets { | ||
public static final String isNullOrUndefined = "function isNullOrUndefined(val) {\n" + | ||
" return val == null || val == undefined\n" + | ||
"}\n"; | ||
public static final String getValue = isNullOrUndefined + "function getValue(val) {\n" + | ||
" return !isNullOrUndefined(val.value) ? !isNullOrUndefined(val.value.value) ? !isNullOrUndefined(val.value.value.value) ? val.value.value.value.toString() : val.value.value.toString() : val.value.toString() : val.toString();\n" + | ||
"}\n"; | ||
} |