mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-09 06:39:33 +00:00
4361 AutopsyService to populate object id for data sources in cr
This commit is contained in:
parent
9f48caf897
commit
aee7efd6d5
@ -133,6 +133,24 @@ abstract class AbstractSqlEamDb implements EamDb {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException{
|
||||||
|
Connection conn = connect();
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
String sql = "UPDATE data_sources SET datasource_id=? WHERE id=?";
|
||||||
|
try {
|
||||||
|
preparedStatement = conn.prepareStatement(sql);
|
||||||
|
preparedStatement.setLong(1, dataSourceObjectId);
|
||||||
|
preparedStatement.setInt(2, rowId);
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
throw new EamDbException("Error updating data source object id for data_sources row " + rowId, ex);
|
||||||
|
} finally {
|
||||||
|
EamDbUtil.closeStatement(preparedStatement);
|
||||||
|
EamDbUtil.closeConnection(conn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for the given name from the name/value db_info table.
|
* Get the value for the given name from the name/value db_info table.
|
||||||
*
|
*
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* Central Repository
|
||||||
|
*
|
||||||
|
* Copyright 2018 Basis Technology Corp.
|
||||||
|
* Contact: carrier <at> sleuthkit <dot> org
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.sleuthkit.autopsy.centralrepository.datamodel;
|
||||||
|
|
||||||
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
|
import org.sleuthkit.autopsy.appservices.AutopsyService
|
||||||
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
import org.sleuthkit.datamodel.DataSource;
|
||||||
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
|
|
||||||
|
|
||||||
|
@ServiceProvider(service = AutopsyService.class)
|
||||||
|
public class CaseUpdateAutopsyService implements AutopsyService{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getServiceName() {
|
||||||
|
return "UpdateCR";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void openCaseResources(CaseContext context) throws AutopsyServiceException {
|
||||||
|
if (EamDb.isEnabled()){
|
||||||
|
try {
|
||||||
|
EamDb centralRepository = EamDb.getInstance();
|
||||||
|
CorrelationCase correlationCase = centralRepository.getCase(context.getCase());
|
||||||
|
for (CorrelationDataSource correlationDataSource : centralRepository.getDataSources()) {
|
||||||
|
if (correlationDataSource.getCaseID() == correlationCase.getID() && correlationDataSource.getCaseDataSourceID() == null){
|
||||||
|
for (Content dataSource : context.getCase().getDataSources()){
|
||||||
|
if (((DataSource)dataSource).getDeviceId().equals(correlationDataSource.getDeviceID())){
|
||||||
|
centralRepository.addDataSourceObjectId(correlationDataSource.getID(), dataSource.getId());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (EamDbException | TskCoreException ex) {
|
||||||
|
throw new AutopsyServiceException("Unabe to update datasources in central repository", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -110,6 +110,16 @@ public interface EamDb {
|
|||||||
*/
|
*/
|
||||||
public void newDbInfo(String name, String value) throws EamDbException;
|
public void newDbInfo(String name, String value) throws EamDbException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the data source object id for a specific entry in the data_sources
|
||||||
|
* table
|
||||||
|
*
|
||||||
|
* @param rowId - the row id for the data_sources table entry
|
||||||
|
* @param dataSourceObjectId - the object id for the data source from the
|
||||||
|
* caseDb
|
||||||
|
*/
|
||||||
|
void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value for the given name from the name/value db_info table.
|
* Get the value for the given name from the name/value db_info table.
|
||||||
*
|
*
|
||||||
@ -346,8 +356,8 @@ public interface EamDb {
|
|||||||
* Find a correlation attribute in the Central Repository database given the
|
* Find a correlation attribute in the Central Repository database given the
|
||||||
* instance type, case, data source, value, and file path.
|
* instance type, case, data source, value, and file path.
|
||||||
*
|
*
|
||||||
* Method exists to support instances added using Central Repository version 1,1 and
|
* Method exists to support instances added using Central Repository version
|
||||||
* older
|
* 1,1 and older
|
||||||
*
|
*
|
||||||
* @param type The type of instance.
|
* @param type The type of instance.
|
||||||
* @param correlationCase The case tied to the instance.
|
* @param correlationCase The case tied to the instance.
|
||||||
@ -369,7 +379,8 @@ public interface EamDb {
|
|||||||
* @param type The type of instance.
|
* @param type The type of instance.
|
||||||
* @param correlationCase The case tied to the instance.
|
* @param correlationCase The case tied to the instance.
|
||||||
* @param correlationDataSource The data source tied to the instance.
|
* @param correlationDataSource The data source tied to the instance.
|
||||||
* @param objectID The object id of the file tied to the instance.
|
* @param objectID The object id of the file tied to the
|
||||||
|
* instance.
|
||||||
*
|
*
|
||||||
* @return The correlation attribute if it exists; otherwise null.
|
* @return The correlation attribute if it exists; otherwise null.
|
||||||
*
|
*
|
||||||
|
@ -274,6 +274,16 @@ final class SqliteEamDb extends AbstractSqlEamDb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws EamDbException{
|
||||||
|
try {
|
||||||
|
acquireExclusiveLock();
|
||||||
|
super.addDataSourceObjectId(rowId, dataSourceObjectId);
|
||||||
|
} finally {
|
||||||
|
releaseExclusiveLock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new Case in the database
|
* Creates new Case in the database
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user