CtrlB
Search
⌃K

Data Redaction

Our agent lets you define custom data redaction functions. Use them when you don't want sensitive data from your application getting captured in developer's frontend.
In the following example, there is a simple flask server with /auth endpoint defined on line 24. It defines a sensitive variable called secret at line 25 which you do not want to be captured in tracepoints. Also let's say you do not want any dynamic log messages in this function.
1
def tracepointRedactFunc(vals):
2
if "auth.py" in vals["file_name"] or "auth" in vals["method_name"]:
3
for var in vals["frames"][0].variables.variables:
4
if var.name=="secret":
5
var.value = "XXXXXXXXX"
6
​
7
def logRedactFunc(vals):
8
if "auth.py" in vals["file_name"] or "auth" in vals["method_name"]:
9
vals["log_expression"] = "REDACTED!!"
10
​
11
import heimdall
12
heimdall.start(
13
tracepoint_data_redaction_callback=tracepointRedactFunc,
14
log_data_redaction_callback=logRedactFunc,
15
apikey="{COMPANY API KEY}"
16
)
17
​
18
import requests
19
from flask import Flask
20
​
21
app = Flask(__name__)
22
​
23
@app.route("/auth")
24
def auth():
25
secret="SENSITIVE DATA"
26
return f"The secret is: {secret}"
You can specify the configuration parameters tracepoint_data_redaction_callback and log_data_redaction_callback while starting heimdall, which define the custom callback functions. Argument vals contains the variables file_name and method_name which can be used to trace where is this data coming from. Data can be redacted as shown in above example.