Autopsy  4.12.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").collect(Collectors.toSet());
65 
70  FileExtMismatchDetectorModuleSettings() {
71  this.versionNumber = 2;
72  this.skipFilesWithNoExtension = true;
73  this.skipKnownFiles = true;
74  this.checkType = CHECK_TYPE.ONLY_MEDIA_AND_EXE;
75  }
76 
82  @Override
83  public long getVersionNumber() {
84  return serialVersionUID;
85  }
86 
93  void setSkipFilesWithNoExtension(boolean skipFilesWithNoExtension) {
94  this.skipFilesWithNoExtension = skipFilesWithNoExtension;
95  }
96 
103  boolean skipFilesWithNoExtension() {
104  return skipFilesWithNoExtension;
105  }
106 
113  void setSkipKnownFiles(boolean skipKnownFiles) {
114  this.skipKnownFiles = skipKnownFiles;
115  }
116 
123  boolean skipKnownFiles() {
124  return skipKnownFiles;
125  }
126 
133  void setCheckType(CHECK_TYPE checkType) {
134  this.checkType = checkType;
135  }
136 
143  CHECK_TYPE getCheckType() {
144  return checkType;
145  }
146 
159  private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
160  in.defaultReadObject();
161  if (0L == versionNumber) {
162  /*
163  * If the version number is set to the Java field default value of
164  * zero, then versionNumber and skipKnownFiles are new fields.
165  * Change this to the desired default value of true.
166  */
167  skipKnownFiles = true;
168  versionNumber = 1;
169  }
170  if (1 == versionNumber) {
171  /*
172  * Set the default value of the new checkType field, it is currently
173  * null.
174  */
175  checkType = CHECK_TYPE.ONLY_MEDIA_AND_EXE;
176  versionNumber = 2;
177  }
178  }
179 
180 }

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.