mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
core unit tests working
This commit is contained in:
parent
a73fac0e07
commit
55db946b0d
2
thirdparty/ClasspathSimplification/.gitignore
vendored
Normal file
2
thirdparty/ClasspathSimplification/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/target/*
|
||||||
|
!/target/ClasspathSimplification-1.0-jar-with-dependencies.jar
|
50
thirdparty/ClasspathSimplification/pom.xml
vendored
Normal file
50
thirdparty/ClasspathSimplification/pom.xml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?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>org.sleuthkit.autopsy.classpathsimplication</groupId>
|
||||||
|
<artifactId>ClasspathSimplification</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<exec.mainClass>org.sleuthkit.autopsy.classpathsimplication.classpathsimplification.ClasspathSimplification</exec.mainClass>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.ant/ant -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ant</groupId>
|
||||||
|
<artifactId>ant</artifactId>
|
||||||
|
<version>1.10.12</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>org.sleuthkit.autopsy.classpathsimplification.ClasspathSimplification</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>make-assembly</id> <!-- this is used for inheritance merges -->
|
||||||
|
<phase>package</phase> <!-- bind to the packaging phase -->
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Autopsy Forensic Browser
|
||||||
|
*
|
||||||
|
* Copyright 2022 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.classpathsimplification;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.Task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplifies a class path from a list of jar files separated by ':' to a list
|
||||||
|
* of directories ending of format '/dir/path/to/jars/*'
|
||||||
|
*/
|
||||||
|
public class ClasspathSimplification extends Task {
|
||||||
|
|
||||||
|
// split on ':' but not 'C:\'
|
||||||
|
private static Pattern CLASS_PATH_REGEX = Pattern.compile("((C:\\\\)?.+?)(:|$)");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param args The command line arguments.
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println(getSimplifiedClasspath(args.length < 1 ? null : args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
String originalClassPath;
|
||||||
|
String outputprop;
|
||||||
|
|
||||||
|
public void setClasspath(String originalClassPath) {
|
||||||
|
this.originalClassPath = originalClassPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutputprop(String outputprop) {
|
||||||
|
this.outputprop = outputprop;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() throws BuildException {
|
||||||
|
if (outputprop != null && !outputprop.trim().isEmpty()) {
|
||||||
|
log("Simplifying path...");
|
||||||
|
String simplified = getSimplifiedClasspath(originalClassPath);
|
||||||
|
getProject().setProperty(outputprop, simplified);
|
||||||
|
} else {
|
||||||
|
log("No output property provided!", Level.WARNING.getSeverity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simplifies a class path from a list of jar files separated by ':' to a
|
||||||
|
* list of directories ending of format '/dir/path/to/jars/*'
|
||||||
|
*
|
||||||
|
* @param origPath The original path with jar file paths separated by ':'
|
||||||
|
* @return The parent folders ending with '*' separated by ':'.
|
||||||
|
*/
|
||||||
|
public static String getSimplifiedClasspath(String origPath) {
|
||||||
|
Set<String> directories = new HashSet<>();
|
||||||
|
if (origPath == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher pathMatch = CLASS_PATH_REGEX.matcher(origPath);
|
||||||
|
while (pathMatch.find()) {
|
||||||
|
String thisPath = pathMatch.group(1).trim();
|
||||||
|
if (thisPath.toLowerCase().endsWith(".jar")) {
|
||||||
|
directories.add(Paths.get(thisPath).getParent().toAbsolutePath().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return directories.stream()
|
||||||
|
.sorted((a, b) -> a.compareToIgnoreCase(b))
|
||||||
|
.map(path -> path.endsWith(File.separator) ? path + "*" : path + File.separator + "*")
|
||||||
|
.collect(Collectors.joining(":"));
|
||||||
|
}
|
||||||
|
}
|
BIN
thirdparty/ClasspathSimplification/target/ClasspathSimplification-1.0-jar-with-dependencies.jar
vendored
Normal file
BIN
thirdparty/ClasspathSimplification/target/ClasspathSimplification-1.0-jar-with-dependencies.jar
vendored
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user