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;
|
||||
ResultSet resultSet = null;
|
||||
String tableName = EamDbUtil.correlationTypeToInstanceTableName(type);
|
||||
StringBuilder sql = new StringBuilder(3);
|
||||
sql.append("select * from ");
|
||||
sql.append(tableName);
|
||||
sql.append(" WHERE ");
|
||||
sql.append(whereClause);
|
||||
StringBuilder sql = new StringBuilder(300);
|
||||
sql.append("select * from ")
|
||||
.append(tableName)
|
||||
.append(" WHERE ")
|
||||
.append(whereClause);
|
||||
|
||||
try {
|
||||
preparedStatement = conn.prepareStatement(sql.toString());
|
||||
|
@ -21,7 +21,6 @@ package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.commons.dbcp2.BasicDataSource;
|
||||
|
@ -63,9 +63,7 @@ final public class CaseDBCommonAttributeInstance extends AbstractCommonAttribute
|
||||
|
||||
SleuthkitCase tskDb = currentCase.getSleuthkitCase();
|
||||
|
||||
AbstractFile abstractFile = tskDb.findAllFilesWhere(String.format("obj_id in (%s)", this.getAbstractFileObjectId())).get(0);
|
||||
|
||||
return abstractFile;
|
||||
return tskDb.findAllFilesWhere(String.format("obj_id in (%s)", this.getAbstractFileObjectId())).get(0);
|
||||
|
||||
} 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);
|
||||
|
@ -87,14 +87,12 @@ public final class CommonAttributePanel extends javax.swing.JDialog {
|
||||
|
||||
private static boolean isEamDbAvailable() {
|
||||
try {
|
||||
final boolean conditions = EamDb.isEnabled() &&
|
||||
return EamDb.isEnabled() &&
|
||||
EamDb.getInstance() != null &&
|
||||
EamDb.getInstance().getCases().size() > 1 &&
|
||||
Case.isCaseOpen() &&
|
||||
Case.getCurrentCase() != null &&
|
||||
EamDb.getInstance().getCase(Case.getCurrentCase()) != null;
|
||||
|
||||
return conditions;
|
||||
} catch (EamDbException 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
|
||||
@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.start();
|
||||
progress.switchToIndeterminate();
|
||||
@ -350,7 +348,7 @@ public final class CommonAttributePanel extends javax.swing.JDialog {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<Integer, String> doInBackground() throws Exception {
|
||||
protected Map<Integer, String> doInBackground() throws EamDbException {
|
||||
|
||||
List<CorrelationCase> dataSources = EamDb.getInstance().getCases();
|
||||
Map<Integer, String> caseMap = mapDataSources(dataSources);
|
||||
|
@ -56,8 +56,7 @@ final public class CommonAttributeValue {
|
||||
* @return
|
||||
*/
|
||||
public String getCases() {
|
||||
final String cases = this.fileInstances.stream().map(AbstractCommonAttributeInstance::getCaseName).collect(Collectors.joining(", "));
|
||||
return cases;
|
||||
return this.fileInstances.stream().map(AbstractCommonAttributeInstance::getCaseName).collect(Collectors.joining(", "));
|
||||
}
|
||||
|
||||
public String getDataSources() {
|
||||
@ -66,8 +65,7 @@ final public class CommonAttributeValue {
|
||||
sources.add(data.getDataSource());
|
||||
}
|
||||
|
||||
final String dataSources = String.join(", ", sources);
|
||||
return dataSources;
|
||||
return String.join(", ", sources);
|
||||
}
|
||||
|
||||
void addInstance(AbstractCommonAttributeInstance metadata) {
|
||||
|
@ -25,7 +25,6 @@ import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.nodes.Sheet;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
|
||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
|
||||
import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
@ -36,8 +35,6 @@ import org.sleuthkit.autopsy.datamodel.NodeProperty;
|
||||
*/
|
||||
public class CommonAttributeValueNode extends DisplayableItemNode {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(CommonAttributeValueNode.class.getName());
|
||||
|
||||
private final String value;
|
||||
private final int commonFileCount;
|
||||
private final String cases;
|
||||
|
@ -55,7 +55,7 @@ public class CommonAttributesSearchResultsViewerTable extends DataResultViewerTa
|
||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), 200);
|
||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_hashsetHitsColLbl(), 100);
|
||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_mimeTypeColLbl(), 130);
|
||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), 300);;
|
||||
map.put(Bundle.CommonFilesSearchResultsViewerTable_tagsColLbl1(), 300);
|
||||
|
||||
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) "
|
||||
+ "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){
|
||||
this.dataSources = dataSources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the CentralRepoCommonAttributeInstance to find common attribute instances and generate nodes at the UI level.
|
||||
*/
|
||||
InterCaseSearchResultsProcessor(){}
|
||||
|
||||
/**
|
||||
|
@ -156,11 +156,13 @@ public abstract class IntraCaseCommonAttributeSearcher extends AbstractCommonAtt
|
||||
StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size());
|
||||
if (!mimeTypesToFilterOn.isEmpty()) {
|
||||
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 = String.format(FILTER_BY_MIME_TYPES_WHERE_CLAUSE, new Object[]{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(CommonAttributeValueNode mn);
|
||||
T visit(CommonAttributeValueNode cavn);
|
||||
|
||||
T visit(CommonAttributeSearchResultRootNode cfn);
|
||||
|
||||
@ -200,8 +200,8 @@ public interface DisplayableItemNodeVisitor<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public T visit(CommonAttributeValueNode mn) {
|
||||
return defaultVisit(mn);
|
||||
public T visit(CommonAttributeValueNode cavn) {
|
||||
return defaultVisit(cavn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -25,11 +25,13 @@ import org.netbeans.junit.NbModuleSuite;
|
||||
import org.netbeans.junit.NbTestCase;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.python.icu.impl.Assert;
|
||||
import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeSearcher;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.AllInterCaseCommonAttributeSearcher;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.SingleInterCaseCommonAttributeSearcher;
|
||||
import static org.sleuthkit.autopsy.commonfilessearch.InterCaseTestUtils.*;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
|
||||
/**
|
||||
* Tests with case 3 as the current case.
|
||||
@ -62,7 +64,7 @@ public class IngestedWithHashAndFileTypeInterCaseTests extends NbTestCase {
|
||||
try {
|
||||
this.utils.enableCentralRepo();
|
||||
this.utils.createCases(this.utils.getIngestSettingsForHashAndFileType(), InterCaseTestUtils.CASE3);
|
||||
} catch (Exception ex) {
|
||||
} catch (TskCoreException | EamDbException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.commonfilessearch;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -96,6 +97,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
||||
* find nothing and no errors should arise.
|
||||
*/
|
||||
public void testOne() {
|
||||
|
||||
try {
|
||||
Map<Long, String> dataSources = this.utils.getDataSourceMap();
|
||||
|
||||
@ -108,7 +110,7 @@ public class IngestedWithNoFileTypesIntraCaseTests extends NbTestCase {
|
||||
|
||||
assertTrue(files.isEmpty());
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (TskCoreException | NoCurrentCaseException | SQLException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.sleuthkit.autopsy.commonfilessearch;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Map;
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import junit.framework.Test;
|
||||
@ -26,12 +27,14 @@ import org.netbeans.junit.NbModuleSuite;
|
||||
import org.netbeans.junit.NbTestCase;
|
||||
import org.openide.util.Exceptions;
|
||||
import org.python.icu.impl.Assert;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.AllIntraCaseCommonAttributeSearcher;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.IntraCaseCommonAttributeSearcher;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.SingleIntraCaseCommonAttributeSearcher;
|
||||
import static org.sleuthkit.autopsy.commonfilessearch.IntraCaseTestUtils.SET1;
|
||||
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
|
||||
@ -83,7 +86,7 @@ public class UningestedCasesIntraCaseTests extends NbTestCase {
|
||||
int resultCount = metadata.size();
|
||||
assertEquals(resultCount, 0);
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (TskCoreException | NoCurrentCaseException | SQLException ex) {
|
||||
Exceptions.printStackTrace(ex);
|
||||
Assert.fail(ex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user