Autopsy  4.13.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
FileExtMismatchDetectorModuleSettings.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2016 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.modules.fileextmismatch;
20 
21 import java.io.IOException;
22 import java.io.ObjectInputStream;
23 import java.util.Set;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
27 
31 final class FileExtMismatchDetectorModuleSettings implements IngestModuleIngestJobSettings {
32 
33  private static final long serialVersionUID = 1L;
34  private long versionNumber;
35  private boolean skipFilesWithNoExtension;
36  @Deprecated
37  private boolean skipFilesWithTextPlainMimeType; // No longer used, retained to maintain serialization compatibility.
38  private boolean skipKnownFiles;
39  private CHECK_TYPE checkType;
40 
41  /*
42  * Extension mismatches can be checked for all files, for all files except
43  * text files, or for media and executable files only.
44  */
45  enum CHECK_TYPE {
46  ALL, NO_TEXT_FILES, ONLY_MEDIA_AND_EXE
47  }
48 
49  /*
50  * The set of the MIME types that will be checked for extension mismatches
51  * when checkType is ONLY_MEDIA_AND_EXE.
52  */
53  static final Set<String> MEDIA_AND_EXE_MIME_TYPES = Stream.of(
54  "image/bmp",
55  "image/gif",
56  "image/jpeg",
57  "image/png",
58  "image/tiff",
59  "image/x-ms-bmp",
60  "application/dos-exe",
61  "application/exe",
62  "application/x-dosexec",
63  "application/x-exe",
64  "application/x-msdownload",
65  "application/msword",
66  "application/pdf",
67  "application/rtf",
68  "application/vnd.ms-excel",
69  "application/vnd.ms-powerpoint",
70  "application/vnd.oasis.opendocument.presentation",
71  "application/vnd.oasis.opendocument.spreadsheet",
72  "application/vnd.oasis.opendocument.text",
73  "application/x-msoffice",
74  "application/x-ooxml",
75  "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
76  "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
77  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
78  "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
79  "application/vnd.openxmlformats-officedocument.presentationml.presentation",
80  "application/vnd.openxmlformats-officedocument.presentationml.template",
81  "application/vnd.openxmlformats-officedocument.presentationml.slideshow"
82  ).collect(Collectors.toSet());
83 
88  FileExtMismatchDetectorModuleSettings() {
89  this.versionNumber = 2;
90  this.skipFilesWithNoExtension = true;
91  this.skipKnownFiles = true;
92  this.checkType = CHECK_TYPE.ONLY_MEDIA_AND_EXE;
93  }
94 
100  @Override
101  public long getVersionNumber() {
102  return serialVersionUID;
103  }
104 
111  void setSkipFilesWithNoExtension(boolean skipFilesWithNoExtension) {
112  this.skipFilesWithNoExtension = skipFilesWithNoExtension;
113  }
114 
121  boolean skipFilesWithNoExtension() {
122  return skipFilesWithNoExtension;
123  }
124 
131  void setSkipKnownFiles(boolean skipKnownFiles) {
132  this.skipKnownFiles = skipKnownFiles;
133  }
134 
141  boolean skipKnownFiles() {
142  return skipKnownFiles;
143  }
144 
151  void setCheckType(CHECK_TYPE checkType) {
152  this.checkType = checkType;
153  }
154 
161  CHECK_TYPE getCheckType() {
162  return checkType;
163  }
164 
177  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
178  in.defaultReadObject();
179  if (0L == versionNumber) {
180  /*
181  * If the version number is set to the Java field default value of
182  * zero, then versionNumber and skipKnownFiles are new fields.
183  * Change this to the desired default value of true.
184  */
185  skipKnownFiles = true;
186  versionNumber = 1;
187  }
188  if (1 == versionNumber) {
189  /*
190  * Set the default value of the new checkType field, it is currently
191  * null.
192  */
193  checkType = CHECK_TYPE.ONLY_MEDIA_AND_EXE;
194  versionNumber = 2;
195  }
196  }
197 
198 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.