mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
GP-4008 Auto Version Tracking - added related association accepted check before accepting match
This commit is contained in:
parent
9c6eabfbb3
commit
5f0fe93e89
1 changed files with 59 additions and 1 deletions
|
@ -592,6 +592,15 @@ public class AutoVersionTrackingTask extends Task {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasAcceptedRelatedAssociation(association, monitor)) {
|
||||||
|
Msg.warn(AutoVersionTrackingTask.class,
|
||||||
|
"This association has a related association with an accepted match so cannot " +
|
||||||
|
"make this association accepted which would try to block the already accepted " +
|
||||||
|
"related association " +
|
||||||
|
association);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!tryToSetAccepted(association)) {
|
if (!tryToSetAccepted(association)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -635,6 +644,44 @@ public class AutoVersionTrackingTask extends Task {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to test whether any related associations (ie associations with either the same source
|
||||||
|
* or the same destination address) have already been accepted
|
||||||
|
* @param association the given association (src/dest match pair)
|
||||||
|
* @param taskMonitor the task monitor
|
||||||
|
* @return true if any related associations have already been accepted, false otherwise
|
||||||
|
* @throws CancelledException if cancelled
|
||||||
|
*/
|
||||||
|
private boolean hasAcceptedRelatedAssociation(VTAssociation association,
|
||||||
|
TaskMonitor taskMonitor) throws CancelledException {
|
||||||
|
|
||||||
|
VTAssociationManager vtAssocManager = session.getAssociationManager();
|
||||||
|
|
||||||
|
Set<VTAssociation> relatedAssociations =
|
||||||
|
new HashSet<VTAssociation>(
|
||||||
|
vtAssocManager.getRelatedAssociationsBySourceAndDestinationAddress(
|
||||||
|
association.getSourceAddress(), association.getDestinationAddress()));
|
||||||
|
|
||||||
|
for (VTAssociation relatedAssociation : relatedAssociations) {
|
||||||
|
|
||||||
|
taskMonitor.checkCancelled();
|
||||||
|
|
||||||
|
//skip self
|
||||||
|
if (relatedAssociation.equals(association)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
VTAssociationStatus status = relatedAssociation.getStatus();
|
||||||
|
|
||||||
|
if (status.equals(VTAssociationStatus.ACCEPTED)) {
|
||||||
|
Msg.debug(this, relatedAssociation.toString() + " is already accepted match.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to accept matches and apply markup for duplicate function instruction matches with
|
* Method to accept matches and apply markup for duplicate function instruction matches with
|
||||||
* matching operands if they are a unique match within their associated subset. To explain in
|
* matching operands if they are a unique match within their associated subset. To explain in
|
||||||
|
@ -1237,14 +1284,25 @@ public class AutoVersionTrackingTask extends Task {
|
||||||
* @param match The match to try and accept and apply markup to
|
* @param match The match to try and accept and apply markup to
|
||||||
* @param monitor Allow user to cancel
|
* @param monitor Allow user to cancel
|
||||||
* @return true if there are any markup errors, false if no markup errors
|
* @return true if there are any markup errors, false if no markup errors
|
||||||
|
* @throws CancelledException if cancelled
|
||||||
*/
|
*/
|
||||||
private boolean tryToAcceptMatchAndApplyMarkup(VTMatch match, TaskMonitor monitor) {
|
private boolean tryToAcceptMatchAndApplyMarkup(VTMatch match, TaskMonitor monitor)
|
||||||
|
throws CancelledException {
|
||||||
|
|
||||||
VTAssociation association = match.getAssociation();
|
VTAssociation association = match.getAssociation();
|
||||||
|
|
||||||
// skip already accepted or blocked matches
|
// skip already accepted or blocked matches
|
||||||
if (association.getStatus() == VTAssociationStatus.AVAILABLE) {
|
if (association.getStatus() == VTAssociationStatus.AVAILABLE) {
|
||||||
|
|
||||||
|
if (hasAcceptedRelatedAssociation(association, monitor)) {
|
||||||
|
Msg.warn(AutoVersionTrackingTask.class,
|
||||||
|
"This association has a related association with an accepted match so cannot " +
|
||||||
|
"make this association accepted which would try to block the already accepted " +
|
||||||
|
"related association " +
|
||||||
|
association);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Try to accept the match
|
// Try to accept the match
|
||||||
if (tryToSetAccepted(association)) {
|
if (tryToSetAccepted(association)) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue