Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
XRYWebBookmarksFileParser.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019-2020 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.datasourceprocessors.xry;
20 
21 import java.util.ArrayList;
22 import java.util.Map;
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Optional;
26 import org.sleuthkit.datamodel.AbstractFile;
27 import org.sleuthkit.datamodel.Blackboard.BlackboardException;
28 import org.sleuthkit.datamodel.BlackboardAttribute;
29 import org.sleuthkit.datamodel.BlackboardArtifact;
30 import org.sleuthkit.datamodel.Content;
31 import org.sleuthkit.datamodel.SleuthkitCase;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
37 final class XRYWebBookmarksFileParser extends AbstractSingleEntityParser {
38 
39  //All known XRY keys for web bookmarks.
40  private static final Map<String, BlackboardAttribute.ATTRIBUTE_TYPE> XRY_KEYS
41  = new HashMap<String, BlackboardAttribute.ATTRIBUTE_TYPE>() {
42  {
43  put("web address", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_URL);
44  put("domain", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DOMAIN);
45  put("application", BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PROG_NAME);
46  }
47  };
48 
49  @Override
50  boolean canProcess(XRYKeyValuePair pair) {
51  String normalizedKey = pair.getKey().toLowerCase();
52  return XRY_KEYS.containsKey(normalizedKey);
53  }
54 
55  @Override
56  boolean isNamespace(String nameSpace) {
57  //No known namespaces for web reports.
58  return false;
59  }
60 
65  private Optional<BlackboardAttribute> getBlackboardAttribute(XRYKeyValuePair pair) {
66  String normalizedKey = pair.getKey().toLowerCase();
67  return Optional.of(new BlackboardAttribute(
68  XRY_KEYS.get(normalizedKey),
69  PARSER_NAME, pair.getValue()));
70  }
71 
72  @Override
73  void makeArtifact(List<XRYKeyValuePair> keyValuePairs, Content parent, SleuthkitCase currentCase) throws TskCoreException, BlackboardException {
74  List<BlackboardAttribute> attributes = new ArrayList<>();
75  for(XRYKeyValuePair pair : keyValuePairs) {
76  Optional<BlackboardAttribute> attribute = getBlackboardAttribute(pair);
77  if(attribute.isPresent()) {
78  attributes.add(attribute.get());
79  }
80  }
81  if(!attributes.isEmpty()) {
82  parent.newDataArtifact(BlackboardArtifact.Type.TSK_WEB_BOOKMARK, attributes);
83  }
84  }
85 }

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.