Class HistoryReference
- java.lang.Object
-
- org.parosproxy.paros.model.HistoryReference
-
public class HistoryReference extends java.lang.Object
This class abstracts a reference to a http message stored in database. It reads the whole http message from database when getHttpMessage() is called.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Set<java.lang.Integer>
DEFAULT_TEMPORARY_HISTORY_TYPES
TheSet
with default temporary history types:TYPE_TEMPORARY
;TYPE_SCANNER_TEMPORARY
;TYPE_AUTHENTICATION
;TYPE_SPIDER_TASK
;TYPE_SEQUENCE_TEMPORARY
;TYPE_SPIDER_AJAX_TEMPORARY
;TYPE_SPIDER_TEMPORARY
;TYPE_FUZZER_TEMPORARY
;static int
TYPE_ACCESS_CONTROL
static int
TYPE_AUTHENTICATION
A (temporary) HTTP message that (attempts to) authenticates aUser
.static int
TYPE_BRUTE_FORCE
static int
TYPE_CALLBACK
A HTTP message received by the callback handler.static int
TYPE_FUZZER
A HTTP message sent by the fuzzer.static int
TYPE_FUZZER_TEMPORARY
A (temporary) HTTP message sent by the fuzzer.static int
TYPE_HIDDEN
static int
TYPE_MANUAL
Deprecated.UseTYPE_PROXIED
instead.static int
TYPE_OAST
An HTTP message received by an OAST server that is relayed to ZAP.static int
TYPE_PARAM_DIGGER
An HTTP message sent by the param digger.static int
TYPE_PROXIED
A HTTP message that was proxied through ZAP.static int
TYPE_PROXY_CONNECT
A HTTP CONNECT request received (and processed) by the local proxy.static int
TYPE_SCANNER
static int
TYPE_SCANNER_TEMPORARY
A (temporary) HTTP message sent by the (active) scanner.static int
TYPE_SEQUENCE_TEMPORARY
A (temporary) HTTP message created/used when active scanning sequences.static int
TYPE_SPIDER
static int
TYPE_SPIDER_AJAX
A HTTP message sent by the AJAX Spider.static int
TYPE_SPIDER_AJAX_TEMPORARY
A (temporary) HTTP message of the AJAX spider.static int
TYPE_SPIDER_TASK
A (temporary) HTTP message of the spider.static int
TYPE_SPIDER_TEMPORARY
A (temporary) HTTP message of the spider.static int
TYPE_TEMPORARY
Temporary type = not retrieved from history.static int
TYPE_ZAP_USER
A HTTP message sent by the user from within ZAP, for example, using "Manual Request Editor" or "Resend" dialogues.static int
TYPE_ZEST_SCRIPT
A HTTP message sent by a Zest script.
-
Constructor Summary
Constructors Constructor Description HistoryReference(int historyId)
HistoryReference(int historyId, boolean keepMessage)
Constructs aHistoryReference
with the given ID and whether or not theHttpMessage
read from the database should be kept in memory.HistoryReference(Session session, int historyType, HttpMessage msg)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addAlert(Alert alert)
void
addTag(java.lang.String tag)
static void
addTemporaryType(int type)
Adds the giventype
to the set of temporary types.void
clearHttpMessage()
Clears theHttpMessage
kept in memory.void
delete()
Delete this HistoryReference from database This should typically only be called via the ExtensionHistory.delete(href) methodvoid
deleteAlert(Alert alert)
void
deleteAllAlerts()
void
deleteTag(java.lang.String tag)
java.util.List<Alert>
getAlerts()
Gets the alerts.java.util.ArrayList<java.lang.Boolean>
getClearIfManual()
java.util.ArrayList<java.lang.String>
getCustomIcons()
int
getHighestAlert()
int
getHistoryId()
int
getHistoryType()
HttpMessage
getHttpMessage()
Gets the corresponding http message from the database.java.lang.String
getMethod()
java.lang.String
getReason()
java.lang.String
getRequestBody()
int
getRequestBodyLength()
int
getRequestHeaderLength()
int
getResponseBodyLength()
int
getResponseHeaderLength()
int
getRtt()
long
getSessionId()
SiteNode
getSiteNode()
int
getStatusCode()
java.util.List<java.lang.String>
getTags()
static java.util.List<java.lang.String>
getTags(int historyId)
Gets the tags of the message with the given history ID.static java.util.Set<java.lang.Integer>
getTemporaryTypes()
Gets the temporary history types.long
getTimeReceivedMillis()
long
getTimeSentMillis()
org.apache.commons.httpclient.URI
getURI()
boolean
hasAlert(Alert alert)
Tells whether or not this history reference has the given alert.boolean
hasAlerts()
Tells whether or not this history reference has alerts.boolean
hasNote()
boolean
isWebSocketUpgrade()
void
loadAlerts()
static void
removeTemporaryType(int type)
Removes the giventype
from the set of temporary types.void
setCustomIcon(java.lang.String i, boolean c)
void
setNote(java.lang.String note)
void
setSiteNode(SiteNode siteNode)
static void
setTableAlert(TableAlert tableAlert)
static void
setTableHistory(TableHistory tableHistory)
static void
setTableTag(TableTag tableTag)
void
setTags(java.util.List<java.lang.String> tags)
Sets the tags for the HTTP message.void
setTags(java.util.Vector<java.lang.String> tags)
Deprecated.(2.7.0) UsesetTags(List)
instead.java.lang.String
toString()
void
updateAlert(Alert alert)
-
-
-
Field Detail
-
TYPE_TEMPORARY
public static final int TYPE_TEMPORARY
Temporary type = not retrieved from history. To be deleted.- See Also:
- Constant Field Values
-
TYPE_MANUAL
@Deprecated public static final int TYPE_MANUAL
Deprecated.UseTYPE_PROXIED
instead.- See Also:
TYPE_ZAP_USER
, Constant Field Values
-
TYPE_PROXIED
public static final int TYPE_PROXIED
A HTTP message that was proxied through ZAP.- See Also:
- Constant Field Values
-
TYPE_ZAP_USER
public static final int TYPE_ZAP_USER
A HTTP message sent by the user from within ZAP, for example, using "Manual Request Editor" or "Resend" dialogues.- See Also:
- Constant Field Values
-
TYPE_SPIDER
public static final int TYPE_SPIDER
- See Also:
- Constant Field Values
-
TYPE_SCANNER
public static final int TYPE_SCANNER
- See Also:
- Constant Field Values
-
TYPE_HIDDEN
public static final int TYPE_HIDDEN
- See Also:
- Constant Field Values
-
TYPE_BRUTE_FORCE
public static final int TYPE_BRUTE_FORCE
- See Also:
- Constant Field Values
-
TYPE_FUZZER
public static final int TYPE_FUZZER
A HTTP message sent by the fuzzer.Used for fuzzer messages that have an
Alert
, which outlive the fuzzing sessions.- Since:
- 1.4.0
- See Also:
TYPE_FUZZER_TEMPORARY
, Constant Field Values
-
TYPE_SPIDER_TASK
public static final int TYPE_SPIDER_TASK
A (temporary) HTTP message of the spider.The type is used to off-load the messages (of resources found but not yet fetched) from the memory.
- Since:
- 2.0.0
- See Also:
TYPE_SPIDER
,TYPE_SPIDER_TEMPORARY
,DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_SPIDER_AJAX
public static final int TYPE_SPIDER_AJAX
A HTTP message sent by the AJAX Spider.- Since:
- 2.0.0
- See Also:
TYPE_SPIDER_AJAX_TEMPORARY
, Constant Field Values
-
TYPE_AUTHENTICATION
public static final int TYPE_AUTHENTICATION
A (temporary) HTTP message that (attempts to) authenticates aUser
.- Since:
- 2.4.0
- See Also:
DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_ACCESS_CONTROL
public static final int TYPE_ACCESS_CONTROL
- See Also:
- Constant Field Values
-
TYPE_ZEST_SCRIPT
public static final int TYPE_ZEST_SCRIPT
A HTTP message sent by a Zest script.Not all HTTP messages sent by Zest scripts will have this type, some might use the type(s) of the underlying component (for example, Zest Active Rules will use the types of the active scanner,
TYPE_SCANNER_TEMPORARY
orTYPE_SCANNER
).- Since:
- 2.6.0
- See Also:
- Constant Field Values
-
TYPE_SCANNER_TEMPORARY
public static final int TYPE_SCANNER_TEMPORARY
A (temporary) HTTP message sent by the (active) scanner.- Since:
- 2.4.0
- See Also:
DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
DEFAULT_TEMPORARY_HISTORY_TYPES
public static final java.util.Set<java.lang.Integer> DEFAULT_TEMPORARY_HISTORY_TYPES
TheSet
with default temporary history types:TYPE_TEMPORARY
;TYPE_SCANNER_TEMPORARY
;TYPE_AUTHENTICATION
;TYPE_SPIDER_TASK
;TYPE_SEQUENCE_TEMPORARY
;TYPE_SPIDER_AJAX_TEMPORARY
;TYPE_SPIDER_TEMPORARY
;TYPE_FUZZER_TEMPORARY
;
Persisted messages with temporary types are deleted when the session is closed.
Note: This set does not allow modifications, any attempt to modify it will result in an
UnsupportedOperationException
.- Since:
- 2.5.0
- See Also:
getTemporaryTypes()
-
TYPE_PROXY_CONNECT
public static final int TYPE_PROXY_CONNECT
A HTTP CONNECT request received (and processed) by the local proxy.- Since:
- 2.5.0
- See Also:
- Constant Field Values
-
TYPE_SEQUENCE_TEMPORARY
public static final int TYPE_SEQUENCE_TEMPORARY
A (temporary) HTTP message created/used when active scanning sequences.- Since:
- 2.6.0
- See Also:
DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_SPIDER_AJAX_TEMPORARY
public static final int TYPE_SPIDER_AJAX_TEMPORARY
A (temporary) HTTP message of the AJAX spider.Normally a message that was not processed (i.e. not on spider scope).
- Since:
- 2.6.0
- See Also:
TYPE_SPIDER_AJAX
,DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_SPIDER_TEMPORARY
public static final int TYPE_SPIDER_TEMPORARY
A (temporary) HTTP message of the spider.Normally a message that was not processed (i.e. not successfully sent to the server).
- Since:
- 2.6.0
- See Also:
TYPE_SPIDER
,TYPE_SPIDER_TASK
,DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_FUZZER_TEMPORARY
public static final int TYPE_FUZZER_TEMPORARY
A (temporary) HTTP message sent by the fuzzer.- Since:
- 2.7.0
- See Also:
TYPE_FUZZER
,DEFAULT_TEMPORARY_HISTORY_TYPES
, Constant Field Values
-
TYPE_CALLBACK
public static final int TYPE_CALLBACK
A HTTP message received by the callback handler.- Since:
- 2.8.0
- See Also:
- Constant Field Values
-
TYPE_OAST
public static final int TYPE_OAST
An HTTP message received by an OAST server that is relayed to ZAP.- Since:
- 2.11.0
- See Also:
- Constant Field Values
-
TYPE_PARAM_DIGGER
public static final int TYPE_PARAM_DIGGER
An HTTP message sent by the param digger.- Since:
- 2.12.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HistoryReference
public HistoryReference(int historyId) throws HttpMalformedHeaderException, DatabaseException
-
HistoryReference
public HistoryReference(int historyId, boolean keepMessage) throws HttpMalformedHeaderException, DatabaseException
Constructs aHistoryReference
with the given ID and whether or not theHttpMessage
read from the database should be kept in memory.Note: This constructor should be used with care as the
HttpMessage
might be kept in memory (until this instance is garbage collected ormanually cleared
). It should be used only when the contents of theHttpMessage
are used immediately after creating theHistoryReference
, avoiding reading theHttpMessage
once again.- Parameters:
historyId
- the ID of the message persisted to databasekeepMessage
-true
if theHttpMessage
should be kept in memory,false
otherwise.- Throws:
HttpMalformedHeaderException
- if an error occurred while parsing the message.DatabaseException
- if an error occurred while reading the message.- Since:
- 2.7.0
- See Also:
getHttpMessage()
-
HistoryReference
public HistoryReference(Session session, int historyType, HttpMessage msg) throws HttpMalformedHeaderException, DatabaseException
-
-
Method Detail
-
getSessionId
public long getSessionId()
- Returns:
- Returns the sessionId.
-
getClearIfManual
public java.util.ArrayList<java.lang.Boolean> getClearIfManual()
- Returns:
- whether the icon has to be cleaned when being manually visited or not.
-
getCustomIcons
public java.util.ArrayList<java.lang.String> getCustomIcons()
- Returns:
- The icon's string path (i.e. /resource/icon/16/xx.png)
-
setCustomIcon
public void setCustomIcon(java.lang.String i, boolean c)
- Parameters:
i
- the icon's URL (i.e. /resource/icon/16/xx.png)c
- if the icon has to be cleaned when the node is manually visited
-
setTableHistory
public static void setTableHistory(TableHistory tableHistory)
-
setTableTag
public static void setTableTag(TableTag tableTag)
-
setTableAlert
public static void setTableAlert(TableAlert tableAlert)
-
getHistoryId
public int getHistoryId()
- Returns:
- Returns the historyId.
-
getHttpMessage
public HttpMessage getHttpMessage() throws HttpMalformedHeaderException, DatabaseException
Gets the corresponding http message from the database. Try to minimise calls to this method as much as possible. But also dont cache the HttpMessage either as this can significantly increase ZAP's memory usage.- Returns:
- the http message
- Throws:
HttpMalformedHeaderException
- the http malformed header exceptionDatabaseException
- if an error occurred while reading the HTTP message.
-
clearHttpMessage
public void clearHttpMessage()
Clears theHttpMessage
kept in memory.- Since:
- 2.7.0
- See Also:
HistoryReference(int, boolean)
-
getURI
public org.apache.commons.httpclient.URI getURI()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getHistoryType
public int getHistoryType()
- Returns:
- Returns the historyType.
-
delete
public void delete()
Delete this HistoryReference from database This should typically only be called via the ExtensionHistory.delete(href) method
-
getSiteNode
public SiteNode getSiteNode()
- Returns:
- Returns the siteNode.
-
setSiteNode
public void setSiteNode(SiteNode siteNode)
- Parameters:
siteNode
- The siteNode to set.
-
addTag
public void addTag(java.lang.String tag)
-
deleteTag
public void deleteTag(java.lang.String tag)
-
getTags
public java.util.List<java.lang.String> getTags()
-
setNote
public void setNote(java.lang.String note)
-
loadAlerts
public void loadAlerts()
-
addAlert
public boolean addAlert(Alert alert)
-
updateAlert
public void updateAlert(Alert alert)
-
deleteAlert
public void deleteAlert(Alert alert)
-
deleteAllAlerts
public void deleteAllAlerts()
-
hasAlert
public boolean hasAlert(Alert alert)
Tells whether or not this history reference has the given alert.- Parameters:
alert
- the alert to check- Returns:
true
if it has the given alert,false
otherwise.- Since:
- 2.6.0
- See Also:
hasAlerts()
,addAlert(Alert)
-
hasAlerts
public boolean hasAlerts()
Tells whether or not this history reference has alerts.- Returns:
true
if it has alerts,false
otherwise.- Since:
- 2.6.0
- See Also:
hasAlert(Alert)
,addAlert(Alert)
-
getHighestAlert
public int getHighestAlert()
-
getAlerts
public java.util.List<Alert> getAlerts()
Gets the alerts.If alerts where never added, an unmodifiable empty list is returned, otherwise it's returned a copy of the internal collection.
- Returns:
- the alerts
- See Also:
addAlert(Alert)
,hasAlerts()
,hasAlert(Alert)
-
getMethod
public java.lang.String getMethod()
-
getStatusCode
public int getStatusCode()
-
getReason
public java.lang.String getReason()
-
getRtt
public int getRtt()
-
setTags
public void setTags(java.util.List<java.lang.String> tags)
Sets the tags for the HTTP message.- Parameters:
tags
- the new tags.- Throws:
java.lang.IllegalArgumentException
- if the given parameter isnull
.- Since:
- 2.7.0
- See Also:
addTag(String)
,deleteTag(String)
-
setTags
@Deprecated public void setTags(java.util.Vector<java.lang.String> tags)
Deprecated.(2.7.0) UsesetTags(List)
instead.Sets the tags for the HTTP message.- Parameters:
tags
- the new tags.- Throws:
java.lang.IllegalArgumentException
- if the given parameter isnull
.
-
hasNote
public boolean hasNote()
-
getTimeSentMillis
public long getTimeSentMillis()
-
getTimeReceivedMillis
public long getTimeReceivedMillis()
-
isWebSocketUpgrade
public boolean isWebSocketUpgrade()
-
getRequestHeaderLength
public int getRequestHeaderLength()
-
getRequestBodyLength
public int getRequestBodyLength()
-
getResponseHeaderLength
public int getResponseHeaderLength()
-
getResponseBodyLength
public int getResponseBodyLength()
-
getRequestBody
public java.lang.String getRequestBody()
-
addTemporaryType
public static void addTemporaryType(int type)
Adds the giventype
to the set of temporary types.Persisted messages with temporary types are deleted when the session is closed.
- Parameters:
type
- the history type that will be added- Since:
- 2.5.0
- See Also:
removeTemporaryType(int)
,getTemporaryTypes()
-
removeTemporaryType
public static void removeTemporaryType(int type)
Removes the giventype
from the set of temporary types.Attempting to remove a default temporary type has no effect.
- Parameters:
type
- the history type that will be removed- Since:
- 2.5.0
- See Also:
DEFAULT_TEMPORARY_HISTORY_TYPES
,addTemporaryType(int)
,getTemporaryTypes()
-
getTemporaryTypes
public static java.util.Set<java.lang.Integer> getTemporaryTypes()
Gets the temporary history types.Persisted messages with temporary types are deleted when the session is closed.
- Returns:
- a
Set
with the temporary history types - See Also:
addTemporaryType(int)
,removeTemporaryType(int)
-
getTags
public static java.util.List<java.lang.String> getTags(int historyId) throws DatabaseException
Gets the tags of the message with the given history ID.- Parameters:
historyId
- the history ID.- Returns:
- a
List
with the tags of the message, nevernull
. - Throws:
DatabaseException
- if an error occurred while obtaining the tags from the database.- Since:
- 2.7.0
-
-