コード例 #1
0
  /** Execution of the start ZAP job. */
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    // Signal that the ZAP start action is starting.
    Job signalZAPStartJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Start...", ZAPEventType.SERVER_STARTED, eventHandler);
    signalZAPStartJob.setPriority(Job.INTERACTIVE);
    signalZAPStartJob.schedule();

    // Run the start ZAP job.
    Job startZAPJob = new StartZAPJob("Running ZAP Start Job...");
    startZAPJob.setPriority(Job.LONG);
    startZAPJob.schedule();
    while (startZAPJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    // Signal that the ZAp start action is complete.
    Job signalZAPStartCompleteJob =
        new SignalZAPEventJob(
            display, "ZAP Start Complete", ZAPEventType.SERVER_STARTUP_COMPLETE, eventHandler);
    signalZAPStartCompleteJob.setPriority(Job.INTERACTIVE);
    signalZAPStartCompleteJob.schedule();

    return Status.OK_STATUS;
  }
コード例 #2
0
 public boolean isEnabled() {
   try {
     Expression enablementExpression = getEnablementExpression();
     if (enablementExpression == null) {
       return true;
     }
     EvaluationContext context = new EvaluationContext(null, this);
     EvaluationResult evaluationResult = enablementExpression.evaluate(context);
     return evaluationResult != EvaluationResult.FALSE;
   } catch (CoreException e) {
     ConsolePlugin.log(e);
     return false;
   }
 }
コード例 #3
0
ファイル: MysqlConsoleFactory.java プロジェクト: rraaff/wtf
  private static void basicOpenConsole() {
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window != null) {
      IWorkbenchPage page = window.getActivePage();
      if (page != null) {
        try {
          IConsole myConsole = findConsole(SQLPLUS_CONSOLE_VIEW);
          String id = IConsoleConstants.ID_CONSOLE_VIEW;
          IConsoleView view = (IConsoleView) page.showView(id);
          view.display(myConsole);

        } catch (PartInitException e) {
          ConsolePlugin.log(e);
        }
      }
    }
  }
コード例 #4
0
  /** Execution of the run ZAP scan job. */
  @Override
  protected IStatus run(IProgressMonitor monitor) {

    ScanProgress scanProgress = new ScanProgress();

    // Make sure that all of the necessary scan parameters have been
    // entered.
    if (StringUtils.isBlank(target.getTargetUrl())
        || StringUtils.isBlank(target.getFileName())
        || StringUtils.isBlank(target.getReportFormat())) {
      CreatePopupMessageJob incompleteParamsWarningJob =
          new CreatePopupMessageJob(
              MessageDialog.WARNING,
              "The Scan Target URL, Scan Result File, and Report Format fields are required to run a scan.");
      incompleteParamsWarningJob.setPriority(Job.INTERACTIVE);
      incompleteParamsWarningJob.schedule();
      return Status.CANCEL_STATUS;
    }

    // Give the user a warning if the scan will overwrite an existing scan
    // file.
    try {
      if (ZAPScanHelper.scanFilesExist(target.getFileName())) {
        CreatePopupMessageJob fileOverwriteWarning =
            new CreatePopupMessageJob(
                MessageDialog.CONFIRM,
                "The specified Scan Result File matches an existing scan file in the ZAPScanResults folder.  Executing the scan may overwrite existing scan results data.  Do you wish to proceed?");
        fileOverwriteWarning.setPriority(Job.INTERACTIVE);
        fileOverwriteWarning.schedule();
        while (fileOverwriteWarning.getResult() == null) {
          try {
            Thread.sleep(100);
          } catch (InterruptedException e) {
            ConsolePlugin.log(e);
          }
        }

        if (fileOverwriteWarning.getResult() == Status.CANCEL_STATUS) {
          return Status.CANCEL_STATUS;
        }
      }
    } catch (CoreException e1) {
      ConsolePlugin.log(e1);
    }

    // Signal that the spider has started.
    Job signalZAPSpiderJob =
        new SignalZAPEventJob(
            display,
            "Signal ZAP Spider Started...",
            ZAPEventType.SCAN_SPIDER_STARTED,
            eventHandler);
    signalZAPSpiderJob.setPriority(Job.INTERACTIVE);
    signalZAPSpiderJob.schedule();

    // Set the attack levels.
    Job attackLevelJob =
        new ZAPSetZAPLevelsJob("Setting ZAP Attack Levels..", target.getZapPolicyList());
    attackLevelJob.setPriority(LONG);
    attackLevelJob.schedule();

    // Perform a spider of the target URL.
    spiderJob =
        new ZAPSpiderJob(
            "Running Zed Attack Proxy Spider...",
            target,
            display,
            scanProgress,
            eventHandler,
            scanStatus);
    spiderJob.setPriority(LONG);
    spiderJob.schedule();
    while (spiderJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    if (scanStatus.isScanCancelled()) {
      return Status.CANCEL_STATUS;
    }

    // Signal that the spider has started.
    Job signalZAPAscanJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Ascan Started...", ZAPEventType.SCAN_ASCAN_STARTED, eventHandler);
    signalZAPAscanJob.setPriority(Job.INTERACTIVE);
    signalZAPAscanJob.schedule();

    // Perform an ascan on the target URL.
    ascanJob =
        new ZAPAscanJob(
            "Running Zed Attack Proxy Ascan...",
            target,
            display,
            scanProgress,
            eventHandler,
            scanStatus);
    ascanJob.setPriority(LONG);
    ascanJob.schedule();
    while (ascanJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    if (scanStatus.isScanCancelled()) {
      return Status.CANCEL_STATUS;
    }

    // Clear out scan data after run is complete.
    Job clearZapJob = new ClearZAPJob("Clearing Zed Attack Proxy Run Data...");
    clearZapJob.setPriority(LONG);
    clearZapJob.schedule();
    while (clearZapJob.getResult() == null) {
      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        ConsolePlugin.log(e);
      }
    }

    // Signal that the scan is complete.
    Job signalZAPScanCompleteJob =
        new SignalZAPEventJob(
            display, "Signal ZAP Scan Complete", ZAPEventType.SCAN_COMPLETE, eventHandler);
    signalZAPScanCompleteJob.setPriority(Job.INTERACTIVE);
    signalZAPScanCompleteJob.schedule();

    return Status.OK_STATUS;
  }