Clean and document Keyword class

This commit is contained in:
Richard Cordovano 2016-10-22 14:03:17 -04:00
parent c8fd478428
commit 181f65aee4
14 changed files with 166 additions and 114 deletions

View File

@ -186,7 +186,6 @@ Ingester.FscContentStream.getSrcInfo=File\:{0}
Ingester.FscContentStream.getReader=Not supported yet. Ingester.FscContentStream.getReader=Not supported yet.
Ingester.NullContentStream.getSrcInfo.text=File\:{0} Ingester.NullContentStream.getSrcInfo.text=File\:{0}
Ingester.NullContentStream.getReader=Not supported yet. Ingester.NullContentStream.getReader=Not supported yet.
Keyword.toString.text=Keyword'{'query\={0}, isLiteral\={1}, keywordType\={2}'}'
KeywordSearch.moduleErr=Module Error KeywordSearch.moduleErr=Module Error
KeywordSearch.fireNumIdxFileChg.moduleErr.msg=A module caused an error listening to KeywordSearch updates. See log to determine which module. Some data could be incomplete. KeywordSearch.fireNumIdxFileChg.moduleErr.msg=A module caused an error listening to KeywordSearch updates. See log to determine which module. Some data could be incomplete.
KeywordSearchListsEncase.save.exception.msg=Not supported yet. KeywordSearchListsEncase.save.exception.msg=Not supported yet.

View File

@ -207,7 +207,6 @@ KeywordSearchIngestModule.doInBackGround.pendingMsg=\uff08\u30da\u30f3\u30c7\u30
SearchRunner.doInBackGround.cancelMsg=\uff08\u30ad\u30e3\u30f3\u30bb\u30eb\u4e2d\u2026\uff09 SearchRunner.doInBackGround.cancelMsg=\uff08\u30ad\u30e3\u30f3\u30bb\u30eb\u4e2d\u2026\uff09
Server.addDoc.exception.msg2=\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u30cf\u30f3\u30c9\u30e9\u30fc\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u304c\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u6b21\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\uff1a{0} Server.addDoc.exception.msg2=\u30a2\u30c3\u30d7\u30c7\u30fc\u30c8\u30cf\u30f3\u30c9\u30e9\u30fc\u3092\u4f7f\u7528\u3057\u307e\u3057\u305f\u304c\u3001\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u6b21\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u8ffd\u52a0\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\uff1a{0}
ExtractedContentViewer.getSolrContent.txtBodyItal=<span style\=''font-style\:italic''>{0}</span> ExtractedContentViewer.getSolrContent.txtBodyItal=<span style\=''font-style\:italic''>{0}</span>
Keyword.toString.text=Keyword'{'query\={0}, isLiteral\={1}, keywordType\={2}'}'
KeywordSearchJobSettingsPanel.keywordSearchEncodings.text=- KeywordSearchJobSettingsPanel.keywordSearchEncodings.text=-
KeywordSearchJobSettingsPanel.languagesValLabel.text=- KeywordSearchJobSettingsPanel.languagesValLabel.text=-
KeywordSearchJobSettingsPanel.encodingsLabel.text=\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\uff1a KeywordSearchJobSettingsPanel.encodingsLabel.text=\u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\uff1a

View File

@ -562,8 +562,8 @@ class DropdownListSearchPanel extends KeywordSearchPanel {
Boolean regex; Boolean regex;
KeywordTableEntry(Keyword keyword) { KeywordTableEntry(Keyword keyword) {
this.name = keyword.getQuery(); this.name = keyword.getSearchTerm();
this.regex = !keyword.isLiteral(); this.regex = !keyword.searchTermIsLiteral();
} }
@Override @Override

View File

@ -581,10 +581,10 @@ class GlobalEditListPanel extends javax.swing.JPanel implements ListSelectionLis
Keyword word = currentKeywordList.getKeywords().get(rowIndex); Keyword word = currentKeywordList.getKeywords().get(rowIndex);
switch (columnIndex) { switch (columnIndex) {
case 0: case 0:
ret = (Object) word.getQuery(); ret = (Object) word.getSearchTerm();
break; break;
case 1: case 1:
ret = (Object) !word.isLiteral(); ret = (Object) !word.searchTermIsLiteral();
break; break;
default: default:
logger.log(Level.SEVERE, "Invalid table column index: {0}", columnIndex); //NON-NLS logger.log(Level.SEVERE, "Invalid table column index: {0}", columnIndex); //NON-NLS

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2014 Basis Technology Corp. * Copyright 2011-2016 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -18,81 +18,135 @@
*/ */
package org.sleuthkit.autopsy.keywordsearch; package org.sleuthkit.autopsy.keywordsearch;
import org.openide.util.NbBundle;
import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.BlackboardAttribute;
/** /**
* Representation of single keyword to search for * A representation of a keyword for which to search. The search term for the
* keyword may be either a literal term, with or without wildcards, or a regex.
*
* It is currently possible to optionally associate an artifact attribute type
* with a keyword. This feature was added to support an initial implementation
* of account number search and may be removed in the future.
*/ */
class Keyword { class Keyword {
private String keywordString; // keyword to search for private String term;
private boolean isLiteral; // false if reg exp private boolean isLiteral;
private boolean isWholeword; // false if match a substring private boolean isWholeword;
private BlackboardAttribute.ATTRIBUTE_TYPE keywordType = null; private BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType;
/** /**
* Constructs a representation of a keyword for which to search. The search
* term for the keyword may be either a literal term without wildcards or a
* regex.
* *
* @param query Keyword to search for * @param term The search term for the keyword.
* @param isLiteral false if reg exp * @param isLiteral Whether or not the search term is a literal term instead
* of a regex. If the term is literal, this constructor
* assumes that it does not include wildcards.
*/ */
Keyword(String query, boolean isLiteral) { Keyword(String term, boolean isLiteral) {
this.keywordString = query; this.term = term;
this.isLiteral = isLiteral; this.isLiteral = isLiteral;
this.isWholeword = true; this.isWholeword = true;
} }
/** /**
* Constructs a representation of a keyword for which to search. The search
* term may be either a literal term, with or without wildcards, or a regex.
* *
* @param query Keyword to search for * @param term The search term.
* @param isLiteral false if reg exp * @param isLiteral Whether or not the search term is a literal term
* @param isWholeword false to match substring (undefined behavior if regexp * instead of a regex.
* is true) * @param hasNoWildcards Whether or not the search term, if it is a literal
* search term, includes wildcards.
*/ */
Keyword(String query, boolean isLiteral, boolean isWholeword) { Keyword(String term, boolean isLiteral, boolean hasNoWildcards) {
this.keywordString = query; this.term = term;
this.isLiteral = isLiteral; this.isLiteral = isLiteral;
this.isWholeword = isWholeword; this.isWholeword = hasNoWildcards;
} }
/** /**
* Constructs a representation of a keyword for which to search, for the
* purpose of finding a specific artifact attribute. The search term may be
* either a literal term, with or without wildcards, or a regex.
* *
* @param query Keyword to search for * The association of an artifact attribute type with a keyword was added to
* @param isLiteral false if reg exp * support an initial implementation of account number search and may be
* @param keywordType * removed in the future.
*
* @param term The search term.
* @param isLiteral Whether or not the search term is a literal term
* instead of a regex.
* @param hasNoWildcards Whether or not the search term, if it is a literal
* search term, includes wildcards.
* @param keywordType The artifact attribute type.
*/ */
Keyword(String query, boolean isLiteral, BlackboardAttribute.ATTRIBUTE_TYPE keywordType) { Keyword(String term, boolean isLiteral, BlackboardAttribute.ATTRIBUTE_TYPE keywordType) {
this(query, isLiteral); this(term, isLiteral);
this.keywordType = keywordType; this.artifactAtrributeType = keywordType;
}
void setType(BlackboardAttribute.ATTRIBUTE_TYPE keywordType) {
this.keywordType = keywordType;
}
BlackboardAttribute.ATTRIBUTE_TYPE getType() {
return this.keywordType;
} }
/** /**
* Gets the search term for the keyword, which may be either a literal term,
* with or without wild cards, or a regex.
* *
* @return Keyword to search for * @return The search term.
*/ */
String getQuery() { String getSearchTerm() {
return keywordString; return term;
} }
boolean isLiteral() { /**
* Indicates whether the search term for the keyword is a literal term, with
* or without wildcards, or a regex.
*
* @return True or false.
*/
boolean searchTermIsLiteral() {
return isLiteral; return isLiteral;
} }
boolean isWholeword() { /**
return isWholeword; * Indicates whether or not the search term for the keyword, if it is a
* literal term and not a regex, includes wildcards.
*
* @return True or false.
*/
boolean searchTermHasWildcards() {
return !isWholeword;
}
/**
* Sets the artifact attribute type associated with the keyword, if any.
*
* The association of an artifact attribute type with the keyword was added
* to support an initial implementation of account number search and may be
* removed in the future.
*
* @param artifactAtrributeType
*/
void setArtifactAttributeType(BlackboardAttribute.ATTRIBUTE_TYPE artifactAtrributeType) {
this.artifactAtrributeType = artifactAtrributeType;
}
/**
* Gets the artifact attribute type associated with the keyword, if any.
*
* The association of an artifact attribute type with the keyword was added
* to support an initial implementation of account number search and may be
* removed in the future.
*
* @return A attribute type object or null.
*/
BlackboardAttribute.ATTRIBUTE_TYPE getArtifactAttributeType() {
return this.artifactAtrributeType;
} }
@Override @Override
public String toString() { public String toString() {
return NbBundle.getMessage(this.getClass(), "Keyword.toString.text", keywordString, isLiteral, keywordType); return String.format("Keyword{term='%s', isLiteral=%s, artifactAtrributeType=%s}", term, isLiteral, artifactAtrributeType);
} }
@Override @Override
@ -103,21 +157,19 @@ class Keyword {
if (getClass() != obj.getClass()) { if (getClass() != obj.getClass()) {
return false; return false;
} }
final Keyword other = (Keyword) obj; Keyword other = (Keyword) obj;
if ((this.keywordString == null) ? (other.keywordString != null) : !this.keywordString.equals(other.keywordString)) { if ((this.term == null) ? (other.term != null) : !this.term.equals(other.term)) {
return false; return false;
} }
if (this.isLiteral != other.isLiteral) { return (this.isLiteral == other.isLiteral);
return false;
}
return true;
} }
@Override @Override
public int hashCode() { public int hashCode() {
int hash = 7; int hash = 7;
hash = 17 * hash + (this.keywordString != null ? this.keywordString.hashCode() : 0); hash = 17 * hash + (this.term != null ? this.term.hashCode() : 0);
hash = 17 * hash + (this.isLiteral ? 1 : 0); hash = 17 * hash + (this.isLiteral ? 1 : 0);
return hash; return hash;
} }
} }

View File

@ -1,15 +1,15 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2014 Basis Technology Corp. * Copyright 2011-2016 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -21,22 +21,27 @@ package org.sleuthkit.autopsy.keywordsearch;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* A list of keywords for which to search. Includes list creation and
* modification metadata and a setting that indicates whether messages should be
* sent to the ingest messages inbox when a keyword in the list is found.
*/
public class KeywordList { public class KeywordList {
private String name; private String name;
private Date created; private Date created;
private Date modified; private Date modified;
private Boolean useForIngest; private Boolean useForIngest;
private Boolean ingestMessages; private Boolean postIngestMessages;
private List<Keyword> keywords; private List<Keyword> keywords;
private Boolean locked; private Boolean locked;
KeywordList(String name, Date created, Date modified, Boolean useForIngest, Boolean ingestMessages, List<Keyword> keywords, boolean locked) { KeywordList(String name, Date created, Date modified, Boolean useForIngest, Boolean postIngestMessages, List<Keyword> keywords, boolean locked) {
this.name = name; this.name = name;
this.created = created; this.created = created;
this.modified = modified; this.modified = modified;
this.useForIngest = useForIngest; this.useForIngest = useForIngest;
this.ingestMessages = ingestMessages; this.postIngestMessages = postIngestMessages;
this.keywords = keywords; this.keywords = keywords;
this.locked = locked; this.locked = locked;
} }
@ -96,11 +101,11 @@ public class KeywordList {
} }
Boolean getIngestMessages() { Boolean getIngestMessages() {
return ingestMessages; return postIngestMessages;
} }
void setIngestMessages(boolean ingestMessages) { void setIngestMessages(boolean ingestMessages) {
this.ingestMessages = ingestMessages; this.postIngestMessages = ingestMessages;
} }
List<Keyword> getKeywords() { List<Keyword> getKeywords() {
@ -114,7 +119,7 @@ public class KeywordList {
boolean hasKeyword(String keyword) { boolean hasKeyword(String keyword) {
//note, this ignores isLiteral //note, this ignores isLiteral
for (Keyword k : keywords) { for (Keyword k : keywords) {
if (k.getQuery().equals(keyword)) { if (k.getSearchTerm().equals(keyword)) {
return true; return true;
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011-2016 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -18,11 +18,8 @@
*/ */
package org.sleuthkit.autopsy.keywordsearch; package org.sleuthkit.autopsy.keywordsearch;
import org.sleuthkit.datamodel.AbstractFile;
/** /**
* Interface for a search query. Implemented by various engines or methods of * Interface for kewyord search queries.
* using the same engine. One of these is created for each query.
*/ */
interface KeywordSearchQuery { interface KeywordSearchQuery {
@ -33,7 +30,7 @@ interface KeywordSearchQuery {
* *
* @return true if the query passed validation * @return true if the query passed validation
*/ */
public boolean validate(); boolean validate();
/** /**
* execute query and return results without publishing them return results * execute query and return results without publishing them return results
@ -43,7 +40,7 @@ interface KeywordSearchQuery {
* could be a notification to stop processing * could be a notification to stop processing
* @return * @return
*/ */
public QueryResults performQuery() throws NoOpenCoreException; QueryResults performQuery() throws NoOpenCoreException;
/** /**
* Set an optional filter to narrow down the search Adding multiple filters * Set an optional filter to narrow down the search Adding multiple filters
@ -51,14 +48,14 @@ interface KeywordSearchQuery {
* *
* @param filter filter to set on the query * @param filter filter to set on the query
*/ */
public void addFilter(KeywordQueryFilter filter); void addFilter(KeywordQueryFilter filter);
/** /**
* Set an optional SOLR field to narrow down the search * Set an optional SOLR field to narrow down the search
* *
* @param field field to set on the query * @param field field to set on the query
*/ */
public void setField(String field); void setField(String field);
/** /**
* Modify the query string to be searched as a substring instead of a whole * Modify the query string to be searched as a substring instead of a whole
@ -66,39 +63,39 @@ interface KeywordSearchQuery {
* *
* @param isSubstring * @param isSubstring
*/ */
public void setSubstringQuery(); void setSubstringQuery();
/** /**
* escape the query string and use the escaped string in the query * escape the query string and use the escaped string in the query
*/ */
public void escape(); void escape();
/** /**
* *
* @return true if query was escaped * @return true if query was escaped
*/ */
public boolean isEscaped(); boolean isEscaped();
/** /**
* *
* @return true if query is a literal query (non regex) * @return true if query is a literal query (non regex)
*/ */
public boolean isLiteral(); boolean isLiteral();
/** /**
* return original keyword/query string * return original keyword/query string
* *
* @return the query String supplied originally * @return the query String supplied originally
*/ */
public String getQueryString(); String getQueryString();
/** /**
* return escaped keyword/query string if escaping was done * return escaped keyword/query string if escaping was done
* *
* @return the escaped query string, or original string if no escaping done * @return the escaped query string, or original string if no escaping done
*/ */
public String getEscapedQueryString(); String getEscapedQueryString();
public KeywordCachedArtifact writeSingleFileHitsToBlackBoard(String termHit, KeywordHit hit, String snippet, String listName); KeywordCachedArtifact writeSingleFileHitsToBlackBoard(String termHit, KeywordHit hit, String snippet, String listName);
} }

View File

@ -55,9 +55,9 @@ class KeywordSearchQueryDelegator {
for (KeywordList keywordList : keywordLists) { for (KeywordList keywordList : keywordLists) {
for (Keyword keyword : keywordList.getKeywords()) { for (Keyword keyword : keywordList.getKeywords()) {
KeywordSearchQuery query; KeywordSearchQuery query;
if (keyword.isLiteral()) { if (keyword.searchTermIsLiteral()) {
// literal, exact match // literal, exact match
if (keyword.isWholeword()) { if (keyword.searchTermHasWildcards()) {
query = new LuceneQuery(keywordList, keyword); query = new LuceneQuery(keywordList, keyword);
query.escape(); query.escape();
} // literal, substring match } // literal, substring match

View File

@ -255,8 +255,8 @@ class KeywordSearchResultFactory extends ChildFactory<KeyValueQueryContent> {
//the query is executed later on demand //the query is executed later on demand
if (queryResults.getKeywords().size() == 1) { if (queryResults.getKeywords().size() == 1) {
//simple case, no need to process subqueries and do special escaping //simple case, no need to process subqueries and do special escaping
Keyword term = queryResults.getKeywords().iterator().next(); Keyword keyword = queryResults.getKeywords().iterator().next();
return constructEscapedSolrQuery(term.getQuery(), literal_query); return constructEscapedSolrQuery(keyword.getSearchTerm(), literal_query);
} else { } else {
//find terms for this content hit //find terms for this content hit
List<Keyword> hitTerms = new ArrayList<>(); List<Keyword> hitTerms = new ArrayList<>();
@ -274,7 +274,7 @@ class KeywordSearchResultFactory extends ChildFactory<KeyValueQueryContent> {
int curTerm = 0; int curTerm = 0;
for (Keyword term : hitTerms) { for (Keyword term : hitTerms) {
//escape subqueries, MAKE SURE they are not escaped again later //escape subqueries, MAKE SURE they are not escaped again later
highlightQuery.append(constructEscapedSolrQuery(term.getQuery(), literal_query)); highlightQuery.append(constructEscapedSolrQuery(term.getSearchTerm(), literal_query));
if (lastTerm != curTerm) { if (lastTerm != curTerm) {
highlightQuery.append(" "); //acts as OR || highlightQuery.append(" "); //acts as OR ||
} }

View File

@ -55,7 +55,7 @@ class LuceneQuery implements KeywordSearchQuery {
private final String keywordString; //original unescaped query private final String keywordString; //original unescaped query
private String keywordStringEscaped; private String keywordStringEscaped;
private boolean isEscaped; private boolean isEscaped;
private Keyword keywordQuery = null; private Keyword keyword = null;
private KeywordList keywordList = null; private KeywordList keywordList = null;
private final List<KeywordQueryFilter> filters = new ArrayList<>(); private final List<KeywordQueryFilter> filters = new ArrayList<>();
private String field = null; private String field = null;
@ -72,15 +72,15 @@ class LuceneQuery implements KeywordSearchQuery {
/** /**
* Constructor with query to process. * Constructor with query to process.
* *
* @param keywordQuery * @param keyword
*/ */
public LuceneQuery(KeywordList keywordList, Keyword keywordQuery) { public LuceneQuery(KeywordList keywordList, Keyword keyword) {
this.keywordList = keywordList; this.keywordList = keywordList;
this.keywordQuery = keywordQuery; this.keyword = keyword;
// @@@ BC: Long-term, we should try to get rid of this string and use only the // @@@ BC: Long-term, we should try to get rid of this string and use only the
// keyword object. Refactoring did not make its way through this yet. // keyword object. Refactoring did not make its way through this yet.
this.keywordString = keywordQuery.getQuery(); this.keywordString = keyword.getSearchTerm();
this.keywordStringEscaped = this.keywordString; this.keywordStringEscaped = this.keywordString;
} }
@ -168,8 +168,8 @@ class LuceneQuery implements KeywordSearchQuery {
//bogus - workaround the dir tree table issue //bogus - workaround the dir tree table issue
//attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID(), MODULE_NAME, "", "")); //attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP.getTypeID(), MODULE_NAME, "", ""));
//selector //selector
if (keywordQuery != null) { if (keyword != null) {
BlackboardAttribute.ATTRIBUTE_TYPE selType = keywordQuery.getType(); BlackboardAttribute.ATTRIBUTE_TYPE selType = keyword.getArtifactAttributeType();
if (selType != null) { if (selType != null) {
attributes.add(new BlackboardAttribute(selType, MODULE_NAME, termHit)); attributes.add(new BlackboardAttribute(selType, MODULE_NAME, termHit));
} }

View File

@ -115,7 +115,7 @@ class QueryResults {
for (final Keyword keyword : getKeywords()) { for (final Keyword keyword : getKeywords()) {
if (worker.isCancelled()) { if (worker.isCancelled()) {
logger.log(Level.INFO, "Cancel detected, bailing before new keyword processed: {0}", keyword.getQuery()); //NON-NLS logger.log(Level.INFO, "Cancel detected, bailing before new keyword processed: {0}", keyword.getSearchTerm()); //NON-NLS
break; break;
} }
@ -124,7 +124,7 @@ class QueryResults {
progress.progress(keyword.toString(), unitProgress); progress.progress(keyword.toString(), unitProgress);
} }
if (subProgress != null) { if (subProgress != null) {
String hitDisplayStr = keyword.getQuery(); String hitDisplayStr = keyword.getSearchTerm();
if (hitDisplayStr.length() > 50) { if (hitDisplayStr.length() > 50) {
hitDisplayStr = hitDisplayStr.substring(0, 49) + "..."; hitDisplayStr = hitDisplayStr.substring(0, 49) + "...";
} }
@ -132,7 +132,7 @@ class QueryResults {
} }
for (KeywordHit hit : getOneHitPerObject(keyword)) { for (KeywordHit hit : getOneHitPerObject(keyword)) {
String termString = keyword.getQuery(); String termString = keyword.getSearchTerm();
final String snippetQuery = KeywordSearchUtil.escapeLuceneQuery(termString); final String snippetQuery = KeywordSearchUtil.escapeLuceneQuery(termString);
String snippet; String snippet;
try { try {

View File

@ -403,7 +403,7 @@ public final class SearchRunner {
ProgressContributor[] subProgresses = new ProgressContributor[keywords.size()]; ProgressContributor[] subProgresses = new ProgressContributor[keywords.size()];
int i = 0; int i = 0;
for (Keyword keywordQuery : keywords) { for (Keyword keywordQuery : keywords) {
subProgresses[i] = AggregateProgressFactory.createProgressContributor(keywordQuery.getQuery()); subProgresses[i] = AggregateProgressFactory.createProgressContributor(keywordQuery.getSearchTerm());
progressGroup.addContributor(subProgresses[i]); progressGroup.addContributor(subProgresses[i]);
i++; i++;
} }
@ -419,11 +419,11 @@ public final class SearchRunner {
for (Keyword keywordQuery : keywords) { for (Keyword keywordQuery : keywords) {
if (this.isCancelled()) { if (this.isCancelled()) {
logger.log(Level.INFO, "Cancel detected, bailing before new keyword processed: {0}", keywordQuery.getQuery()); //NON-NLS logger.log(Level.INFO, "Cancel detected, bailing before new keyword processed: {0}", keywordQuery.getSearchTerm()); //NON-NLS
return null; return null;
} }
final String queryStr = keywordQuery.getQuery(); final String queryStr = keywordQuery.getSearchTerm();
final KeywordList list = keywordToList.get(queryStr); final KeywordList list = keywordToList.get(queryStr);
//new subProgress will be active after the initial query //new subProgress will be active after the initial query
@ -434,7 +434,7 @@ public final class SearchRunner {
KeywordSearchQuery keywordSearchQuery = null; KeywordSearchQuery keywordSearchQuery = null;
boolean isRegex = !keywordQuery.isLiteral(); boolean isRegex = !keywordQuery.searchTermIsLiteral();
if (isRegex) { if (isRegex) {
keywordSearchQuery = new TermsComponentQuery(list, keywordQuery); keywordSearchQuery = new TermsComponentQuery(list, keywordQuery);
} else { } else {
@ -454,16 +454,16 @@ public final class SearchRunner {
try { try {
queryResults = keywordSearchQuery.performQuery(); queryResults = keywordSearchQuery.performQuery();
} catch (NoOpenCoreException ex) { } catch (NoOpenCoreException ex) {
logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getQuery(), ex); //NON-NLS logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getSearchTerm(), ex); //NON-NLS
//no reason to continue with next query if recovery failed //no reason to continue with next query if recovery failed
//or wait for recovery to kick in and run again later //or wait for recovery to kick in and run again later
//likely case has closed and threads are being interrupted //likely case has closed and threads are being interrupted
return null; return null;
} catch (CancellationException e) { } catch (CancellationException e) {
logger.log(Level.INFO, "Cancel detected, bailing during keyword query: {0}", keywordQuery.getQuery()); //NON-NLS logger.log(Level.INFO, "Cancel detected, bailing during keyword query: {0}", keywordQuery.getSearchTerm()); //NON-NLS
return null; return null;
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getQuery(), e); //NON-NLS logger.log(Level.WARNING, "Error performing query: " + keywordQuery.getSearchTerm(), e); //NON-NLS
continue; continue;
} }
@ -481,7 +481,7 @@ public final class SearchRunner {
int totalUnits = newResults.getKeywords().size(); int totalUnits = newResults.getKeywords().size();
subProgresses[keywordsSearched].start(totalUnits); subProgresses[keywordsSearched].start(totalUnits);
int unitProgress = 0; int unitProgress = 0;
String queryDisplayStr = keywordQuery.getQuery(); String queryDisplayStr = keywordQuery.getSearchTerm();
if (queryDisplayStr.length() > 50) { if (queryDisplayStr.length() > 50) {
queryDisplayStr = queryDisplayStr.substring(0, 49) + "..."; queryDisplayStr = queryDisplayStr.substring(0, 49) + "...";
} }
@ -547,7 +547,7 @@ public final class SearchRunner {
keywordLists.add(list); keywordLists.add(list);
for (Keyword k : list.getKeywords()) { for (Keyword k : list.getKeywords()) {
keywords.add(k); keywords.add(k);
keywordToList.put(k.getQuery(), list); keywordToList.put(k.getSearchTerm(), list);
} }
} }
} }

View File

@ -121,7 +121,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
this.keyword = keyword; this.keyword = keyword;
this.keywordList = keywordList; this.keywordList = keywordList;
this.escapedQuery = keyword.getQuery(); this.escapedQuery = keyword.getSearchTerm();
} }
@Override @Override
@ -146,7 +146,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
@Override @Override
public void escape() { public void escape() {
escapedQuery = Pattern.quote(keyword.getQuery()); escapedQuery = Pattern.quote(keyword.getSearchTerm());
isEscaped = true; isEscaped = true;
} }
@ -181,7 +181,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
@Override @Override
public String getQueryString() { public String getQueryString() {
return keyword.getQuery(); return keyword.getSearchTerm();
} }
@Override @Override
@ -189,7 +189,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
BlackboardArtifact newArtifact; BlackboardArtifact newArtifact;
Collection<BlackboardAttribute> attributes = new ArrayList<>(); Collection<BlackboardAttribute> attributes = new ArrayList<>();
if (keyword.getType() == ATTRIBUTE_TYPE.TSK_CARD_NUMBER) { if (keyword.getArtifactAttributeType() == ATTRIBUTE_TYPE.TSK_CARD_NUMBER) {
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE, MODULE_NAME, Account.Type.CREDIT_CARD.name())); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_ACCOUNT_TYPE, MODULE_NAME, Account.Type.CREDIT_CARD.name()));
Map<BlackboardAttribute.Type, BlackboardAttribute> parsedTrackAttributeMap = new HashMap<>(); Map<BlackboardAttribute.Type, BlackboardAttribute> parsedTrackAttributeMap = new HashMap<>();
@ -266,7 +266,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
//regex match //regex match
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD, MODULE_NAME, termHit)); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD, MODULE_NAME, termHit));
//regex keyword //regex keyword
attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP, MODULE_NAME, keyword.getQuery())); attributes.add(new BlackboardAttribute(ATTRIBUTE_TYPE.TSK_KEYWORD_REGEXP, MODULE_NAME, keyword.getSearchTerm()));
//make keyword hit artifact //make keyword hit artifact
try { try {
@ -325,7 +325,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
try { try {
terms = KeywordSearch.getServer().queryTerms(q).getTerms(TERMS_SEARCH_FIELD); terms = KeywordSearch.getServer().queryTerms(q).getTerms(TERMS_SEARCH_FIELD);
} catch (KeywordSearchModuleException ex) { } catch (KeywordSearchModuleException ex) {
LOGGER.log(Level.SEVERE, "Error executing the regex terms query: " + keyword.getQuery(), ex); //NON-NLS LOGGER.log(Level.SEVERE, "Error executing the regex terms query: " + keyword.getSearchTerm(), ex); //NON-NLS
//TODO: this is almost certainly wrong and guaranteed to throw a NPE at some point!!!! //TODO: this is almost certainly wrong and guaranteed to throw a NPE at some point!!!!
} }
@ -339,7 +339,7 @@ final class TermsComponentQuery implements KeywordSearchQuery {
for (Term term : terms) { for (Term term : terms) {
final String termStr = KeywordSearchUtil.escapeLuceneQuery(term.getTerm()); final String termStr = KeywordSearchUtil.escapeLuceneQuery(term.getTerm());
if (keyword.getType() == ATTRIBUTE_TYPE.TSK_CARD_NUMBER) { if (keyword.getArtifactAttributeType() == ATTRIBUTE_TYPE.TSK_CARD_NUMBER) {
//If the keyword is a credit card number, pass it through luhn validator //If the keyword is a credit card number, pass it through luhn validator
Matcher matcher = CCN_PATTERN.matcher(term.getTerm()); Matcher matcher = CCN_PATTERN.matcher(term.getTerm());
matcher.find(); matcher.find();

View File

@ -123,13 +123,13 @@ final class XmlKeywordSearchList extends KeywordSearchList {
for (Keyword keyword : keywords) { for (Keyword keyword : keywords) {
Element keywordEl = doc.createElement(KEYWORD_EL); Element keywordEl = doc.createElement(KEYWORD_EL);
String literal = keyword.isLiteral() ? "true" : "false"; //NON-NLS String literal = keyword.searchTermIsLiteral() ? "true" : "false"; //NON-NLS
keywordEl.setAttribute(KEYWORD_LITERAL_ATTR, literal); keywordEl.setAttribute(KEYWORD_LITERAL_ATTR, literal);
BlackboardAttribute.ATTRIBUTE_TYPE selectorType = keyword.getType(); BlackboardAttribute.ATTRIBUTE_TYPE selectorType = keyword.getArtifactAttributeType();
if (selectorType != null) { if (selectorType != null) {
keywordEl.setAttribute(KEYWORD_SELECTOR_ATTR, selectorType.getLabel()); keywordEl.setAttribute(KEYWORD_SELECTOR_ATTR, selectorType.getLabel());
} }
keywordEl.setTextContent(keyword.getQuery()); keywordEl.setTextContent(keyword.getSearchTerm());
listEl.appendChild(keywordEl); listEl.appendChild(keywordEl);
} }
rootEl.appendChild(listEl); rootEl.appendChild(listEl);
@ -199,7 +199,7 @@ final class XmlKeywordSearchList extends KeywordSearchList {
String selector = wordEl.getAttribute(KEYWORD_SELECTOR_ATTR); String selector = wordEl.getAttribute(KEYWORD_SELECTOR_ATTR);
if (!selector.equals("")) { if (!selector.equals("")) {
BlackboardAttribute.ATTRIBUTE_TYPE selectorType = BlackboardAttribute.ATTRIBUTE_TYPE.fromLabel(selector); BlackboardAttribute.ATTRIBUTE_TYPE selectorType = BlackboardAttribute.ATTRIBUTE_TYPE.fromLabel(selector);
keyword.setType(selectorType); keyword.setArtifactAttributeType(selectorType);
} }
words.add(keyword); words.add(keyword);