Skip to content
This repository was archived by the owner on May 28, 2026. It is now read-only.

Taint API

Patrick Spiegel edited this page Dec 3, 2018 · 1 revision

The prototypes of string and buffer objects implement a set of functions in order to access the underlying taint information.

String.prototype.taint([String tag])

  • Returns a tainted copy of the string given an optional tag to be stored along with the taint.
const x = 'foo';
const y = x.taint();
x.getTaint(); 
> [ ]
y.getTaint();
> [ { begin: 0, end: 3, flow: [ [Object] ] } ]

String.prototype.isTainted()

  • Returns a boolean value indicating if any part of the string is tainted or not.
const x = 'foo'.taint();
x.isTainted();
> true

String.prototype.getTaint()

  • Returns the taint information of a given string as an array of taint ranges.
const x = 'foo'.taint();
x.getTaint();
> [ { begin: 0, end: 3, flow: [ [Object] ] } ]

String.prototype.untaint()

  • Returns a copy of a given string without any taint information attached.
const x = 'foo'.taint();
const y = x.untaint();
x.getTaint();
> [ { begin: 0, end: 3, flow: [ [Object] ] } ]
y.getTaint();
> [ ]

process.taintVersion()

  • Returns the version of the current taint implementation.
process.taintVersion()
> "v0.2.0"

Clone this wiki locally