mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
fix dox warns
This commit is contained in:
parent
852aa43ee1
commit
6f823614af
@ -16,7 +16,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sleuthkit.autopsy.datamodel;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
@ -48,19 +47,17 @@ import org.sleuthkit.datamodel.VolumeSystem;
|
||||
* Static class of utility methods for Content objects
|
||||
*/
|
||||
public final class ContentUtils {
|
||||
|
||||
|
||||
private final static Logger logger = Logger.getLogger(ContentUtils.class.getName());
|
||||
private static SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
private static SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// don't instantiate
|
||||
private ContentUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
private static final ShortNameVisitor shortName = new ShortNameVisitor();
|
||||
|
||||
private static final GetPathVisitor getDisplayPath = new GetPathVisitor(shortName);
|
||||
|
||||
|
||||
/**
|
||||
* Returns full path to this node.
|
||||
*
|
||||
@ -69,90 +66,94 @@ public final class ContentUtils {
|
||||
public static String[] getDisplayPath(Content content) {
|
||||
return content.accept(getDisplayPath).toArray(new String[]{});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert epoch seconds to a string value in the given time zone
|
||||
*
|
||||
* @param epochSeconds
|
||||
* @param tzone
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static String getStringTime(long epochSeconds, TimeZone tzone) {
|
||||
String time = "0000-00-00 00:00:00";
|
||||
if (epochSeconds != 0) {
|
||||
dateFormatter.setTimeZone(tzone);
|
||||
time = dateFormatter.format(new java.util.Date(epochSeconds * 1000));
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public static String getStringTime(long epochSeconds, TimeZone tzone) {
|
||||
String time = "0000-00-00 00:00:00";
|
||||
if (epochSeconds != 0) {
|
||||
dateFormatter.setTimeZone(tzone);
|
||||
time = dateFormatter.format(new java.util.Date(epochSeconds * 1000));
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert epoch seconds to a string value (convenience method)
|
||||
*
|
||||
* @param epochSeconds
|
||||
* @param c
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static String getStringTime(long epochSeconds, Content c) {
|
||||
return getStringTime(epochSeconds, getTimeZone(c));
|
||||
}
|
||||
|
||||
public static String getStringTime(long epochSeconds, Content c) {
|
||||
return getStringTime(epochSeconds, getTimeZone(c));
|
||||
}
|
||||
|
||||
public static TimeZone getTimeZone(Content c) {
|
||||
try {
|
||||
return TimeZone.getTimeZone(c.getImage().getTimeZone());
|
||||
} catch(TskException ex) {
|
||||
} catch (TskException ex) {
|
||||
return TimeZone.getDefault();
|
||||
}
|
||||
}
|
||||
|
||||
private static final SystemNameVisitor systemName = new SystemNameVisitor();
|
||||
|
||||
private static final GetPathVisitor getSystemPath = new GetPathVisitor(systemName);
|
||||
|
||||
|
||||
/**
|
||||
* Returns full path to this node.
|
||||
*
|
||||
*
|
||||
* @return the path of this node
|
||||
*/
|
||||
public static String[] getSystemPath(Content content) {
|
||||
return content.accept(getSystemPath).toArray(new String[]{});
|
||||
}
|
||||
|
||||
|
||||
static String getSystemName(Content content) {
|
||||
return content.accept(systemName);
|
||||
}
|
||||
|
||||
|
||||
private static class SystemNameVisitor extends ContentVisitor.Default<String> {
|
||||
SystemNameVisitor() {}
|
||||
|
||||
SystemNameVisitor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultVisit(Content cntnt) {
|
||||
return cntnt.accept(shortName) + ":" + Long.toString(cntnt.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class ShortNameVisitor extends ContentVisitor.Default<String> {
|
||||
ShortNameVisitor() {}
|
||||
|
||||
ShortNameVisitor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String defaultVisit(Content cntnt) {
|
||||
return cntnt.getName();
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetPathVisitor implements ContentVisitor<List<String>> {
|
||||
|
||||
private static class GetPathVisitor implements ContentVisitor<List<String>> {
|
||||
|
||||
ContentVisitor<String> toString;
|
||||
|
||||
GetPathVisitor(ContentVisitor<String> toString) {
|
||||
this.toString = toString;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> visit(LayoutFile lay) {
|
||||
List<String> path = lay.getParent().accept(this);
|
||||
path.add(toString.visit(lay));
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> visit(LayoutDirectory ld) {
|
||||
List<String> path = ld.getParent().accept(this);
|
||||
@ -174,7 +175,7 @@ public final class ContentUtils {
|
||||
throw new RuntimeException("Couldn't get directory path.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@ -196,9 +197,9 @@ public final class ContentUtils {
|
||||
|
||||
@Override
|
||||
public List<String> visit(Image image) {
|
||||
List<String> path = new LinkedList<String>();
|
||||
path.add(toString.visit(image));
|
||||
return path;
|
||||
List<String> path = new LinkedList<String>();
|
||||
path.add(toString.visit(image));
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -213,24 +214,29 @@ public final class ContentUtils {
|
||||
return vs.getParent().accept(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final int TO_FILE_BUFFER_SIZE = 8192;
|
||||
|
||||
|
||||
/**
|
||||
* Reads all the data from any content object and writes it to a file.
|
||||
*
|
||||
* @param content Any content object.
|
||||
* @param outputFile Will be created if it doesn't exist, and overwritten if
|
||||
* it does
|
||||
* @throws IOException
|
||||
* @param progress progress bar handle to update, if available. null
|
||||
* otherwise
|
||||
* @param worker the swing worker background thread the process runs within,
|
||||
* or null, if in the main thread, used to handle task cancellation
|
||||
* @param source true if source file
|
||||
* @throws IOException if file could not be written
|
||||
*/
|
||||
public static void writeToFile(Content content, java.io.File outputFile, ProgressHandle progress, SwingWorker worker, boolean source) throws IOException {
|
||||
public static void writeToFile(Content content, java.io.File outputFile,
|
||||
ProgressHandle progress, SwingWorker worker, boolean source) throws IOException {
|
||||
|
||||
InputStream in = new ReadContentInputStream(content);
|
||||
|
||||
|
||||
boolean append = false;
|
||||
FileOutputStream out = new FileOutputStream(outputFile, append);
|
||||
|
||||
|
||||
// Get the unit size for a progress bar
|
||||
int unit = (int) (content.getSize() / 100);
|
||||
long totalRead = 0;
|
||||
@ -240,19 +246,19 @@ public final class ContentUtils {
|
||||
int len = in.read(buffer);
|
||||
while (len != -1) {
|
||||
// If there is a worker, check for a cancelation
|
||||
if (worker!=null && worker.isCancelled()) {
|
||||
if (worker != null && worker.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
out.write(buffer, 0, len);
|
||||
len = in.read(buffer);
|
||||
totalRead+=len;
|
||||
totalRead += len;
|
||||
// If there is a progress bar and this is the source file,
|
||||
// report any progress
|
||||
if(progress!=null && source && totalRead>=TO_FILE_BUFFER_SIZE) {
|
||||
if (progress != null && source && totalRead >= TO_FILE_BUFFER_SIZE) {
|
||||
int totalProgress = (int) (totalRead / unit);
|
||||
progress.progress(content.getName(), totalProgress);
|
||||
// If it's not the source, just update the file being processed
|
||||
} else if(progress!=null && !source) {
|
||||
// If it's not the source, just update the file being processed
|
||||
} else if (progress != null && !source) {
|
||||
progress.progress(content.getName());
|
||||
}
|
||||
}
|
||||
@ -260,11 +266,11 @@ public final class ContentUtils {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void writeToFile(Content content, java.io.File outputFile) throws IOException {
|
||||
writeToFile(content, outputFile, null, null, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper to ignore the '.' and '..' directories
|
||||
*/
|
||||
@ -272,8 +278,7 @@ public final class ContentUtils {
|
||||
String name = dir.getName();
|
||||
return name.equals(".") || name.equals("..");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Extracts file/folder as given destination file, recursing into folders.
|
||||
* Assumes there will be no collisions with existing directories/files, and
|
||||
@ -288,22 +293,30 @@ public final class ContentUtils {
|
||||
|
||||
/**
|
||||
* Make new extractor for a specific destination
|
||||
*
|
||||
* @param dest The file/folder visited will be extracted as this file
|
||||
* @param progress progress bar handle to update, if available. null
|
||||
* otherwise
|
||||
* @param worker the swing worker background thread the process runs
|
||||
* within, or null, if in the main thread, used to handle task
|
||||
* cancellation
|
||||
* @param source true if source file
|
||||
*/
|
||||
public ExtractFscContentVisitor(java.io.File dest, ProgressHandle progress, SwingWorker worker, boolean source) {
|
||||
public ExtractFscContentVisitor(java.io.File dest,
|
||||
ProgressHandle progress, SwingWorker worker, boolean source) {
|
||||
this.dest = dest;
|
||||
this.progress = progress;
|
||||
this.worker = worker;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
public ExtractFscContentVisitor(java.io.File dest) {
|
||||
this.dest = dest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to make a new instance for given destination
|
||||
* and extract given content
|
||||
* Convenience method to make a new instance for given destination and
|
||||
* extract given content
|
||||
*/
|
||||
public static void extract(Content cntnt, java.io.File dest, ProgressHandle progress, SwingWorker worker) {
|
||||
cntnt.accept(new ExtractFscContentVisitor(dest, progress, worker, true));
|
||||
@ -323,14 +336,14 @@ public final class ContentUtils {
|
||||
|
||||
@Override
|
||||
public Void visit(Directory dir) {
|
||||
|
||||
|
||||
// don't extract . and .. directories
|
||||
if (isDotDirectory(dir)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
dest.mkdir();
|
||||
|
||||
|
||||
// member visitor to generate destination files for children
|
||||
DestFileContentVisitor destFileCV = new DestFileContentVisitor();
|
||||
|
||||
@ -339,15 +352,15 @@ public final class ContentUtils {
|
||||
// recurse on children
|
||||
for (Content child : dir.getChildren()) {
|
||||
java.io.File childFile = child.accept(destFileCV);
|
||||
ExtractFscContentVisitor childVisitor =
|
||||
new ExtractFscContentVisitor(childFile, progress, worker, false);
|
||||
ExtractFscContentVisitor childVisitor =
|
||||
new ExtractFscContentVisitor(childFile, progress, worker, false);
|
||||
// If this is the source directory of an extract it
|
||||
// will have a progress and worker, and will keep track
|
||||
// of the progress bar's progress
|
||||
if(worker!=null && worker.isCancelled()) {
|
||||
if (worker != null && worker.isCancelled()) {
|
||||
break;
|
||||
}
|
||||
if(progress!=null && source) {
|
||||
if (progress != null && source) {
|
||||
progress.progress(child.getName(), numProcessed);
|
||||
}
|
||||
child.accept(childVisitor);
|
||||
@ -370,12 +383,11 @@ public final class ContentUtils {
|
||||
/**
|
||||
* Helper visitor to get the destination file for a child Content object
|
||||
*/
|
||||
private class DestFileContentVisitor extends
|
||||
ContentVisitor.Default<java.io.File> {
|
||||
private class DestFileContentVisitor extends ContentVisitor.Default<java.io.File> {
|
||||
|
||||
/**
|
||||
* Get destination file by adding File/Directory name to the path
|
||||
* of parent
|
||||
* Get destination file by adding File/Directory name to the path of
|
||||
* parent
|
||||
*/
|
||||
private java.io.File getFsContentDest(FsContent fsc) {
|
||||
String path = dest.getAbsolutePath() + java.io.File.separator
|
||||
|
@ -53,13 +53,13 @@ public class AbstractFileStringIntStream extends InputStream {
|
||||
private StringExtractResult lastExtractResult;
|
||||
|
||||
/**
|
||||
* Constructs new stream object that does convertion from file, to extracted
|
||||
* strings, then to byte stream, for specified script auto-detected encoding
|
||||
* Constructs new stream object that does conversion from file, to extracted
|
||||
* strings, then to byte stream, for specified script, auto-detected encoding
|
||||
* (UTF8, UTF16LE, UTF16BE), and specified output byte stream encoding
|
||||
*
|
||||
* @param content
|
||||
* @param script
|
||||
* @param outCharset
|
||||
* @param content input content to process and turn into a stream to convert into strings
|
||||
* @param scripts a list of scripts to consider
|
||||
* @param outCharset encoding to use in the output byte stream
|
||||
*/
|
||||
public AbstractFileStringIntStream(AbstractFile content, List<SCRIPT> scripts, Charset outCharset) {
|
||||
this.content = content;
|
||||
|
@ -96,7 +96,8 @@ public class SearchEngineURLQueryAnalyzer extends Extract implements IngestServi
|
||||
* Returns which of the supported SearchEngines, if any, the given string
|
||||
* belongs to.
|
||||
*
|
||||
* @param searchEngineName the URL string to be determined
|
||||
* @param domain domain as part of the URL
|
||||
* @return supported search engine the domain belongs to, if any
|
||||
*
|
||||
*/
|
||||
private static SearchEngine getSearchEngine(String domain) {
|
||||
|
@ -42,7 +42,7 @@ If you are planning on running the script regularly ("./regression.py"), the inp
|
||||
|
||||
autopsy/Testing/script/input
|
||||
|
||||
However, if you are planning on using the configuration file, you can change the input directory using the <indir> tag.
|
||||
However, if you are planning on using the configuration file, you can change the input directory using the <indir> tag.
|
||||
|
||||
Ensure the following files are in the input directory, whether in the default location or set by the configuration file
|
||||
|
||||
@ -50,7 +50,7 @@ Ensure the following files are in the input directory, whether in the default lo
|
||||
nsrl.txt-md5.idx
|
||||
notablekeywords.xml
|
||||
|
||||
Place any images you would like to test in the input directory, and/or use the configuration file to point to image files directly using the <image> tag. The input directory will be scanned for images even when the configuration file points to specific ones. Use the -i or --ignore command to prevent this.
|
||||
Place any images you would like to test in the input directory, and/or use the configuration file to point to image files directly using the <image> tag. The input directory will be scanned for images even when the configuration file points to specific ones. Use the -i or --ignore command to prevent this.
|
||||
|
||||
|
||||
|
||||
@ -105,13 +105,13 @@ An XML configuration file can be pointed to by using the -l or --list command as
|
||||
|
||||
The configuration file has three possible tags, all of which are optional.
|
||||
|
||||
<indir value="X:\path\to\input\directory">
|
||||
<indir value="X:\path\to\input\directory">
|
||||
Changes the default input directory to the one provided.
|
||||
|
||||
<global_csv value="X:\path\to\csv\file.txt">
|
||||
<global_csv value="X:\path\to\csv\file.txt">
|
||||
Points to an optional CSV file to be added to, anywhere in the user's filesystem.
|
||||
|
||||
<image value="X:\path\to\image.img">
|
||||
<image value="X:\path\to\image.img">
|
||||
Points to a specific image file to be tested. This tag can be used any number of times in the configuration file.
|
||||
|
||||
|
||||
@ -194,7 +194,7 @@ For further reference regarding ContainerOperators, please see
|
||||
|
||||
|
||||
When an element has been selected, the individual components may be manipluated with ContainerOperators.
|
||||
To select a button, use the code below, where cont is one of the ContainerOperators from above, text is the text displayed on the button, and index is the button's order if there are multiple with the same name (i.e. if there are three buttons labeled “preview”, the first's index is 0, then 1, then 2).
|
||||
To select a button, use the code below, where cont is one of the ContainerOperators from above, text is the text displayed on the button, and index is the button's order if there are multiple with the same name (i.e. if there are three buttons labeled <EFBFBD>preview<EFBFBD>, the first's index is 0, then 1, then 2).
|
||||
|
||||
JbuttonOperator jbo = new JbuttonOperator(ContainerOperator cont, String text, int index);
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class ThunderbirdMetadata implements CreativeCommons, DublinCore, Geograp
|
||||
private Map<String, ArrayList<String>> metadata = null;
|
||||
|
||||
/**
|
||||
* The UTC time zone. Not sure if {@link TimeZone#getTimeZone(String)}
|
||||
* The UTC time zone. Not sure if TimeZone.getTimeZone(String)
|
||||
* understands "UTC" in all environments, but it'll fall back to GMT
|
||||
* in such cases, which is in practice equivalent to UTC.
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ public class ThunderbirdXHTMLContentHandler extends SafeContentHandler {
|
||||
private static final char[] TAB = new char[] { '\t' };
|
||||
|
||||
/**
|
||||
* The elements that are in the <head> section.
|
||||
* The elements that are in the <head> section.
|
||||
*/
|
||||
private static final Set<String> HEAD =
|
||||
unmodifiableSet("title", "link", "base", "meta");
|
||||
@ -63,13 +63,13 @@ public class ThunderbirdXHTMLContentHandler extends SafeContentHandler {
|
||||
unmodifiableSet("html", "head", "body", "frameset");
|
||||
|
||||
/**
|
||||
* The elements that get prepended with the {@link #TAB} character.
|
||||
* The elements that get prepended with the #TAB character.
|
||||
*/
|
||||
private static final Set<String> INDENT =
|
||||
unmodifiableSet("li", "dd", "dt", "td", "th", "frame");
|
||||
|
||||
/**
|
||||
* The elements that get appended with the {@link #NL} character.
|
||||
* The elements that get appended with the #NL character.
|
||||
*/
|
||||
public static final Set<String> ENDLINE = unmodifiableSet(
|
||||
"p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "ul", "ol", "dl",
|
||||
|
Loading…
x
Reference in New Issue
Block a user