Skip to content

Commit 32eecee

Browse files
authored
Merge pull request #45 from silinternational/feature/filtersenstives
Filter sensitive values from Sentry events
2 parents e43dc47 + 8acbc1b commit 32eecee

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

application/backup.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,26 @@ function get_server_cert() {
4141
fi
4242
}
4343

44+
# Function to remove sensitive values from sentry Event
45+
filter_sensitive_values() {
46+
local msg="$1"
47+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID MYSQL_PASSWORD; do
48+
val="${!var}"
49+
if [ -n "$val" ]; then
50+
msg="${msg//$val/[FILTERED]}"
51+
fi
52+
done
53+
echo "$msg"
54+
}
55+
4456
# Sentry reporting with validation and backwards compatibility
4557
error_to_sentry() {
4658
local error_message="$1"
4759
local db_name="$2"
4860
local status_code="$3"
4961

62+
error_message=$(filter_sensitive_values "$error_message")
63+
5064
# Check if SENTRY_DSN is configured - ensures backup continues
5165
if [ -z "${SENTRY_DSN:-}" ]; then
5266
log "DEBUG" "Sentry logging skipped - SENTRY_DSN not configured"

application/restore.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,26 @@ function get_server_cert() {
1616
fi
1717
}
1818

19+
# Function to remove sensitive values from sentry Event
20+
filter_sensitive_values() {
21+
local msg="$1"
22+
for var in AWS_ACCESS_KEY AWS_SECRET_KEY B2_APPLICATION_KEY B2_APPLICATION_KEY_ID MYSQL_PASSWORD; do
23+
val="${!var}"
24+
if [ -n "$val" ]; then
25+
msg="${msg//$val/[FILTERED]}"
26+
fi
27+
done
28+
echo "$msg"
29+
}
30+
1931
# Sentry reporting with validation and backwards compatibility
2032
error_to_sentry() {
2133
local error_message="$1"
2234
local db_name="$2"
2335
local status_code="$3"
2436

37+
error_message=$(filter_sensitive_values "$error_message")
38+
2539
# Check if SENTRY_DSN is configured - ensures restore continues
2640
if [ -z "${SENTRY_DSN:-}" ]; then
2741
log "DEBUG" "Sentry logging skipped - SENTRY_DSN not configured"

0 commit comments

Comments
 (0)