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);
   }
 }

Members

(inner) avgCookieFieldsPerNeighbor

Average number of HTTP/S cookies per in-neighbor

(inner) avgCookieFieldsPerRq

Average number of HTTP/S cookies per request

(inner) avgPathLength

Average HTTP/S path length

(inner) avgQpPerNeighbor

Average number of query parameters per in-neighbor

(inner) avgQpPerReq

Average number of query parameters per HTTP/S request

(inner) avgReqPerNeighbor

Average HTTP/S requests per in-neighbors

(inner) avgRespHPerNeighbor

Average number of HTTP/S response headers per in-neighbor

(inner) avgRespHPerRq

Average number of HTTP/S response headers per request

(inner) avgRhPerNeighbor

Average number of HTTP/S request headers per in-neighbor

(inner) avgRhPerRq

Average number of HTTP/S request headers per request

(inner) avgSubdomainLength

Average length of subdomain NOTE: dots are included in the length

(inner) avgUrlLength

Average URL length

(inner) cookiesSet

Number of cookies set per in-neighbor

(inner) count

HTTP/S request count

(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.

(inner) maxSubdomainDepth

Maximum subdomain depth

(inner, constant) requestMethods :Array

Array of all possible request methods. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods for more details.

Type:
  • Array
Default Value
  • [ "GET", "POST", "OPTIONS", "HEAD", "PUT", "DELETE", "SEARCH", "PATCH" ]

(inner, constant) requestTypes :Array

Array of all possible request types. See https://developer.chrome.com/docs/extensions/reference/webRequest/#type-ResourceType for more details.

Type:
  • Array
Default Value
  • [ "xmlhttprequest", "image", "font", "script", "stylesheet", "ping", "sub_frame", "other", "main_frame", "csp_report", "object", "media" ]

(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.

Type:
  • function

(inner) thirdPartyCookie

Ratio between third-party-cookies and all cookies

(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.

(inner, constant) values :Object

A helper object to treat the generation process of request types and methods differently as the extraction differs.

Type:
  • Object

(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.

(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.

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.

Parameters:
NameTypeDescription
xNumber

The accumulator value of the reduce operation.

yNumber

The value of a specific edge attribute of an edge.

Returns:

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().

Parameters:
NameTypeDescription
rObject

An HTTP/S request retrieved from the webRequest interface. See webRequest.onBeforeRequest() for more details.

accNumber

In case the edge is created 0 will be passed as acc. In case the edge already exists, the current value of the edge attribute is passed as acc (i.e., the result of the previous extract() call).

Returns:

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.

Parameters:
NameTypeDescription
valueObject

A child property of Features#values

Returns:

Object

(inner) set(feature, attrs) → {Number}

set() is called for each node, when finally computing the node attributes based on the accumulated edge attributes.

Parameters:
NameTypeDescription
featureString

The name of the feature.

attrsObject

The accumulated edge attributes including the indegree of the node.

Returns:

The final value for feature.

Type: 
Number