-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJava_Reflection_usage.cypher
17 lines (16 loc) · 1 KB
/
Java_Reflection_usage.cypher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Query Java Reflection usage combined with invocations of "Class.forName". Requires "Add_file_name and_extension.cypher".
MATCH (dependentArtifact:Artifact)-[:CONTAINS]-(dependentType:Type)
WITH dependentArtifact.name AS dependentArtifactName
,dependentType
OPTIONAL MATCH (dependentType)-[:DEPENDS_ON]->(reflectionType:Type)
WHERE reflectionType.fqn STARTS WITH 'java.lang.reflect.'
OPTIONAL MATCH (dependentType)-[:DECLARES]->(dependentMethod:Method)-[:INVOKES]->(classForName:Method)
WHERE classForName.signature STARTS WITH 'java.lang.Class forName'
WITH dependentArtifactName
,collect(DISTINCT coalesce(reflectionType.fqn, 'Class.' + classForName.name)) AS reflectionTypes
,collect(DISTINCT dependentType.fqn) AS reflectionCaller
,count(DISTINCT dependentType.fqn) AS numberOfReflectionCaller
RETURN dependentArtifactName
,numberOfReflectionCaller
,reflectionCaller[0..19] AS someReflectionCaller
,reflectionTypes[0..19] AS someReflectionTypes