Skip to content

Commit

Permalink
Merge pull request zaproxy#2344 from kingthorin/wapp-able
Browse files Browse the repository at this point in the history
wappalyzer: Add Enable/Disable Toggle
  • Loading branch information
thc202 authored Mar 26, 2020
2 parents c285279 + 3a818ea commit 1defd39
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 54 deletions.
3 changes: 3 additions & 0 deletions addOns/wappalyzer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Changed
- Update minimum ZAP version to 2.9.0.

### Added
- The Wappalyzer toolbar now has a toggle button to allow users to enable/disable the passive scanner simply from the GUI (Issue 5846).

## [17] - 2020-03-06

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void init() {
passiveScanner = new WappalyzerPassiveScanner(this);
}

WappalyzerPassiveScanner getPassiveScanner() {
return passiveScanner;
}

@Override
public void hook(ExtensionHook extensionHook) {
super.hook(extensionHook);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@

import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.Toolkit;
import java.awt.event.ItemEvent;
import java.awt.event.KeyEvent;
import javax.swing.Box;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
Expand All @@ -43,6 +47,7 @@
import org.parosproxy.paros.view.View;
import org.zaproxy.zap.utils.SortedComboBoxModel;
import org.zaproxy.zap.utils.TableExportButton;
import org.zaproxy.zap.view.ZapToggleButton;

public class TechPanel extends AbstractPanel {

Expand All @@ -63,6 +68,7 @@ public class TechPanel extends AbstractPanel {
private TechTableModel techModel = new TechTableModel();

private TableExportButton<JXTable> exportButton = null;
private ZapToggleButton enableButton = null;

private static final Icon TRANSPARENT_ICON =
new Icon() {
Expand Down Expand Up @@ -147,57 +153,20 @@ private javax.swing.JToolBar getPanelToolbar() {
if (panelToolbar == null) {

panelToolbar = new javax.swing.JToolBar();
panelToolbar.setLayout(new java.awt.GridBagLayout());
panelToolbar.setEnabled(true);
panelToolbar.setFloatable(false);
panelToolbar.setRollover(true);
panelToolbar.setPreferredSize(new java.awt.Dimension(800, 30));
panelToolbar.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12));
panelToolbar.setName("WappTechToolbar");

GridBagConstraints gridBagConstraints0 = new GridBagConstraints();
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
GridBagConstraints gridBagConstraintsx = new GridBagConstraints();

gridBagConstraints0.gridx = 0;
gridBagConstraints0.gridy = 0;
gridBagConstraints0.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraints0.anchor = java.awt.GridBagConstraints.WEST;

gridBagConstraints1.gridx = 1;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;

gridBagConstraints2.gridx = 2;
gridBagConstraints2.gridy = 0;
gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST;

gridBagConstraints3.gridx = 3;
gridBagConstraints3.gridy = 0;
gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST;

gridBagConstraintsx.gridx = 3;
gridBagConstraintsx.gridy = 0;
gridBagConstraintsx.weightx = 1.0;
gridBagConstraintsx.weighty = 1.0;
gridBagConstraintsx.insets = new java.awt.Insets(0, 0, 0, 0);
gridBagConstraintsx.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraintsx.fill = java.awt.GridBagConstraints.HORIZONTAL;

JLabel t1 = new JLabel();

panelToolbar.add(
new JLabel(Constant.messages.getString("wappalyzer.toolbar.site.label")),
gridBagConstraints1);
panelToolbar.add(getSiteSelect(), gridBagConstraints2);
panelToolbar.add(getExportButton(), gridBagConstraints3);
new JLabel(Constant.messages.getString("wappalyzer.toolbar.site.label")));
panelToolbar.add(getSiteSelect());
panelToolbar.add(getExportButton());
panelToolbar.add(getEnableToggleButton());

panelToolbar.add(t1, gridBagConstraintsx);
panelToolbar.add(Box.createHorizontalGlue());
}
return panelToolbar;
}
Expand Down Expand Up @@ -270,6 +239,7 @@ private JComboBox<String> getSiteSelect() {
if (siteSelect == null) {
siteSelect = new JComboBox<>(siteModel);
siteSelect.addItem(Constant.messages.getString("params.toolbar.site.select"));
siteSelect.setPreferredSize(new Dimension(250, 22));
siteSelect.setSelectedIndex(0);

siteSelect.addActionListener(
Expand Down Expand Up @@ -343,4 +313,40 @@ private TableExportButton<JXTable> getExportButton() {
}
return exportButton;
}

private ZapToggleButton getEnableToggleButton() {
if (enableButton == null) {
enableButton =
new ZapToggleButton(
Constant.messages.getString("wappalyzer.toolbar.toggle.state.enabled"),
true);
enableButton.setIcon(
new ImageIcon(
TechPanel.class.getResource(
ExtensionWappalyzer.RESOURCE + "/off.png")));
enableButton.setToolTipText(
Constant.messages.getString(
"wappalyzer.toolbar.toggle.state.disabled.tooltip"));
enableButton.setSelectedIcon(
new ImageIcon(
TechPanel.class.getResource(ExtensionWappalyzer.RESOURCE + "/on.png")));
enableButton.setSelectedToolTipText(
Constant.messages.getString("wappalyzer.toolbar.toggle.state.enabled.tooltip"));
enableButton.addItemListener(
event -> {
if (event.getStateChange() == ItemEvent.SELECTED) {
enableButton.setText(
Constant.messages.getString(
"wappalyzer.toolbar.toggle.state.enabled"));
extension.getPassiveScanner().setEnabled(true);
} else {
enableButton.setText(
Constant.messages.getString(
"wappalyzer.toolbar.toggle.state.disabled"));
extension.getPassiveScanner().setEnabled(false);
}
});
}
return enableButton;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import net.htmlparser.jericho.Source;
import org.apache.log4j.Logger;
import org.parosproxy.paros.Constant;
import org.parosproxy.paros.core.scanner.Plugin.AlertThreshold;
import org.parosproxy.paros.model.HistoryReference;
import org.parosproxy.paros.model.SiteNode;
import org.parosproxy.paros.network.HttpMessage;
Expand All @@ -43,6 +42,7 @@ public class WappalyzerPassiveScanner implements PassiveScanner {
private Set<String> visitedSiteIdentifiers = new HashSet<>();
private ApplicationMatch appMatch;
private Application currentApp;
private volatile boolean enabled = true;

public WappalyzerPassiveScanner(WappalyzerApplicationHolder applicationHolder) {
super();
Expand Down Expand Up @@ -206,20 +206,12 @@ public void setParent(PassiveScanThread parent) {

@Override
public boolean isEnabled() {
return true;
return enabled;
}

@Override
public void setEnabled(boolean enabled) {
// Does not apply.
}

public AlertThreshold getAlertThreshold() {
return AlertThreshold.MEDIUM;
}

public void setAlertThresholdl(AlertThreshold level) {
// Does not apply.
this.enabled = enabled;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ <H2>The Technology Tab</H2>
the menu will not be displayed.
<p>
Beside the site selection drop down is an Export button which can be used to export a CSV (comma separated values) file based on the
table information currently being displayed.
table information currently being displayed. There is also a toggle button which allows users to easily Enable/Disable the Wappalyzer
passive scanner.

<H2>External Links</H2>
<table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ wappalyzer.table.header.website = Website

wappalyzer.toolbar.site.label = Site:
wappalyzer.toolbar.site.select = -- Select Site --
wappalyzer.toolbar.toggle.state.enabled=Enabled
wappalyzer.toolbar.toggle.state.enabled.tooltip=Click to Disable Wappalyzer
wappalyzer.toolbar.toggle.state.disabled=Disabled
wappalyzer.toolbar.toggle.state.disabled.tooltip=Click to Enable Wappalyzer

wappalyzer.category.cms = CMS
wappalyzer.category.message-boards = Message-boards
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1defd39

Please sign in to comment.