use of org.zaproxy.zap.control.AddOn.AddOnRunRequirements in project zaproxy by zaproxy.
the class AddOnLoader method addAddOnImpl.
private void addAddOnImpl(AddOn ao) {
if (AddOn.InstallationStatus.INSTALLED == ao.getInstallationStatus()) {
return;
}
if (this.blockList.contains(ao.getId())) {
// Explicitly being added back, so remove from the block list
this.blockList.remove(ao.getId());
this.saveBlockList();
}
if (!isDynamicallyInstallable(ao)) {
return;
}
AddOnRunRequirements reqs = calculateRunRequirements(ao, aoc.getInstalledAddOns());
if (!reqs.isRunnable()) {
ao.setInstallationStatus(AddOn.InstallationStatus.NOT_INSTALLED);
return;
}
AddOnInstaller.install(createAndAddAddOnClassLoader(ao), ao);
ao.setInstallationStatus(AddOn.InstallationStatus.INSTALLED);
Control.getSingleton().getExtensionLoader().addOnInstalled(ao);
if (runnableAddOns.get(ao) == null) {
runnableAddOns.put(ao, getRunnableExtensionsWithDeps(reqs));
saveAddOnsRunState(runnableAddOns);
}
checkAndLoadDependentExtensions();
checkAndInstallAddOnsNotInstalled();
if (View.isInitialised()) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
View.getSingleton().refreshTabViewMenus();
}
});
}
}
use of org.zaproxy.zap.control.AddOn.AddOnRunRequirements in project zaproxy by zaproxy.
the class AddOnLoader method loadAllAddOns.
private void loadAllAddOns() {
runnableAddOns = new HashMap<>();
idsAddOnsWithRunningIssuesSinceLastRun = new ArrayList<>();
Map<AddOn, List<String>> oldRunnableAddOns = loadAddOnsRunState(aoc);
List<AddOn> runAddons = new ArrayList<>();
for (Iterator<AddOn> iterator = aoc.getAddOns().iterator(); iterator.hasNext(); ) {
AddOn addOn = iterator.next();
if (canLoadAddOn(addOn)) {
AddOnRunRequirements reqs = calculateRunRequirements(addOn, aoc.getAddOns());
if (reqs.isRunnable()) {
List<String> runnableExtensions;
if (addOn.hasExtensionsWithDeps()) {
runnableExtensions = getRunnableExtensionsWithDeps(reqs);
List<String> oldRunnableExtensions = oldRunnableAddOns.get(addOn);
if (oldRunnableExtensions != null && !oldRunnableExtensions.isEmpty()) {
oldRunnableExtensions.removeAll(runnableExtensions);
if (!oldRunnableExtensions.isEmpty()) {
idsAddOnsWithRunningIssuesSinceLastRun.add(addOn.getId());
}
}
} else {
runnableExtensions = Collections.emptyList();
}
runnableAddOns.put(addOn, runnableExtensions);
runAddons.add(addOn);
} else if (oldRunnableAddOns.get(addOn) != null) {
idsAddOnsWithRunningIssuesSinceLastRun.add(addOn.getId());
}
} else {
iterator.remove();
}
}
saveAddOnsRunState(runnableAddOns);
for (AddOn addOn : runAddons) {
addOn.setInstallationStatus(AddOn.InstallationStatus.INSTALLED);
createAndAddAddOnClassLoader(addOn);
}
}
use of org.zaproxy.zap.control.AddOn.AddOnRunRequirements in project zaproxy by zaproxy.
the class InstalledAddOnsTableModel method refreshUpdateIssues.
private boolean refreshUpdateIssues(AddOnWrapper aow) {
AddOnRunRequirements reqs = aow.getAddOnUpdate().calculateRunRequirements(availableAddOns.getAddOns());
String issues = getAddOnRunningIssues(reqs);
aow.setUpdateIssues(issues, !reqs.hasExtensionsWithRunningIssues());
return !issues.isEmpty();
}
use of org.zaproxy.zap.control.AddOn.AddOnRunRequirements in project zaproxy by zaproxy.
the class AddOnsTableModel method refreshRunningIssues.
protected boolean refreshRunningIssues(AddOnWrapper aow, int row) {
AddOnRunRequirements reqs = aow.getAddOn().calculateRunRequirements(addOnCollection.getAddOns());
String issues = getAddOnRunningIssues(reqs);
aow.setRunningIssues(issues, !reqs.hasExtensionsWithRunningIssues());
return !issues.isEmpty();
}
use of org.zaproxy.zap.control.AddOn.AddOnRunRequirements in project zaproxy by zaproxy.
the class ExtensionAutoUpdate method installLocalAddOn.
private void installLocalAddOn(Path file) throws Exception {
if (!AddOn.isAddOn(file)) {
showWarningMessageInvalidAddOnFile();
return;
}
AddOn ao;
try {
ao = new AddOn(file);
} catch (Exception e) {
showWarningMessageInvalidAddOnFile();
return;
}
if (!ao.canLoadInCurrentVersion()) {
showWarningMessageCantLoadAddOn(ao);
return;
}
AddOnDependencyChecker dependencyChecker = new AddOnDependencyChecker(getLocalVersionInfo(), latestVersionInfo == null ? getLocalVersionInfo() : latestVersionInfo);
boolean update = false;
AddOnChangesResult result;
AddOn installedAddOn = getLocalVersionInfo().getAddOn(ao.getId());
if (installedAddOn != null) {
if (!ao.isUpdateTo(installedAddOn)) {
View.getSingleton().showWarningDialog(MessageFormat.format(Constant.messages.getString("cfu.warn.addOnOlderVersion"), installedAddOn.getFileVersion(), View.getSingleton().getStatusUI(installedAddOn.getStatus()).toString(), ao.getFileVersion(), View.getSingleton().getStatusUI(ao.getStatus()).toString()));
return;
}
result = dependencyChecker.calculateUpdateChanges(ao);
update = true;
} else {
result = dependencyChecker.calculateInstallChanges(ao);
}
if (result.getOldVersions().isEmpty() && result.getUninstalls().isEmpty()) {
AddOnRunRequirements reqs = ao.calculateRunRequirements(getLocalVersionInfo().getAddOns());
if (!reqs.isRunnable()) {
if (!AddOnRunIssuesUtils.askConfirmationAddOnNotRunnable(Constant.messages.getString("cfu.warn.addOnNotRunnable.message"), Constant.messages.getString("cfu.warn.addOnNotRunnable.question"), getLocalVersionInfo(), ao)) {
return;
}
}
installLocalAddOn(ao);
return;
}
if (update) {
if (!dependencyChecker.confirmUpdateChanges(getView().getMainFrame(), result)) {
return;
}
// The new version of the add-on is installed manually
result.getNewVersions().remove(ao);
} else {
if (!dependencyChecker.confirmInstallChanges(getView().getMainFrame(), result)) {
return;
}
// The add-on is installed manually
result.getInstalls().remove(ao);
}
processAddOnChanges(getView().getMainFrame(), result);
installLocalAddOn(ao);
}
Aggregations