use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class PopupExcludeFromProxyMenu method performAction.
@Override
public void performAction(SiteNode sn) {
try {
Session session = Model.getSingleton().getSession();
session.getExcludeFromProxyRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
SiteMap map = (SiteMap) View.getSingleton().getSiteTreePanel().getTreeSite().getModel();
ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
if (extHistory != null) {
extHistory.purge(map, sn);
}
} catch (DatabaseException e) {
// Ignore
}
}
use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class PopupExcludeFromScanMenu method performAction.
@Override
public void performAction(SiteNode sn) {
try {
Session session = Model.getSingleton().getSession();
session.getExcludeFromScanRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
} catch (DatabaseException e) {
// Ignore
}
}
use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class ContextCreateDialog method save.
@Override
public void save() {
Context ctx = Model.getSingleton().getSession().getNewContext(this.getStringValue(NAME_FIELD));
ctx.setDescription(this.getStringValue(DESC_FIELD));
ctx.setInScope(this.getBoolValue(IN_SCOPE_FIELD));
if (topNode != null) {
try {
ctx.addIncludeInContextRegex(new StructuralSiteNode(topNode).getRegexPattern());
} catch (DatabaseException e) {
// Ignore
}
}
Model.getSingleton().getSession().saveContext(ctx);
}
use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class ExtensionActiveScan method startScan.
@Override
public int startScan(String name, Target target, User user, Object[] contextSpecificObjects) {
if (name == null) {
name = target.getDisplayName();
}
switch(Control.getSingleton().getMode()) {
case safe:
throw new InvalidParameterException("Scans are not allowed in Safe mode");
case protect:
List<StructuralNode> nodes = target.getStartNodes();
if (nodes != null) {
for (StructuralNode node : nodes) {
if (node instanceof StructuralSiteNode) {
SiteNode siteNode = ((StructuralSiteNode) node).getSiteNode();
if (!siteNode.isIncludedInScope()) {
throw new InvalidParameterException("Scans are not allowed on nodes not in scope Protected mode " + target.getStartNode().getHierarchicNodeName());
}
}
}
}
// No problem
break;
case standard:
// No problem
break;
case attack:
// No problem
break;
}
int id = this.ascanController.startScan(name, target, user, contextSpecificObjects);
if (hasView()) {
ActiveScan scanner = this.ascanController.getScan(id);
// So the UI get updated
scanner.addScannerListener(getActiveScanPanel());
this.getActiveScanPanel().scannerStarted(scanner);
this.getActiveScanPanel().switchView(scanner);
if (isPanelSwitch()) {
this.getActiveScanPanel().setTabFocus();
}
}
return id;
}
use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class SpiderDialog method validateFields.
@Override
public String validateFields() {
if (Control.Mode.safe == Control.getSingleton().getMode()) {
// The dialogue shouldn't be shown when in safe mode but if it is warn.
return Constant.messages.getString("spider.custom.notSafe.error");
}
if (this.isEmptyField(FIELD_START)) {
return Constant.messages.getString("spider.custom.nostart.error");
}
boolean noStartUri = true;
if (!getStringValue(FIELD_START).equals(getTargetText(target))) {
String url = this.getStringValue(FIELD_START);
try {
// Need both constructors as they catch slightly different issues ;)
new URI(url, true);
new URL(url);
} catch (Exception e) {
return Constant.messages.getString("spider.custom.nostart.error");
}
if (Control.getSingleton().getMode() == Control.Mode.protect) {
if (!extension.isTargetUriInScope(url)) {
return Constant.messages.getString("spider.custom.targetNotInScope.error", url);
}
}
noStartUri = false;
}
if (this.target != null) {
if (!this.target.isValid()) {
return Constant.messages.getString("spider.custom.nostart.error");
}
if (Control.getSingleton().getMode() == Control.Mode.protect) {
String uri = extension.getTargetUriOutOfScope(target);
if (uri != null) {
return Constant.messages.getString("spider.custom.targetNotInScope.error", uri);
}
}
List<StructuralNode> nodes = target.getStartNodes();
if (nodes != null) {
for (StructuralNode node : nodes) {
if (node instanceof StructuralSiteNode) {
noStartUri = false;
break;
}
}
}
}
if (getBoolValue(FIELD_SUBTREE_ONLY) && noStartUri) {
return Constant.messages.getString("spider.custom.noStartSubtreeOnly.error");
}
return null;
}
Aggregations