use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class HttpBreakpointsUiManagerInterface method showAddDialog.
private void showAddDialog(Message aMessage) {
HttpBreakpointMessage.Match match = HttpBreakpointMessage.Match.regex;
HttpMessage msg = (HttpMessage) aMessage;
String regex = "";
if (msg.getHistoryRef() != null && msg.getHistoryRef().getSiteNode() != null) {
try {
regex = new StructuralSiteNode(msg.getHistoryRef().getSiteNode()).getRegexPattern(false);
} catch (DatabaseException e) {
// Ignore
}
}
if (regex.length() == 0 && msg.getRequestHeader().getURI() != null) {
// Just use the escaped url
regex = msg.getRequestHeader().getURI().toString();
match = HttpBreakpointMessage.Match.contains;
}
this.showAddDialog(regex, match);
}
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;
}
use of org.zaproxy.zap.model.StructuralSiteNode in project zaproxy by zaproxy.
the class PopupExcludeFromSpiderMenu method performAction.
@Override
public void performAction(SiteNode sn) {
try {
Session session = Model.getSingleton().getSession();
session.getExcludeFromSpiderRegexs().add(new StructuralSiteNode(sn).getRegexPattern());
} catch (DatabaseException e) {
// Ignore
}
}
Aggregations