Skip to content

Commit

Permalink
automation: let job report alert tests support
Browse files Browse the repository at this point in the history
Allow the job itself to tell if it supports or not alert tests to
remove direct dependencies to jobs in implementations.

Part of zaproxy/zaproxy#7959.

Signed-off-by: thc202 <[email protected]>
  • Loading branch information
thc202 committed Jul 25, 2024
1 parent e8fb7cb commit dfe2fc2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ public void logTestsToProgress(AutomationProgress progress) {
tests.forEach(t -> t.logToProgress(progress));
}

public boolean supportsAlertTests() {
return false;
}

public boolean supportsMonitorTests() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.parosproxy.paros.view.View;
import org.zaproxy.addon.automation.AutomationEventPublisher;
import org.zaproxy.addon.automation.AutomationJob;
import org.zaproxy.addon.automation.jobs.ActiveScanJob;
import org.zaproxy.addon.automation.jobs.PassiveScanWaitJob;
import org.zaproxy.addon.automation.tests.AbstractAutomationTest;
import org.zaproxy.addon.automation.tests.AutomationAlertTest;
import org.zaproxy.addon.automation.tests.AutomationMonitorTest;
Expand Down Expand Up @@ -60,7 +58,7 @@ public AddTestDialog(AutomationJob job) {
}
testNames.add(Constant.messages.getString(URL_PRESENCE_TEST_NAME));

if (job instanceof PassiveScanWaitJob || job instanceof ActiveScanJob) {
if (job.supportsAlertTests()) {
testNames.add(Constant.messages.getString(ALERT_TEST_NAME));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public ActiveScanJob() {
data = new Data(this, this.parameters, this.policyDefinition);
}

@Override
public boolean supportsAlertTests() {
return true;
}

private ExtensionActiveScan getExtAScan() {
if (extAScan == null) {
extAScan =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public PassiveScanWaitJob() {
this.data = new Data(this, parameters);
}

@Override
public boolean supportsAlertTests() {
return true;
}

@Override
public void runJob(AutomationEnvironment env, AutomationProgress progress) {
ExtensionPassiveScan extPScan = getExtPassiveScan();
Expand Down

0 comments on commit dfe2fc2

Please sign in to comment.