use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class SessionExcludeFromSpiderPanel method initParam.
@Override
public void initParam(Object obj) {
Session session = (Session) obj;
regexesPanel.setRegexes(session.getExcludeFromSpiderRegexs());
regexesPanel.setRemoveWithoutConfirmation(!Model.getSingleton().getOptionsParam().getViewParam().isConfirmRemoveSpiderExcludeRegex());
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class HttpPanelSender method persistAndShowMessage.
private void persistAndShowMessage(HttpMessage httpMessage) {
if (!EventQueue.isDispatchThread()) {
EventQueue.invokeLater(() -> persistAndShowMessage(httpMessage));
return;
}
try {
Session session = Model.getSingleton().getSession();
HistoryReference ref = new HistoryReference(session, HistoryReference.TYPE_ZAP_USER, httpMessage);
final ExtensionHistory extHistory = getHistoryExtension();
if (extHistory != null) {
extHistory.addHistory(ref);
}
SessionStructure.addPath(Model.getSingleton(), ref, httpMessage);
} catch (HttpMalformedHeaderException | DatabaseException e) {
logger.warn("Failed to persist message sent:", e);
}
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class PopupMenuHistoryReference method isEnableForComponent.
@Override
public boolean isEnableForComponent(Component invoker) {
boolean display = false;
if (invoker.getName() == null) {
return false;
}
if (invoker.getName().equals("History Table")) {
this.lastInvoker = Invoker.history;
this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker instanceof JTree && invoker.getName().equals("treeSite")) {
this.lastInvoker = Invoker.sites;
this.treeInvoker = (JTree) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker.getName().equals("treeAlert")) {
this.lastInvoker = Invoker.alerts;
this.treeInvoker = (JTree) invoker;
JTree tree = (JTree) invoker;
if (tree.getLastSelectedPathComponent() != null) {
if (tree.getSelectionCount() > 1) {
// Note - the Alerts tree only supports single selections
this.setEnabled(false);
} else {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
if (!node.isRoot() && node.getUserObject() != null) {
this.setEnabled(isEnabledForHistoryReference(getSelectedHistoryReferences().get(0)));
} else {
this.setEnabled(false);
}
}
}
display = true;
} else if (invoker.getName().equals(SearchPanel.HTTP_MESSAGE_CONTAINER_NAME)) {
this.lastInvoker = Invoker.search;
this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker.getName().equals(ActiveScanPanel.MESSAGE_CONTAINER_NAME)) {
this.lastInvoker = Invoker.ascan;
this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker.getName().equals("HttpFuzzerResultsContentPanel")) {
this.lastInvoker = Invoker.fuzz;
this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker.getName().equals("ForcedBrowseMessageContainer")) {
this.lastInvoker = Invoker.bruteforce;
this.hrefsTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else if (invoker instanceof HistoryReferencesTable) {
this.lastInvoker = Invoker.hreftable;
this.hrefTableInvoker = (HistoryReferencesTable) invoker;
this.setEnabled(isEnabledForHistoryReferences(getSelectedHistoryReferences()));
display = true;
} else {
// Only enable this while testing
/*
log.debug("Popup " + this.getName() +
" not enabled for panel " + invoker.getName() +
" class " + invoker.getClass().getName());
*/
}
if (display) {
if (this.isEnabled() && !this.isSafe() && Control.getSingleton().getMode().equals(Mode.protect)) {
boolean inScope = true;
Session session = Model.getSingleton().getSession();
for (HistoryReference href : getSelectedHistoryReferences()) {
if (!session.isInScope(href)) {
inScope = false;
break;
}
}
if (!inScope) {
// Not safe and not in scope while in protected mode
this.setEnabled(false);
}
}
return this.isEnableForInvoker(lastInvoker);
}
return false;
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class SessionStructure method getNodeName.
private static String getNodeName(long sessionId, URI uri, String method, String postData) throws URIException {
Session session = Model.getSingleton().getSession();
List<String> paths = session.getTreePath(uri);
String host = getHostName(uri);
String nodeUrl = pathsToUrl(host, paths, paths.size());
if (postData != null) {
String params = getParams(session, uri, postData);
if (params.length() > 0) {
nodeUrl = nodeUrl + " " + params;
}
}
return nodeUrl;
}
use of org.parosproxy.paros.model.Session in project zaproxy by zaproxy.
the class Control method newSession.
public Session newSession() throws Exception {
log.info("New Session");
closeSessionAndCreateAndOpenUntitledDb();
final Session session = createNewSession();
getExtensionLoader().databaseOpen(model.getDb());
getExtensionLoader().sessionChangedAllPlugin(session);
if (hasView()) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
view.getSiteTreePanel().getTreeSite().setModel(session.getSiteTree());
view.getSiteTreePanel().reloadContextTree();
}
});
// refresh display
view.getOutputPanel().clear();
}
try {
model.getDb().getTableSession().insert(session.getSessionId(), session.getSessionName());
} catch (DatabaseException e) {
log.error(e.getMessage(), e);
}
return session;
}
Aggregations