use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class ExtensionSpider method startScanNode.
/**
* Start the scan of an URL (Node) from the POV of a User.
*
* @param node the node
*/
public void startScanNode(SiteNode node, User user) {
Target target = new Target(node);
target.setRecurse(true);
this.startScan(target, user, null);
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class NodeSelectDialog method populateContexts.
private void populateContexts(SiteNode root) {
// Uncomment to hide contexts tree if there are no valid contexts -
// not sure if this is a good idea or not :/
// int contexts = 0;
int contextsInScope = 0;
for (Context ctx : Model.getSingleton().getSession().getContexts()) {
// TODO ignore handle protected mode?
if (ctx.getIncludeInContextRegexs().size() > 0) {
SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, ctx.getName());
node.setUserObject(new Target(ctx));
root.add(node);
// contexts ++;
if (ctx.isInScope()) {
contextsInScope++;
}
}
}
if (contextsInScope > 1) {
// Allow user to choose everything in scope
SiteNode node = new SiteNode(null, HistoryReference.TYPE_PROXIED, Constant.messages.getString("context.allInScope"));
node.setUserObject(new Target(null, null, true, true));
root.add(node);
}
// this.getTreeContext().setVisible(contexts > 0);
this.getTreeContext().expandRow(0);
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class ContextsTreeCellRenderer method getTreeCellRendererComponent.
/**
* Sets custom tree node logos.
*/
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
SiteNode node = null;
Target target = null;
if (value instanceof SiteNode) {
node = (SiteNode) value;
if (node.getUserObject() instanceof Target) {
target = (Target) node.getUserObject();
}
}
if (node != null) {
if (node.isRoot()) {
setIcon(DisplayUtils.getScaledIcon(ROOT_ICON));
} else if (target != null) {
if (target.getContext() != null) {
if (target.getContext().isInScope()) {
setIcon(DisplayUtils.getScaledIcon(CONTEXT_IN_SCOPE_ICON));
} else {
setIcon(DisplayUtils.getScaledIcon(CONTEXT_ICON));
}
} else if (target.isInScopeOnly()) {
setIcon(DisplayUtils.getScaledIcon(ALL_IN_SCOPE_ICON));
}
}
}
return this;
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class ExtensionAlert method publishAlertEvent.
private void publishAlertEvent(Alert alert, String event) {
HistoryReference historyReference = hrefs.get(alert.getSourceHistoryId());
if (historyReference == null) {
historyReference = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class).getHistoryReference(alert.getSourceHistoryId());
}
Map<String, String> map = new HashMap<>();
map.put(AlertEventPublisher.ALERT_ID, Integer.toString(alert.getAlertId()));
map.put(AlertEventPublisher.HISTORY_REFERENCE_ID, Integer.toString(alert.getSourceHistoryId()));
map.put(AlertEventPublisher.NAME, alert.getName());
map.put(AlertEventPublisher.URI, alert.getUri().toString());
map.put(AlertEventPublisher.PARAM, alert.getParam());
map.put(AlertEventPublisher.RISK, Integer.toString(alert.getRisk()));
map.put(AlertEventPublisher.RISK_STRING, Alert.MSG_RISK[alert.getRisk()]);
map.put(AlertEventPublisher.CONFIDENCE, Integer.toString(alert.getConfidence()));
map.put(AlertEventPublisher.CONFIDENCE_STRING, Alert.MSG_CONFIDENCE[alert.getConfidence()]);
map.put(AlertEventPublisher.SOURCE, Integer.toString(alert.getSource().getId()));
ZAP.getEventBus().publishSyncEvent(AlertEventPublisher.getPublisher(), new Event(AlertEventPublisher.getPublisher(), event, new Target(historyReference.getSiteNode()), map));
}
use of org.zaproxy.zap.model.Target in project zaproxy by zaproxy.
the class StandardFieldsDialog method addTargetSelectField.
/*
* Add a 'node select' field which provides a button for showing a Node Select Dialog and a
* non editable field for showing the node selected
*/
public void addTargetSelectField(int tabIndex, final String fieldLabel, final Target value, final boolean editable, final boolean allowRoot) {
validateTabbed(tabIndex);
final ZapTextField text = new ZapTextField();
text.setEditable(editable);
this.setTextTarget(text, value);
JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
selectButton.setIcon(// Globe icon
new ImageIcon(View.class.getResource("/resource/icon/16/094.png")));
selectButton.addActionListener(new java.awt.event.ActionListener() {
// Keep a local copy so that we can always select the last node chosen
Target target = value;
@Override
public void actionPerformed(java.awt.event.ActionEvent e) {
NodeSelectDialog nsd = new NodeSelectDialog(StandardFieldsDialog.this);
nsd.setAllowRoot(allowRoot);
target = nsd.showDialog(target);
setTextTarget(text, target);
targetSelected(fieldLabel, target);
}
});
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
panel.add(text, LayoutHelper.getGBC(0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
panel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4)));
this.addField(this.tabPanels.get(tabIndex), this.tabOffsets.get(tabIndex), fieldLabel, text, panel, 0.0D);
this.incTabOffset(tabIndex);
}
Aggregations