use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class ExtensionAlert method alertFound.
public void alertFound(Alert alert, HistoryReference ref) {
try {
logger.debug("alertFound " + alert.getName() + " " + alert.getUri());
if (ref == null) {
ref = alert.getHistoryRef();
}
if (ref == null) {
ref = new HistoryReference(getModel().getSession(), HistoryReference.TYPE_SCANNER, alert.getMessage());
alert.setHistoryRef(ref);
}
if (alert.getSource() == Alert.Source.UNKNOWN) {
alert.setSource(Alert.Source.TOOL);
}
alert.setSourceHistoryId(ref.getHistoryId());
hrefs.put(Integer.valueOf(ref.getHistoryId()), ref);
this.applyOverrides(alert);
writeAlertToDB(alert, ref);
try {
if (getView() == null || EventQueue.isDispatchThread()) {
SessionStructure.addPath(Model.getSingleton().getSession(), ref, alert.getMessage());
} else {
final HistoryReference fRef = ref;
final HttpMessage fMsg = alert.getMessage();
EventQueue.invokeAndWait(new Runnable() {
@Override
public void run() {
SessionStructure.addPath(Model.getSingleton().getSession(), fRef, fMsg);
}
});
}
ref.addAlert(alert);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
addAlertToTree(alert);
// Clear the message so that it can be GC'ed
alert.setMessage(null);
publishAlertEvent(alert, AlertEventPublisher.ALERT_ADDED_EVENT);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class SessionStructure method getTempHttpMessage.
private static HttpMessage getTempHttpMessage(Session session, String url, HttpMessage base) {
try {
HttpMessage newMsg = base.cloneRequest();
URI uri = new URI(url, false);
newMsg.getRequestHeader().setURI(uri);
newMsg.getRequestHeader().setMethod(HttpRequestHeader.GET);
newMsg.getRequestBody().setBody("");
newMsg.getRequestHeader().setHeader(HttpHeader.CONTENT_TYPE, null);
newMsg.getRequestHeader().setHeader(HttpHeader.CONTENT_LENGTH, null);
HistoryReference historyRef = new HistoryReference(session, HistoryReference.TYPE_TEMPORARY, newMsg);
newMsg.setHistoryRef(historyRef);
return newMsg;
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return null;
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class AuthenticationHelper method addAuthMessageToHistory.
public static void addAuthMessageToHistory(HttpMessage msg) {
// Add message to history
try {
final HistoryReference ref = new HistoryReference(Model.getSingleton().getSession(), HistoryReference.TYPE_AUTHENTICATION, msg);
ref.addTag(HISTORY_TAG_AUTHENTICATION);
if (View.isInitialised()) {
final ExtensionHistory extHistory = Control.getSingleton().getExtensionLoader().getExtension(ExtensionHistory.class);
if (extHistory != null) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
extHistory.addHistory(ref);
}
});
}
}
} catch (Exception ex) {
log.error("Cannot add authentication message to History tab.", ex);
}
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class SearchResultsTable method getSelectedHistoryReferences.
@Override
public List<HistoryReference> getSelectedHistoryReferences() {
final int[] selectedRows = getSelectedRows();
if (selectedRows.length == 0) {
return Collections.emptyList();
}
ArrayList<HistoryReference> uniqueHistoryReferences = new ArrayList<>(selectedRows.length);
SortedSet<Integer> historyReferenceIdsAdded = new TreeSet<>();
for (int selectedRow : selectedRows) {
HistoryReference historyReference = getHistoryReferenceAtViewRow(selectedRow);
if (historyReference != null) {
Integer id = Integer.valueOf(historyReference.getHistoryId());
if (!historyReferenceIdsAdded.contains(id)) {
historyReferenceIdsAdded.add(id);
uniqueHistoryReferences.add(historyReference);
}
}
}
uniqueHistoryReferences.trimToSize();
return uniqueHistoryReferences;
}
use of org.parosproxy.paros.model.HistoryReference in project zaproxy by zaproxy.
the class SearchResultsTableModel method createSearchResultTableEntry.
private static SearchResultTableEntry createSearchResultTableEntry(SearchResult sr, SearchResultTableEntry previousResult) {
HistoryReference hRef = sr.getMessage().getHistoryRef();
Integer historyId = null;
String uri = null;
String stringFound = null;
if (previousResult != null) {
Integer previousId = previousResult.getHistoryId();
if (previousId.intValue() == hRef.getHistoryId()) {
historyId = previousId;
}
if (previousResult.getStringFound().equals(sr.getStringFound())) {
stringFound = previousResult.getStringFound();
}
uri = sr.getMessage().getRequestHeader().getURI().toString();
if (previousResult.getUri().equals(uri)) {
uri = previousResult.getUri();
}
}
if (historyId == null) {
historyId = Integer.valueOf(hRef.getHistoryId());
}
if (stringFound == null) {
stringFound = sr.getStringFound();
}
if (uri == null) {
uri = sr.getMessage().getRequestHeader().getURI().toString();
}
return new SearchResultTableEntry(hRef, historyId, hRef.getMethod(), uri, stringFound, sr);
}
Aggregations