A module to implement functions to extract features from the stream of HTTP/S requests and responses. This module returns an object containing all features that are extracted in Wdg.addEdge()
. A feature itself is an object consisting of three properties: extract
, accumulate
(optional), and set
. NOTE: The key of this object will be used as the name of the feature. Its properties have to implement functions, which are called at different stages in the graph generation process. See below an example for a feature object:
tracking: {
'extract': (r, acc) => {
let isTracking = r.labels
.reduce((acc, val) =>
acc || val.isLabeled,
false
);
return Util.count(isTracking, acc);
},
'set': (feature, attrs) => {
return Util.ratio(attrs[feature], attrs.count);
}
}
- Source
Members
(inner) avgCookieFieldsPerNeighbor
Average number of HTTP/S cookies per in-neighbor
- Source
(inner) avgCookieFieldsPerRq
Average number of HTTP/S cookies per request
- Source
(inner) avgPathLength
Average HTTP/S path length
- Source
(inner) avgQpPerNeighbor
Average number of query parameters per in-neighbor
- Source
(inner) avgQpPerReq
Average number of query parameters per HTTP/S request
- Source
(inner) avgReqPerNeighbor
Average HTTP/S requests per in-neighbors
- Source
(inner) avgRespHPerNeighbor
Average number of HTTP/S response headers per in-neighbor
- Source
(inner) avgRespHPerRq
Average number of HTTP/S response headers per request
- Source
(inner) avgRhPerNeighbor
Average number of HTTP/S request headers per in-neighbor
- Source
(inner) avgRhPerRq
Average number of HTTP/S request headers per request
- Source
(inner) avgSubdomainLength
Average length of subdomain NOTE: dots are included in the length
- Source
(inner) avgUrlLength
Average URL length
- Source
(inner) cookiesSet
Number of cookies set per in-neighbor
- Source
(inner) count
HTTP/S request count
- Source
(inner) firstPartyDisclosed
First-party is contained in HTTP/S request NOTE: Currently, we only check if the Referer or Origin header is set. The URL can be contained in the query string or even path (URL- or Base64 encoded). For each node the ratio between requests in which the first-party had been contained and all incoming requests is calculated.
- Source
(inner) maxSubdomainDepth
Maximum subdomain depth
- Source
(inner, constant) requestMethods :Array
Array of all possible request methods. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods for more details.
- Array
- Default Value
- [ "GET", "POST", "OPTIONS", "HEAD", "PUT", "DELETE", "SEARCH", "PATCH" ]
- Source
(inner, constant) requestTypes :Array
Array of all possible request types. See https://developer.chrome.com/docs/extensions/reference/webRequest/#type-ResourceType for more details.
- Array
- Default Value
- [ "xmlhttprequest", "image", "font", "script", "stylesheet", "ping", "sub_frame", "other", "main_frame", "csp_report", "object", "media" ]
- Source
(inner, constant) stringComparison :function
A function that checks strict equality of two strings. Instantly returns false in case one or both string are undefined, null, or empty.
- function
- Source
(inner) thirdPartyCookie
Ratio between third-party-cookies and all cookies
- Source
(inner) tracking
Tracking requests count NOTE: HTTP/S requests are matched against filter lists (e.g., EasyList & EasyPrivacy) If one rule matches, the request is labeled as tracking request.
For each node the ratio between tracking requests and all incoming requests (count) is calculated.
- Source
(inner, constant) values :Object
A helper object to treat the generation process of request types and methods differently as the extraction differs.
- Object
- Source
(inner) {requestMethod}
For each Features.requestMethods
we compute the total number of requests with that specific request method and divide it by the total number of requests to that node.
- Source
(inner) {requestType}
For each Features.requestTypes
we compute the total number of requests with that specific type and divide it by the total number of requests to that node.
- Source
Methods
(inner) accumulate(x, y) → {Number}
accumulate()
is called for each node, when reducing the edge attributes of each in-neighbor in Wdg.attributes(). The property is optional. In case it is undefined
, the sum will be computed for each edge attribute.
Name | Type | Description |
---|---|---|
x | Number | The accumulator value of the reduce operation. |
y | Number | The value of a specific edge attribute of an edge. |
- Source
The new value of the edge attribute.
- Type:
- Number
(inner) extract(r, acc) → {Number}
extract()
is called for each HTTP/S request in Wdg.addEdge()
.
Name | Type | Description |
---|---|---|
r | Object | An HTTP/S request retrieved from the |
acc | Number | In case the edge is created 0 will be passed as |
- Source
The new value of the edge attribute.
- Type:
- Number
(inner) generate(value)
A function to generate feature objects. Used to generate the feature objects for each request type and method.
Name | Type | Description |
---|---|---|
value | Object | A child property of Features#values |
- Source
Object
(inner) set(feature, attrs) → {Number}
set()
is called for each node, when finally computing the node attributes based on the accumulated edge attributes.
Name | Type | Description |
---|---|---|
feature | String | The name of the feature. |
attrs | Object | The accumulated edge attributes including the indegree of the node. |
- Source
The final value for feature
.
- Type:
- Number