use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class SessionStructure method getRootNode.
/**
* Returns the root node
*
* @param model the model
* @return the root node
*/
public static StructuralNode getRootNode(Model model) {
if (!Constant.isLowMemoryOptionSet()) {
return new StructuralSiteNode(model.getSession().getSiteTree().getRoot());
}
Session session = model.getSession();
RecordStructure rs;
try {
rs = model.getDb().getTableStructure().find(session.getSessionId(), ROOT, HttpRequestHeader.GET);
if (rs != null) {
return new StructuralTableNode(rs);
}
} catch (DatabaseException e) {
log.error(e.getMessage(), e);
}
return null;
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class SessionStructure method addStructure.
private static RecordStructure addStructure(Model model, String host, HttpMessage msg, List<String> paths, int size, int historyId, boolean newOnly) throws DatabaseException, URIException {
// String nodeUrl = pathsToUrl(host, paths, size);
Session session = model.getSession();
String nodeName = getNodeName(session, host, msg, paths, size);
String parentName = pathsToUrl(host, paths, size - 1);
String url = "";
if (msg != null) {
url = msg.getRequestHeader().getURI().toString();
String params = getParams(session, msg);
if (params.length() > 0) {
nodeName = nodeName + " " + params;
}
}
String method = HttpRequestHeader.GET;
if (msg != null) {
method = msg.getRequestHeader().getMethod();
}
RecordStructure msgRs = model.getDb().getTableStructure().find(session.getSessionId(), nodeName, method);
if (msgRs == null) {
long parentId = -1;
if (!nodeName.equals(ROOT)) {
HttpMessage tmpMsg = null;
int parentHistoryId = -1;
if (!parentName.equals(ROOT)) {
tmpMsg = getTempHttpMessage(session, parentName, msg);
parentHistoryId = tmpMsg.getHistoryRef().getHistoryId();
}
RecordStructure parentRs = addStructure(model, host, tmpMsg, paths, size - 1, parentHistoryId, false);
parentId = parentRs.getStructureId();
}
msgRs = model.getDb().getTableStructure().insert(session.getSessionId(), parentId, historyId, nodeName, url, method);
} else if (newOnly) {
// Already exists
return null;
}
return msgRs;
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class SessionStructure method addPath.
/**
* Adds the message to the Sites tree
*
* @param model the model
* @param ref the history reference
* @param msg the message
* @param newOnly Only return a SiteNode if one was newly created
* @return the SiteNode that corresponds to the HttpMessage, or null if newOnly and the node
* already exists
* @since 2.10.0
*/
public static StructuralNode addPath(Model model, HistoryReference ref, HttpMessage msg, boolean newOnly) {
Session session = model.getSession();
if (!Constant.isLowMemoryOptionSet()) {
SiteNode node = session.getSiteTree().addPath(ref, msg, newOnly);
if (node != null) {
return new StructuralSiteNode(node);
}
return null;
} else {
try {
List<String> paths = getTreePath(model, msg);
String host = getHostName(msg.getRequestHeader().getURI());
RecordStructure rs = addStructure(model, host, msg, paths, paths.size(), ref.getHistoryId(), newOnly);
if (rs != null) {
return new StructuralTableNode(rs);
} else {
return null;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
return null;
}
}
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class PopupUserMenuItemHolder method resetMenu.
private void resetMenu() {
final List<JMenuItem> mainPopupMenuItems = View.getSingleton().getPopupList();
// Remove existing popup menu items
if (visibleItself)
this.removeAll();
else {
for (ExtensionPopupMenuItem menu : getSubmenuItems()) {
mainPopupMenuItems.remove(menu);
}
subMenuItems.clear();
}
// Add a popup menu item for each existing users
Session session = Model.getSingleton().getSession();
List<Context> contexts = session.getContexts();
for (Context context : contexts) {
ContextUserAuthManager manager = extensionUserAuth.getContextUserAuthManager(context.getId());
for (User user : manager.getUsers()) {
ExtensionPopupMenuItem piicm;
if (visibleItself) {
piicm = getPopupUserMenu(context, user, this.getText());
this.add(piicm);
} else {
piicm = getPopupUserMenu(context, user, this.parentName);
piicm.setMenuIndex(this.getMenuIndex());
mainPopupMenuItems.add(piicm);
subMenuItems.add(piicm);
}
}
}
}
use of org.parosproxy.paros.model.Session 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
}
}
Aggregations