Skip to content

Commit 309fbb8

Browse files
authored
Merge pull request #23 from silinternational/feature-filtersenstives
Filter sensitive values from Sentry events
2 parents 5c0131a + d39f2c2 commit 309fbb8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

application/backup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,26 @@ log() {
77
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${level}: ${message}";
88
}
99

10+
# Function to remove sensitive values from sentry Event
11+
filter_sensitive_values() {
12+
local msg="$1"
13+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
14+
val="${!var}"
15+
if [ -n "$val" ]; then
16+
msg="${msg//$val/[FILTERED]}"
17+
fi
18+
done
19+
echo "$msg"
20+
}
21+
1022
# Sentry reporting with validation and backwards compatibility
1123
error_to_sentry() {
1224
local error_message="$1";
1325
local db_name="$2";
1426
local status_code="$3";
1527

28+
error_message=$(filter_sensitive_values "$error_message")
29+
1630
# Check if SENTRY_DSN is configured - ensures backup continues
1731
if [ -z "${SENTRY_DSN:-}" ]; then
1832
log "DEBUG" "Sentry logging skipped - SENTRY_DSN not configured";

application/restore.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ log() {
77
echo "[$(date '+%Y-%m-%d %H:%M:%S')] ${level}: ${message}"
88
}
99

10+
filter_sensitive_values() {
11+
local msg="$1"
12+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID DB_ROOTPASSWORD DB_USERPASSWORD; do
13+
val="${!var}"
14+
if [ -n "$val" ]; then
15+
msg="${msg//$val/[FILTERED]}"
16+
fi
17+
done
18+
echo "$msg"
19+
}
20+
1021
# Sentry reporting with validation and backwards compatibility
1122
error_to_sentry() {
1223
local error_message="$1"
1324
local db_name="$2"
1425
local status_code="$3"
1526

27+
error_message=$(filter_sensitive_values "$error_message")
28+
1629
# Check if SENTRY_DSN is configured - ensures restore continues
1730
if [ -z "${SENTRY_DSN:-}" ]; then
1831
log "DEBUG" "Sentry logging skipped - SENTRY_DSN not configured"

0 commit comments

Comments
 (0)