mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
codacy stuff
This commit is contained in:
parent
7daab901b3
commit
ac096fac57
@ -1922,11 +1922,11 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
String tableName = EamDbUtil.correlationTypeToInstanceTableName(type);
|
String tableName = EamDbUtil.correlationTypeToInstanceTableName(type);
|
||||||
StringBuilder sql = new StringBuilder(3);
|
StringBuilder sql = new StringBuilder(300);
|
||||||
sql.append("select * from ");
|
sql.append("select * from ")
|
||||||
sql.append(tableName);
|
.append(tableName)
|
||||||
sql.append(" WHERE ");
|
.append(" WHERE ")
|
||||||
sql.append(whereClause);
|
.append(whereClause);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
preparedStatement = conn.prepareStatement(sql.toString());
|
preparedStatement = conn.prepareStatement(sql.toString());
|
||||||
|
@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.centralrepository.datamodel;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.apache.commons.dbcp2.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
@ -63,9 +63,7 @@ final public class CaseDBCommonAttributeInstance extends AbstractCommonAttribute
|
|||||||
|
|
||||||
SleuthkitCase tskDb = currentCase.getSleuthkitCase();
|
SleuthkitCase tskDb = currentCase.getSleuthkitCase();
|
||||||
|
|
||||||
AbstractFile abstractFile = tskDb.findAllFilesWhere(String.format("obj_id in (%s)", this.getAbstractFileObjectId())).get(0);
|
return tskDb.findAllFilesWhere(String.format("obj_id in (%s)", this.getAbstractFileObjectId())).get(0);
|
||||||
|
|
||||||
return abstractFile;
|
|
||||||
|
|
||||||
} catch (TskCoreException | NoCurrentCaseException ex) {
|
} catch (TskCoreException | NoCurrentCaseException ex) {
|
||||||
LOGGER.log(Level.SEVERE, String.format("Unable to find AbstractFile for record with obj_id: %s. Node not created.", new Object[]{this.getAbstractFileObjectId()}), ex);
|
LOGGER.log(Level.SEVERE, String.format("Unable to find AbstractFile for record with obj_id: %s. Node not created.", new Object[]{this.getAbstractFileObjectId()}), ex);
|
||||||
|
@ -87,14 +87,12 @@ public final class CommonAttributePanel extends javax.swing.JDialog {
|
|||||||
|
|
||||||
private static boolean isEamDbAvailable() {
|
private static boolean isEamDbAvailable() {
|
||||||
try {
|
try {
|
||||||
final boolean conditions = EamDb.isEnabled() &&
|
return EamDb.isEnabled() &&
|
||||||
EamDb.getInstance() != null &&
|
EamDb.getInstance() != null &&
|
||||||
EamDb.getInstance().getCases().size() > 1 &&
|
EamDb.getInstance().getCases().size() > 1 &&
|
||||||
Case.isCaseOpen() &&
|
Case.isCaseOpen() &&
|
||||||
Case.getCurrentCase() != null &&
|
Case.getCurrentCase() != null &&
|
||||||
EamDb.getInstance().getCase(Case.getCurrentCase()) != null;
|
EamDb.getInstance().getCase(Case.getCurrentCase()) != null;
|
||||||
|
|
||||||
return conditions;
|
|
||||||
} catch (EamDbException ex) {
|
} catch (EamDbException ex) {
|
||||||
LOGGER.log(Level.SEVERE, "Unexpected exception while checking for EamDB enabled.", ex);
|
LOGGER.log(Level.SEVERE, "Unexpected exception while checking for EamDB enabled.", ex);
|
||||||
}
|
}
|
||||||
@ -138,7 +136,7 @@ public final class CommonAttributePanel extends javax.swing.JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"BoxedValueEquality", "NumberEquality"})
|
@SuppressWarnings({"BoxedValueEquality", "NumberEquality"})
|
||||||
protected CommonAttributeSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException, Exception {
|
protected CommonAttributeSearchResults doInBackground() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException {
|
||||||
progress = ProgressHandle.createHandle(Bundle.CommonFilesPanel_search_done_searchProgressGathering());
|
progress = ProgressHandle.createHandle(Bundle.CommonFilesPanel_search_done_searchProgressGathering());
|
||||||
progress.start();
|
progress.start();
|
||||||
progress.switchToIndeterminate();
|
progress.switchToIndeterminate();
|
||||||
@ -350,7 +348,7 @@ public final class CommonAttributePanel extends javax.swing.JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Map<Integer, String> doInBackground() throws Exception {
|
protected Map<Integer, String> doInBackground() throws EamDbException {
|
||||||
|
|
||||||
List<CorrelationCase> dataSources = EamDb.getInstance().getCases();
|
List<CorrelationCase> dataSources = EamDb.getInstance().getCases();
|
||||||
Map<Integer, String> caseMap = mapDataSources(dataSources);
|
Map<Integer, String> caseMap = mapDataSources(dataSources);
|
||||||
|
@ -56,8 +56,7 @@ final public class CommonAttributeValue {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getCases() {
|
public String getCases() {
|
||||||
final String cases = this.fileInstances.stream().map(AbstractCommonAttributeInstance::getCaseName).collect(Collectors.joining(", "));
|
return this.fileInstances.stream().map(AbstractCommonAttributeInstance::getCaseName).collect(Collectors.joining(", "));
|
||||||
return cases;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDataSources() {
|
public String getDataSources() {
|
||||||
@ -66,8 +65,7 @@ final public class CommonAttributeValue {
|
|||||||
sources.add(data.getDataSource());
|
sources.add(data.getDataSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
final String dataSources = String.join(", ", sources);
|
return String.join(", ", sources);
|
||||||
return dataSources;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void addInstance(AbstractCommonAttributeInstance metadata) {
|
void addInstance(AbstractCommonAttributeInstance metadata) {
|
||||||
|
@ -25,7 +25,6 @@ import org.openide.nodes.Children;
|
|||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
import org.openide.nodes.Sheet;
|
import org.openide.nodes.Sheet;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
|
||||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
|
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
|
||||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
|
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
|
||||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||||
@ -36,8 +35,6 @@ import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
|||||||
*/
|
*/
|
||||||
public class CommonAttributeValueNode extends DisplayableItemNode {
|
public class CommonAttributeValueNode extends DisplayableItemNode {
|
||||||
|
|
||||||
private static final Logger LOGGER = Logger.getLogger(CommonAttributeValueNode.class.getName());
|
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private final int commonFileCount;
|
private final int commonFileCount;
|
||||||
private final String cases;
|
private final String cases;
|
||||||
|
@ -55,7 +55,7 @@ public class CommonAttributesSearchResultsViewerTable extends DataResultViewerTa
|
|||||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), 200);
|
map.put(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), 200);
|
||||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), 100);
|
map.put(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), 100);
|
||||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_mimeTypeColLbl(), 130);
|
map.put(Bundle.CommonFilesSearchResultsViewerTable_mimeTypeColLbl(), 130);
|
||||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), 300);;
|
map.put(Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), 300);
|
||||||
|
|
||||||
COLUMN_WIDTHS = Collections.unmodifiableMap(map);
|
COLUMN_WIDTHS = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
@ -57,10 +57,17 @@ final class InterCaseSearchResultsProcessor {
|
|||||||
+ "WHERE case_id=%s AND (known_status !=%s OR known_status IS NULL) GROUP BY value) "
|
+ "WHERE case_id=%s AND (known_status !=%s OR known_status IS NULL) GROUP BY value) "
|
||||||
+ "AND (case_id=%s OR case_id=%s) GROUP BY value HAVING COUNT(DISTINCT case_id) > 1) ORDER BY value";
|
+ "AND (case_id=%s OR case_id=%s) GROUP BY value HAVING COUNT(DISTINCT case_id) > 1) ORDER BY value";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the InterCaseCommonAttributeSearchers to find common attribute instances and generate nodes at the UI level.
|
||||||
|
* @param dataSources
|
||||||
|
*/
|
||||||
InterCaseSearchResultsProcessor(Map<Long, String> dataSources){
|
InterCaseSearchResultsProcessor(Map<Long, String> dataSources){
|
||||||
this.dataSources = dataSources;
|
this.dataSources = dataSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the CentralRepoCommonAttributeInstance to find common attribute instances and generate nodes at the UI level.
|
||||||
|
*/
|
||||||
InterCaseSearchResultsProcessor(){}
|
InterCaseSearchResultsProcessor(){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,11 +156,13 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt
|
|||||||
StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size());
|
StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size());
|
||||||
if (!mimeTypesToFilterOn.isEmpty()) {
|
if (!mimeTypesToFilterOn.isEmpty()) {
|
||||||
for (String mimeType : mimeTypesToFilterOn) {
|
for (String mimeType : mimeTypesToFilterOn) {
|
||||||
mimeTypeFilter.append("'").append(mimeType).append("',");
|
mimeTypeFilter.append(SINGLE_QUOTE).append(mimeType).append(SINGLE_QUTOE_COMMA);
|
||||||
}
|
}
|
||||||
mimeTypeString = mimeTypeFilter.toString().substring(0, mimeTypeFilter.length() - 1);
|
mimeTypeString = mimeTypeFilter.toString().substring(0, mimeTypeFilter.length() - 1);
|
||||||
mimeTypeString = String.format(FILTER_BY_MIME_TYPES_WHERE_CLAUSE, new Object[]{mimeTypeString});
|
mimeTypeString = String.format(FILTER_BY_MIME_TYPES_WHERE_CLAUSE, new Object[]{mimeTypeString});
|
||||||
}
|
}
|
||||||
return mimeTypeString;
|
return mimeTypeString;
|
||||||
}
|
}
|
||||||
|
static final String SINGLE_QUTOE_COMMA = "',";
|
||||||
|
static final String SINGLE_QUOTE = "'";
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public interface DisplayableItemNodeVisitor<T> {
|
|||||||
|
|
||||||
T visit(InterestingHits.SetNameNode ihsn);
|
T visit(InterestingHits.SetNameNode ihsn);
|
||||||
|
|
||||||
T visit(CommonAttributeValueNode mn);
|
T visit(CommonAttributeValueNode cavn);
|
||||||
|
|
||||||
T visit(CommonAttributeSearchResultRootNode cfn);
|
T visit(CommonAttributeSearchResultRootNode cfn);
|
||||||
|
|
||||||
@ -200,8 +200,8 @@ public interface DisplayableItemNodeVisitor<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T visit(CommonAttributeValueNode mn) {
|
public T visit(CommonAttributeValueNode cavn) {
|
||||||
return defaultVisit(mn);
|
return defaultVisit(cavn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,11 +25,13 @@ import org.netbeans.junit.NbModuleSuite;
|
|||||||
import org.netbeans.junit.NbTestCase;
|
import org.netbeans.junit.NbTestCase;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.python.icu.impl.Assert;
|
import org.python.icu.impl.Assert;
|
||||||
|
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeSearcher;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.AllInterCaseCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.AllInterCaseCommonAttributeSearcher;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.SingleInterCaseCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.SingleInterCaseCommonAttributeSearcher;
|
||||||
import static org.sleuthkit.autopsy.commonfilessearch.InterCaseTestUtils.*;
|
import static org.sleuthkit.autopsy.commonfilessearch.InterCaseTestUtils.*;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests with case 3 as the current case.
|
* Tests with case 3 as the current case.
|
||||||
@ -62,7 +64,7 @@ public class IngestedWithHashAndFileTypeInterCaseTests extends NbTestCase {
|
|||||||
try {
|
try {
|
||||||
this.utils.enableCentralRepo();
|
this.utils.enableCentralRepo();
|
||||||
this.utils.createCases(this.utils.getIngestSettingsForHashAndFileType(), InterCaseTestUtils.CASE3);
|
this.utils.createCases(this.utils.getIngestSettingsForHashAndFileType(), InterCaseTestUtils.CASE3);
|
||||||
} catch (Exception ex) {
|
} catch (TskCoreException | EamDbException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.commonfilessearch;
|
package org.sleuthkit.autopsy.commonfilessearch;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -96,6 +97,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
|||||||
* find nothing and no errors should arise.
|
* find nothing and no errors should arise.
|
||||||
*/
|
*/
|
||||||
public void testOne() {
|
public void testOne() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
|||||||
|
|
||||||
assertTrue(files.isEmpty());
|
assertTrue(files.isEmpty());
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (TskCoreException | NoCurrentCaseException | SQLException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.commonfilessearch;
|
package org.sleuthkit.autopsy.commonfilessearch;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
@ -26,12 +27,14 @@ import org.netbeans.junit.NbModuleSuite;
|
|||||||
import org.netbeans.junit.NbTestCase;
|
import org.netbeans.junit.NbTestCase;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.python.icu.impl.Assert;
|
import org.python.icu.impl.Assert;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.AllIntraCaseCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.AllIntraCaseCommonAttributeSearcher;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.IntraCaseCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.IntraCaseCommonAttributeSearcher;
|
||||||
import org.sleuthkit.autopsy.commonfilesearch.SingleIntraCaseCommonAttributeSearcher;
|
import org.sleuthkit.autopsy.commonfilesearch.SingleIntraCaseCommonAttributeSearcher;
|
||||||
import static org.sleuthkit.autopsy.commonfilessearch.IntraCaseTestUtils.SET1;
|
import static org.sleuthkit.autopsy.commonfilessearch.IntraCaseTestUtils.SET1;
|
||||||
import static org.sleuthkit.autopsy.commonfilessearch.IntraCaseTestUtils.getDataSourceIdByName;
|
import static org.sleuthkit.autopsy.commonfilessearch.IntraCaseTestUtils.getDataSourceIdByName;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that cases which are created but have not run any ingest modules turn up
|
* Test that cases which are created but have not run any ingest modules turn up
|
||||||
@ -83,7 +86,7 @@ public class UningestedCasesIntraCaseTests extends NbTestCase {
|
|||||||
int resultCount = metadata.size();
|
int resultCount = metadata.size();
|
||||||
assertEquals(resultCount, 0);
|
assertEquals(resultCount, 0);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (TskCoreException | NoCurrentCaseException | SQLException ex) {
|
||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
Assert.fail(ex);
|
Assert.fail(ex);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user