Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ExportContainerInfo.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2021 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.report.modules.datasourcesummaryexport;
20 
21 import java.util.Arrays;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
26 import org.apache.commons.lang.StringUtils;
27 import org.openide.util.NbBundle.Messages;
37 import org.sleuthkit.datamodel.DataSource;
38 
42 class ExportContainerInfo {
43 
44  private final ContainerSummary containerSummary;
45 
49  ExportContainerInfo() {
50  containerSummary = new ContainerSummary();
51  }
52 
61  private static List<? extends ExcelItemExportable> getAcquisitionDetails(String acquisitionDetails) {
62  if (StringUtils.isBlank(acquisitionDetails)) {
63  return Collections.emptyList();
64  } else {
65  return Stream.of(acquisitionDetails.split("\\r?\\n"))
66  .map((line) -> (StringUtils.isBlank(line)) ? null : new SingleCellExportable(line))
67  .filter(item -> item != null)
68  .collect(Collectors.toList());
69  }
70  }
71 
72  @Messages({
73  "ExportContainerInfo_setFieldsForNonImageDataSource_na=N/A",
74  "ExportContainerInfo_tabName=Container",
75  "ExportContainerInfo_export_displayName=Display Name:",
76  "ExportContainerInfo_export_originalName=Name:",
77  "ExportContainerInfo_export_deviceId=Device ID:",
78  "ExportContainerInfo_export_timeZone=Time Zone:",
79  "ExportContainerInfo_export_acquisitionDetails=Acquisition Details:",
80  "ExportContainerInfo_export_imageType=Image Type:",
81  "ExportContainerInfo_export_size=Size:",
82  "ExportContainerInfo_export_sectorSize=Sector Size:",
83  "ExportContainerInfo_export_md5=MD5:",
84  "ExportContainerInfo_export_sha1=SHA1:",
85  "ExportContainerInfo_export_sha256=SHA256:",
86  "ExportContainerInfo_export_unallocatedSize=Unallocated Space:",
87  "ExportContainerInfo_export_filePaths=File Paths:",})
88  List<ExcelSheetExport> getExports(DataSource ds) {
89  DataFetcher<DataSource, ContainerDetails> containerDataFetcher = (dataSource) -> containerSummary.getContainerDetails(dataSource);
90  ContainerDetails containerDetails = ExcelExportAction.getFetchResult(containerDataFetcher, "Container sheets", ds);
91  if (ds == null || containerDetails == null) {
92  return Collections.emptyList();
93  }
94 
95  String NA = Bundle.ExportContainerInfo_setFieldsForNonImageDataSource_na();
96  DefaultCellModel<?> NACell = new DefaultCellModel<>(NA);
97 
98  ImageDetails imageDetails = containerDetails.getImageDetails();
99  boolean hasImage = imageDetails != null;
100 
101  DefaultCellModel<?> timeZone = hasImage ? new DefaultCellModel<>(imageDetails.getTimeZone()) : NACell;
102  DefaultCellModel<?> imageType = hasImage ? new DefaultCellModel<>(imageDetails.getImageType()) : NACell;
103  DefaultCellModel<?> size = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getSize()) : NACell;
104  DefaultCellModel<?> sectorSize = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getSectorSize()) : NACell;
105  DefaultCellModel<?> md5 = hasImage ? new DefaultCellModel<>(imageDetails.getMd5Hash()) : NACell;
106  DefaultCellModel<?> sha1 = hasImage ? new DefaultCellModel<>(imageDetails.getSha1Hash()) : NACell;
107  DefaultCellModel<?> sha256 = hasImage ? new DefaultCellModel<>(imageDetails.getSha256Hash()) : NACell;
108  DefaultCellModel<?> unallocatedSize = hasImage ? SizeRepresentationUtil.getBytesCell(imageDetails.getUnallocatedSize()) : NACell;
109  List<String> paths = containerDetails.getImageDetails() == null ? Collections.singletonList(NA) : containerDetails.getImageDetails().getPaths();
110  List<SingleCellExportable> cellPaths = paths.stream()
111  .map(SingleCellExportable::new)
112  .collect(Collectors.toList());
113 
114  return Arrays.asList(new ExcelSpecialFormatExport(Bundle.ExportContainerInfo_tabName(), Arrays.asList(new KeyValueItemExportable(Bundle.ExportContainerInfo_export_displayName(), new DefaultCellModel<>(containerDetails.getDisplayName())),
115  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_originalName(), new DefaultCellModel<>(containerDetails.getOriginalName())),
116  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_deviceId(), new DefaultCellModel<>(containerDetails.getDeviceId())),
117  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_timeZone(), timeZone),
118  new TitledExportable(Bundle.ExportContainerInfo_export_acquisitionDetails(), getAcquisitionDetails(containerDetails.getAcquisitionDetails())),
119  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_imageType(), imageType),
120  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_size(), size),
121  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sectorSize(), sectorSize),
122  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_md5(), md5),
123  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha1(), sha1),
124  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_sha256(), sha256),
125  new KeyValueItemExportable(Bundle.ExportContainerInfo_export_unallocatedSize(), unallocatedSize),
126  new TitledExportable(Bundle.ExportContainerInfo_export_filePaths(), cellPaths)
127  )));
128 
129  }
130 }

Copyright © 2012-2021 Basis Technology. Generated on: Thu Sep 30 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.