Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ commands:
root: .
paths:
- node_modules/
install_maven:
description: Install maven
steps:
- run: apt-get update
- run: apt-get install -y maven
checkout_and_merge:
steps:
- checkout
Expand All @@ -49,6 +54,7 @@ jobs:
<<: *defaults
steps:
- install_deps
- install_maven
lint:
<<: *defaults
steps:
Expand Down
3 changes: 2 additions & 1 deletion lib/call-graph.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Graph } from 'graphlib';
import { removeParams, toFQclassName } from './class-parsing';
import { CallGraphNode } from './types';

function getNodeLabel(
functionCall: string,
classPerJarMapping: { [index: string]: string },
): {} {
): CallGraphNode {
// com.ibm.wala.FakeRootClass:fakeRootMethod
const [className, functionName] = functionCall.split(':');
const jarName = classPerJarMapping[className];
Expand Down
5 changes: 5 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface CallGraphNode {
className: string;
functionName: string;
jarName: string;
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"format": "prettier --write '{lib,test}/**/*.{js,ts,json,yml}'",
"lint": "npm run format:check && npm run lint:eslint",
"lint:eslint": "eslint --color --cache 'lib/**/*.{js,ts}'",
"test": "npm run lint && npm run test:unit",
"test:unit": "jest",
"test": "npm run lint && npm run test:unit && npm run test:system",
"test:unit": "jest unit",
"test:system": "jest system",
"test:coverage": "npm run test:unit -- --coverage",
"test:watch": "tsc-watch --onSuccess 'npm run test:unit'",
"build": "tsc",
Expand Down
142 changes: 142 additions & 0 deletions test/fixtures/java-project-integration-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cy.alavrov</groupId>
<artifactId>JMinerGuide</artifactId>
<version>0.2.0-DEVELOPMENT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<name>JMinerGuide</name>
<build>
<finalName>JMinerGuide</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>dist</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<useUniqueVersions>false</useUniqueVersions>
<mainClass>cy.alavrov.jminerguide.App</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/../dist/lib/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-exec</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/../dist/</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.build.finalName}.${project.packaging}</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
</build>
<dependencies>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.jdesktop</groupId>
<artifactId>beansbinding</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application.version=0.2.0-DEVELOPMENT
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
33 changes: 33 additions & 0 deletions test/system/maven-call-graph.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { getCallGraphMvn } from '../../lib';
import * as path from 'path';
import { CallGraphNode } from '../../lib/types';

jest.setTimeout(60000);

test('simple call graph', async () => {
const callGraph = await getCallGraphMvn(
path.join(__dirname, '../fixtures/java-project-integration-test'),
);

expect(callGraph.edgeCount()).toBeGreaterThan(0);
expect(callGraph.nodeCount()).toBeGreaterThan(0);
expect(
callGraph.hasNode('cy.alavrov.jminerguide.data.ship.Ship:getMaxDrones'),
).toBeTruthy;

const userLandNode = callGraph.node(
'cy.alavrov.jminerguide.data.ship.Ship:getMaxDrones',
) as CallGraphNode;
expect(userLandNode.className).toEqual(
'cy.alavrov.jminerguide.data.ship.Ship',
);
expect(userLandNode.functionName).toEqual('getMaxDrones');
expect(userLandNode.jarName).toBeUndefined(); // user land code doesn't have a jar

const thirdPartyNode = callGraph.node(
'java.util.zip.Inflater:finalize',
) as CallGraphNode;
expect(thirdPartyNode.className).toEqual('java.util.zip.Inflater');
expect(thirdPartyNode.functionName).toEqual('finalize');
expect(thirdPartyNode.jarName).toBeUndefined(); // TODO seems like a bug
});