mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
commit
e59d9cc9dd
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Autopsy Forensic Browser
|
* Autopsy Forensic Browser
|
||||||
*
|
*
|
||||||
* Copyright 2012-2014 Basis Technology Corp.
|
* Copyright 2012-2020 Basis Technology Corp.
|
||||||
* Contact: carrier <at> sleuthkit <dot> org
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -55,6 +55,40 @@ import org.xml.sax.SAXException;
|
|||||||
*/
|
*/
|
||||||
public class XMLUtil {
|
public class XMLUtil {
|
||||||
|
|
||||||
|
private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
|
||||||
|
// See JIRA-6958 for details about class loading and jaxb.
|
||||||
|
ClassLoader original = Thread.currentThread().getContextClassLoader();
|
||||||
|
try {
|
||||||
|
Thread.currentThread().setContextClassLoader(XMLUtil.class.getClassLoader());
|
||||||
|
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||||
|
return builderFactory.newDocumentBuilder();
|
||||||
|
} finally {
|
||||||
|
Thread.currentThread().setContextClassLoader(original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SchemaFactory getSchemaFactory(String schemaLanguage) {
|
||||||
|
// See JIRA-6958 for details about class loading and jaxb.
|
||||||
|
ClassLoader original = Thread.currentThread().getContextClassLoader();
|
||||||
|
try {
|
||||||
|
Thread.currentThread().setContextClassLoader(XMLUtil.class.getClassLoader());
|
||||||
|
return SchemaFactory.newInstance(schemaLanguage);
|
||||||
|
} finally {
|
||||||
|
Thread.currentThread().setContextClassLoader(original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TransformerFactory getTransformerFactory() {
|
||||||
|
// See JIRA-6958 for details about class loading and jaxb.
|
||||||
|
ClassLoader original = Thread.currentThread().getContextClassLoader();
|
||||||
|
try {
|
||||||
|
Thread.currentThread().setContextClassLoader(XMLUtil.class.getClassLoader());
|
||||||
|
return TransformerFactory.newInstance();
|
||||||
|
} finally {
|
||||||
|
Thread.currentThread().setContextClassLoader(original);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a W3C DOM.
|
* Creates a W3C DOM.
|
||||||
*
|
*
|
||||||
@ -63,9 +97,7 @@ public class XMLUtil {
|
|||||||
* @throws ParserConfigurationException
|
* @throws ParserConfigurationException
|
||||||
*/
|
*/
|
||||||
public static Document createDocument() throws ParserConfigurationException {
|
public static Document createDocument() throws ParserConfigurationException {
|
||||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
return getDocumentBuilder().newDocument();
|
||||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
|
||||||
return builder.newDocument();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,8 +132,7 @@ public class XMLUtil {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static Document loadDocument(String docPath) throws ParserConfigurationException, SAXException, IOException {
|
public static Document loadDocument(String docPath) throws ParserConfigurationException, SAXException, IOException {
|
||||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
DocumentBuilder builder = getDocumentBuilder();
|
||||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
|
||||||
Document doc = builder.parse(new FileInputStream(docPath));
|
Document doc = builder.parse(new FileInputStream(docPath));
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
@ -119,7 +150,7 @@ public class XMLUtil {
|
|||||||
public static <T> void validateDocument(final Document doc, Class<T> clazz, String schemaResourceName) throws SAXException, IOException {
|
public static <T> void validateDocument(final Document doc, Class<T> clazz, String schemaResourceName) throws SAXException, IOException {
|
||||||
PlatformUtil.extractResourceToUserConfigDir(clazz, schemaResourceName, false);
|
PlatformUtil.extractResourceToUserConfigDir(clazz, schemaResourceName, false);
|
||||||
File schemaFile = new File(Paths.get(PlatformUtil.getUserConfigDirectory(), schemaResourceName).toAbsolutePath().toString());
|
File schemaFile = new File(Paths.get(PlatformUtil.getUserConfigDirectory(), schemaResourceName).toAbsolutePath().toString());
|
||||||
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
SchemaFactory schemaFactory = getSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||||
Schema schema = schemaFactory.newSchema(schemaFile);
|
Schema schema = schemaFactory.newSchema(schemaFile);
|
||||||
Validator validator = schema.newValidator();
|
Validator validator = schema.newValidator();
|
||||||
validator.validate(new DOMSource(doc), new DOMResult());
|
validator.validate(new DOMSource(doc), new DOMResult());
|
||||||
@ -140,7 +171,7 @@ public class XMLUtil {
|
|||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static void saveDocument(final Document doc, String encoding, String docPath) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException {
|
public static void saveDocument(final Document doc, String encoding, String docPath) throws TransformerConfigurationException, FileNotFoundException, UnsupportedEncodingException, TransformerException, IOException {
|
||||||
TransformerFactory xf = TransformerFactory.newInstance();
|
TransformerFactory xf = getTransformerFactory();
|
||||||
xf.setAttribute("indent-number", 1); //NON-NLS
|
xf.setAttribute("indent-number", 1); //NON-NLS
|
||||||
Transformer xformer = xf.newTransformer();
|
Transformer xformer = xf.newTransformer();
|
||||||
xformer.setOutputProperty(OutputKeys.METHOD, "xml"); //NON-NLS
|
xformer.setOutputProperty(OutputKeys.METHOD, "xml"); //NON-NLS
|
||||||
@ -178,7 +209,7 @@ public class XMLUtil {
|
|||||||
try {
|
try {
|
||||||
PlatformUtil.extractResourceToUserConfigDir(clazz, schemaFile, false);
|
PlatformUtil.extractResourceToUserConfigDir(clazz, schemaFile, false);
|
||||||
File schemaLoc = new File(PlatformUtil.getUserConfigDirectory() + File.separator + schemaFile);
|
File schemaLoc = new File(PlatformUtil.getUserConfigDirectory() + File.separator + schemaFile);
|
||||||
SchemaFactory schm = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
SchemaFactory schm = getSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI);
|
||||||
try {
|
try {
|
||||||
Schema schema = schm.newSchema(schemaLoc);
|
Schema schema = schm.newSchema(schemaLoc);
|
||||||
Validator validator = schema.newValidator();
|
Validator validator = schema.newValidator();
|
||||||
@ -226,10 +257,9 @@ public class XMLUtil {
|
|||||||
*/
|
*/
|
||||||
// TODO: Deprecate.
|
// TODO: Deprecate.
|
||||||
public static <T> Document loadDoc(Class<T> clazz, String xmlPath) {
|
public static <T> Document loadDoc(Class<T> clazz, String xmlPath) {
|
||||||
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
|
||||||
Document ret = null;
|
Document ret = null;
|
||||||
try {
|
try {
|
||||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
DocumentBuilder builder = getDocumentBuilder();
|
||||||
ret = builder.parse(new FileInputStream(xmlPath));
|
ret = builder.parse(new FileInputStream(xmlPath));
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
Logger.getLogger(clazz.getName()).log(Level.SEVERE, "Error loading XML file " + xmlPath + " : can't initialize parser.", e); //NON-NLS
|
Logger.getLogger(clazz.getName()).log(Level.SEVERE, "Error loading XML file " + xmlPath + " : can't initialize parser.", e); //NON-NLS
|
||||||
@ -268,7 +298,7 @@ public class XMLUtil {
|
|||||||
*/
|
*/
|
||||||
// TODO: Deprecate.
|
// TODO: Deprecate.
|
||||||
public static <T> boolean saveDoc(Class<T> clazz, String xmlPath, String encoding, final Document doc) {
|
public static <T> boolean saveDoc(Class<T> clazz, String xmlPath, String encoding, final Document doc) {
|
||||||
TransformerFactory xf = TransformerFactory.newInstance();
|
TransformerFactory xf = getTransformerFactory();
|
||||||
xf.setAttribute("indent-number", 1); //NON-NLS
|
xf.setAttribute("indent-number", 1); //NON-NLS
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
|
@ -117,6 +117,12 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda
|
|||||||
* while processing archive files.
|
* while processing archive files.
|
||||||
*/
|
*/
|
||||||
mapOfDepthTrees.put(jobId, new ConcurrentHashMap<>());
|
mapOfDepthTrees.put(jobId, new ConcurrentHashMap<>());
|
||||||
|
/**
|
||||||
|
* Initialize Java's Image I/O API so that image reading and writing
|
||||||
|
* (needed for image extraction) happens consistently through the
|
||||||
|
* same providers. See JIRA-6951 for more details.
|
||||||
|
*/
|
||||||
|
initializeImageIO();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Construct an embedded content extractor for processing Microsoft
|
* Construct an embedded content extractor for processing Microsoft
|
||||||
@ -127,14 +133,6 @@ public final class EmbeddedFileExtractorIngestModule extends FileIngestModuleAda
|
|||||||
} catch (NoCurrentCaseException ex) {
|
} catch (NoCurrentCaseException ex) {
|
||||||
throw new IngestModuleException(Bundle.EmbeddedFileExtractorIngestModule_UnableToGetMSOfficeExtractor_errMsg(), ex);
|
throw new IngestModuleException(Bundle.EmbeddedFileExtractorIngestModule_UnableToGetMSOfficeExtractor_errMsg(), ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize Java's Image I/O API so that image reading and writing
|
|
||||||
* (needed for image extraction) happens consistently through the
|
|
||||||
* same providers. See JIRA-6951 for more details.
|
|
||||||
*/
|
|
||||||
initializeImageIO();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -228,12 +228,19 @@ public class STIXReportModule implements GeneralReportModule {
|
|||||||
*/
|
*/
|
||||||
private STIXPackage loadSTIXFile(String stixFileName) throws JAXBException {
|
private STIXPackage loadSTIXFile(String stixFileName) throws JAXBException {
|
||||||
// Create STIXPackage object from xml.
|
// Create STIXPackage object from xml.
|
||||||
|
// See JIRA-6958 for details about class loading and jaxb.
|
||||||
|
ClassLoader original = Thread.currentThread().getContextClassLoader();
|
||||||
|
try {
|
||||||
|
Thread.currentThread().setContextClassLoader(STIXReportModule.class.getClassLoader());
|
||||||
File file = new File(stixFileName);
|
File file = new File(stixFileName);
|
||||||
JAXBContext jaxbContext = JAXBContext.newInstance("org.mitre.stix.stix_1:org.mitre.stix.common_1:org.mitre.stix.indicator_2:" //NON-NLS
|
JAXBContext jaxbContext = JAXBContext.newInstance("org.mitre.stix.stix_1:org.mitre.stix.common_1:org.mitre.stix.indicator_2:" //NON-NLS
|
||||||
+ "org.mitre.cybox.objects:org.mitre.cybox.cybox_2:org.mitre.cybox.common_2"); //NON-NLS
|
+ "org.mitre.cybox.objects:org.mitre.cybox.cybox_2:org.mitre.cybox.common_2"); //NON-NLS
|
||||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||||
STIXPackage stix = (STIXPackage) jaxbUnmarshaller.unmarshal(file);
|
STIXPackage stix = (STIXPackage) jaxbUnmarshaller.unmarshal(file);
|
||||||
return stix;
|
return stix;
|
||||||
|
} finally {
|
||||||
|
Thread.currentThread().setContextClassLoader(original);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
/nbproject/private/
|
/nbproject/private/
|
||||||
/build/
|
/build/
|
||||||
|
|
Binary file not shown.
@ -106,7 +106,7 @@
|
|||||||
<copy file="${basedir}/NEWS.txt" tofile="${zip-tmp}/${app.name}/NEWS.txt"/>
|
<copy file="${basedir}/NEWS.txt" tofile="${zip-tmp}/${app.name}/NEWS.txt"/>
|
||||||
<copy file="${basedir}/Running_Linux_OSX.txt" tofile="${zip-tmp}/${app.name}/Running_Linux_OSX.txt"/>
|
<copy file="${basedir}/Running_Linux_OSX.txt" tofile="${zip-tmp}/${app.name}/Running_Linux_OSX.txt"/>
|
||||||
<copy file="${basedir}/unix_setup.sh" tofile="${zip-tmp}/${app.name}/unix_setup.sh"/>
|
<copy file="${basedir}/unix_setup.sh" tofile="${zip-tmp}/${app.name}/unix_setup.sh"/>
|
||||||
<copy file="${basedir}/ManifestTool/ManifestTool.exe" todir="${zip-tmp}/${app.name}/bin"/>
|
<copy file="${basedir}/Tools/ManifestTool/ManifestTool.exe" todir="${zip-tmp}/${app.name}/bin"/>
|
||||||
|
|
||||||
<copy file="${basedir}/icons/icon.ico" tofile="${zip-tmp}/${app.name}/icon.ico" overwrite="true"/>
|
<copy file="${basedir}/icons/icon.ico" tofile="${zip-tmp}/${app.name}/icon.ico" overwrite="true"/>
|
||||||
|
|
||||||
@ -117,10 +117,10 @@
|
|||||||
|
|
||||||
<!-- Copy the ZooKeeper migration tool, it's JAR files, and documentation -->
|
<!-- Copy the ZooKeeper migration tool, it's JAR files, and documentation -->
|
||||||
<copy flatten="false" todir="${zip-tmp}/${app.name}/autopsy/ZookeeperNodeMigration">
|
<copy flatten="false" todir="${zip-tmp}/${app.name}/autopsy/ZookeeperNodeMigration">
|
||||||
<fileset dir="${basedir}/ZookeeperNodeMigration/dist"/>
|
<fileset dir="${basedir}/Tools/ZookeeperNodeMigration/dist"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy flatten="false" todir="${zip-tmp}/${app.name}/autopsy/ZookeeperNodeMigration" overwrite="true">
|
<copy flatten="false" todir="${zip-tmp}/${app.name}/autopsy/ZookeeperNodeMigration" overwrite="true">
|
||||||
<fileset dir="${basedir}/ZookeeperNodeMigration/docs"/>
|
<fileset dir="${basedir}/Tools/ZookeeperNodeMigration/docs"/>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<property name="app.property.file" value="${zip-tmp}/${app.name}/etc/${app.name}.conf" />
|
<property name="app.property.file" value="${zip-tmp}/${app.name}/etc/${app.name}.conf" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user