-
-
Notifications
You must be signed in to change notification settings - Fork 783
quickstart: Add Scan Policy option to Automated Scan panel #7300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
dd04522
7d31089
0d28a2e
bb06386
fb17451
cf77ea6
6790bb9
caf689e
bf90ec1
6df912b
dc27728
9dbc905
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ | |
| import org.parosproxy.paros.model.SiteNode; | ||
| import org.parosproxy.paros.view.View; | ||
| import org.zaproxy.zap.extension.alert.ExtensionAlert; | ||
| import org.zaproxy.zap.extension.ascan.ExtensionActiveScan; | ||
| import org.zaproxy.zap.extension.search.SearchPanel; | ||
| import org.zaproxy.zap.utils.DisplayUtils; | ||
| import org.zaproxy.zap.view.LayoutHelper; | ||
|
|
@@ -52,6 +53,7 @@ public class AttackPanel extends QuickStartSubPanel { | |
| private ImageIcon icon; | ||
| private JButton attackButton; | ||
| private JButton stopButton; | ||
| private JComboBox<String> policyField; | ||
| private JComboBox<String> urlField; | ||
| private DefaultComboBoxModel<String> urlModel; | ||
| private JButton selectButton; | ||
|
|
@@ -149,6 +151,11 @@ public JPanel getContentPanel() { | |
| urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 0.5D)); | ||
| urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D)); | ||
| contentPanel.add(urlSelectPanel, LayoutHelper.getGBC(2, formPanelY, 3, 0.25D)); | ||
| contentPanel.add( | ||
| new JLabel(Constant.messages.getString("quickstart.label.policy")), | ||
| LayoutHelper.getGBC( | ||
| 1, ++formPanelY, 1, 0.0D, DisplayUtils.getScaledInsets(5, 5, 5, 5))); | ||
| contentPanel.add(getPolicyField(), LayoutHelper.getGBC(2, formPanelY, 1, 0.25D)); | ||
|
|
||
| traditionalSpiderY = ++formPanelY; | ||
| plugableSpiderY = ++formPanelY; | ||
|
|
@@ -173,6 +180,41 @@ public JPanel getContentPanel() { | |
| return contentPanel; | ||
| } | ||
|
|
||
| private JComboBox<String> getPolicyField() { | ||
| if (policyField == null) { | ||
| policyField = new JComboBox<>(); | ||
| ExtensionActiveScan extAscan = | ||
| Control.getSingleton() | ||
| .getExtensionLoader() | ||
| .getExtension(ExtensionActiveScan.class); | ||
| if (extAscan != null) { | ||
| String savedPolicy = | ||
| getExtensionQuickStart().getQuickStartParam().getScanPolicyName(); | ||
| String defaultPolicy = null; | ||
| for (String name : extAscan.getPolicyManager().getAllPolicyNames()) { | ||
| policyField.addItem(name); | ||
| if ("Dev Standard".equals(name)) { | ||
| defaultPolicy = name; | ||
| } | ||
| } | ||
|
thc202 marked this conversation as resolved.
Outdated
|
||
| if (savedPolicy != null && !savedPolicy.isEmpty()) { | ||
|
thc202 marked this conversation as resolved.
Outdated
|
||
| policyField.setSelectedItem(savedPolicy); | ||
| } else if (defaultPolicy != null) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preferable to inline in the if than declare variables upfront that might not be even used. |
||
| policyField.setSelectedItem(defaultPolicy); | ||
| } | ||
| } | ||
| } | ||
| return policyField; | ||
| } | ||
|
|
||
| public String getSelectedPolicy() { | ||
| if (policyField == null) { | ||
| return null; | ||
| } | ||
| Object selected = policyField.getSelectedItem(); | ||
| return selected != null ? selected.toString() : null; | ||
|
kingthorin marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private JLabel getProgressLabel() { | ||
| if (progressLabel == null) { | ||
| progressLabel = | ||
|
|
@@ -402,6 +444,7 @@ boolean attackUrl() { | |
| return false; | ||
| } | ||
| this.getExtensionQuickStart().getQuickStartParam().addRecentUrl(urlStr); | ||
| this.getExtensionQuickStart().getQuickStartParam().setScanPolicyName(getSelectedPolicy()); | ||
| getAttackButton().setEnabled(false); | ||
| getStopButton().setEnabled(true); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,6 +319,7 @@ public void attack(URL url, boolean useStdSpider) { | |
| attackThread.setURL(url); | ||
| attackThread.setTraditionalSpider(traditionalSpider); | ||
| attackThread.setPlugableSpider(plugableSpider); | ||
| attackThread.setScanPolicyName(getQuickStartPanel().getAttackPanel().getSelectedPolicy()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will break in headless mode, see |
||
| attackThread.start(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,12 @@ <H3>URL to attack</H3> | |
| This is because https://example.com/test/ is treated as a leaf node internally, which would mean that ZAP would not attack | ||
| URLs like https://example.com/test/1 etc. | ||
|
|
||
| <H3>Scan Policy</H3> | ||
|
|
||
| The scan policy to use when performing the active scan. | ||
|
thc202 marked this conversation as resolved.
|
||
| The last chosen policy will be used by default. | ||
| <br><br> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is still outstanding |
||
|
|
||
| <H3>Use traditional spider</H3> | ||
|
|
||
| The traditional spider explores the application by finding links in HTML pages. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.