Skip to content
Snippets Groups Projects
Unverified Commit 8ec89d77 authored by Jayaram Sreevalsan's avatar Jayaram Sreevalsan Committed by GitHub
Browse files

Merge pull request #2799 from msilva-basis/os_account_merge

Fire event when os accounts are merged
parents 7f947695 3295db2f
No related branches found
No related tags found
No related merge requests found
......@@ -958,7 +958,8 @@ private void mergeOsAccounts(OsAccount sourceAccount, OsAccount destAccount, Cas
s.executeUpdate(query);
// TBD: We need to emit another event which tells CT that two accounts are being merged so it can updates other dedicated tables
// register the merged accounts with the transaction to fire off an event
trans.registerMergedOsAccount(sourceAccount.getId(), destAccount.getId());
// Update the source account. Make a dummy signature to prevent problems with the unique constraint.
String mergedSignature = makeMergedOsAccountSignature();
......
......@@ -13713,6 +13713,7 @@ public static final class CaseDbTransaction {
private List<Host> hostsAdded = new ArrayList<>();
private List<OsAccount> accountsChanged = new ArrayList<>();
private List<OsAccount> accountsAdded = new ArrayList<>();
private List<TskEvent.MergedAccountsPair> accountsMerged = new ArrayList<>();
 
private List<Long> deletedOsAccountObjectIds = new ArrayList<>();
private List<Long> deletedResultObjectIds = new ArrayList<>();
......@@ -13800,6 +13801,16 @@ void registerAddedOsAccount(OsAccount account) {
}
}
 
/**
* Saves an account that has been merged as part of this transaction.
*
* @param sourceOsAccountObjId
* @param destinationOsAccountObjId
*/
void registerMergedOsAccount(long sourceOsAccountObjId, long destinationOsAccountObjId) {
accountsMerged.add(new TskEvent.MergedAccountsPair(sourceOsAccountObjId, destinationOsAccountObjId));
}
/**
* Saves an analysis result that has been deleted as a part of this
* transaction.
......@@ -13854,6 +13865,9 @@ public void commit() throws TskCoreException {
if (!accountsChanged.isEmpty()) {
sleuthkitCase.fireTSKEvent(new TskEvent.OsAccountsUpdatedTskEvent(accountsChanged));
}
if (!accountsMerged.isEmpty()) {
sleuthkitCase.fireTSKEvent(new TskEvent.OsAccountsMergedTskEvent(accountsMerged));
}
if (!deletedOsAccountObjectIds.isEmpty()) {
sleuthkitCase.fireTSKEvent(new TskEvent.OsAccountsDeletedTskEvent(deletedOsAccountObjectIds));
}
......
......@@ -306,6 +306,63 @@ public List<Long> getOsAccountObjectIds() {
}
/**
* An event published when one or more OS accounts are merged.
*/
public final static class OsAccountsMergedTskEvent extends TskObjectsEvent<MergedAccountsPair> {
/**
* Constructs an event published when one or more OS accounts are
* merged.
*
* @param mergedAccounts List of the merged OS accounts.
*/
OsAccountsMergedTskEvent(List<MergedAccountsPair> mergedAccounts) {
super(mergedAccounts);
}
/**
* Gets the pairs of merged accounts
*
* @return
*/
public List<MergedAccountsPair> getMergedAccountPairs() {
return getDataModelObjects();
}
}
/**
* Container to encapsulate the merged account ids, contains both the source and destination account ids.
*/
public final static class MergedAccountsPair {
private final Long sourceOsAccountId;
private final Long destinationOsAccountId;
public MergedAccountsPair(Long sourceOsAccountId, Long destinationOsAccountId) {
this.sourceOsAccountId = sourceOsAccountId;
this.destinationOsAccountId = destinationOsAccountId;
}
/**
* Gets the source os account id. This is the account that was marked as "MERGED"
* @return The TSK object ID of the source os account
*/
public Long getSourceOsAccountId() {
return sourceOsAccountId;
}
/**
* Gets the destination os account id. This is the account that the source was merged into.
* @return The TSK object ID of the destination os account
*/
public Long getDestinationOsAccountId() {
return destinationOsAccountId;
}
}
/**
* An event published when one or more OS account instances are added.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment