-
Notifications
You must be signed in to change notification settings - Fork 86
feat: enhanced notification settings and translation cache fix #2503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8b44c8a
ab34d9b
1b4668f
624864b
1a381c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,6 +36,10 @@ | |
| case 'm': | ||
| $notify .= " -{$option} ".escapeshellarg($value); | ||
| break; | ||
| case 'u': | ||
| $notify .= " -{$option} ".escapeshellarg($value); | ||
| break; | ||
|
|
||
|
Comment on lines
+39
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check the notify script for validation of the -u parameter and safe_filename function
# Find the notify script
NOTIFY_SCRIPT="emhttp/plugins/dynamix/scripts/notify"
if [ -f "$NOTIFY_SCRIPT" ]; then
echo "=== Checking for -u option handling ==="
rg -A 10 -B 2 'u\)' "$NOTIFY_SCRIPT" | head -50
echo ""
echo "=== Checking for safe_filename function ==="
rg -A 20 'safe_filename|function.*filename' "$NOTIFY_SCRIPT"
echo ""
echo "=== Checking for filename validation patterns ==="
rg -C 3 'basename|realpath|sanitize|validate.*filename' "$NOTIFY_SCRIPT"
else
echo "Notify script not found at $NOTIFY_SCRIPT"
fiRepository: unraid/webgui Length of output: 3165 🏁 Script executed: #!/bin/bash
NOTIFY_SCRIPT="emhttp/plugins/dynamix/scripts/notify"
# Search for case statement handling options
echo "=== Searching for all case statement handling ==="
rg -B 5 -A 10 "case '-" "$NOTIFY_SCRIPT" | head -80
echo ""
echo "=== Full context around customFilename usage ==="
rg -B 10 -A 10 "customFilename" "$NOTIFY_SCRIPT"
echo ""
echo "=== Check if .notify extension is enforced for custom filenames ==="
rg -B 5 -A 5 '\.notify' "$NOTIFY_SCRIPT"Repository: unraid/webgui Length of output: 2637 Extend -u parameter validation to enforce .notify extension. The
However, there is a validation gap: the custom filename passed via the Add extension validation for custom filenames to either append or enforce the 🤖 Prompt for AI Agents |
||
| case 'x': | ||
| case 't': | ||
| $notify .= " -{$option}"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ notify [-e "event"] [-s "subject"] [-d "description"] [-i "normal|warning|alert" | |
| use -r to specify recipients and not use default | ||
| use -t to force send email only (for testing) | ||
| use -b to NOT send a browser notification | ||
| use -u to specify a custom filename (API use only) | ||
| all options are optional | ||
|
|
||
| notify init | ||
|
|
@@ -87,12 +88,13 @@ function generate_email($event, $subject, $description, $importance, $message, $ | |
| return mail($to, $subj, implode("\n", $body), implode("\n", $headers)); | ||
| } | ||
|
|
||
| function safe_filename($string) { | ||
| function safe_filename($string, $maxLength=255) { | ||
| $special_chars = ["?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}"]; | ||
| $string = trim(str_replace($special_chars, "", $string)); | ||
| $string = preg_replace('~[^0-9a-z -_]~i', '', $string); | ||
| $string = preg_replace('~[^0-9a-z -_.]~i', '', $string); | ||
| $string = preg_replace('~[- ]~i', '_', $string); | ||
| return trim($string); | ||
| // limit filename length to $maxLength characters | ||
| return substr(trim($string), 0, $maxLength); | ||
| } | ||
|
|
||
| /* | ||
|
|
@@ -112,7 +114,7 @@ function ini_encode_value($value) { | |
| if (is_int($value) || is_float($value)) return $value; | ||
| if (is_bool($value)) return $value ? 'true' : 'false'; | ||
| $value = (string)$value; | ||
| return '"'.strtr($value, ["\\"=>"\\\\", '"' => '\\"']).'"'; | ||
| return '"'.strtr($value, ["\\" => "\\\\", '"' => '\\"']).'"'; | ||
| } | ||
|
|
||
| function build_ini_string(array $data) { | ||
|
|
@@ -135,6 +137,7 @@ function ini_decode_value($value) { | |
| return $value; | ||
| } | ||
|
|
||
|
|
||
| // start | ||
| if ($argc == 1) exit(usage()); | ||
|
|
||
|
|
@@ -209,8 +212,9 @@ case 'add': | |
| $mailtest = false; | ||
| $overrule = false; | ||
| $noBrowser = false; | ||
| $customFilename = false; | ||
|
|
||
| $options = getopt("l:e:s:d:i:m:r:xtb"); | ||
| $options = getopt("l:e:s:d:i:m:r:u:xtb"); | ||
| foreach ($options as $option => $value) { | ||
| switch ($option) { | ||
| case 'e': | ||
|
|
@@ -246,11 +250,26 @@ case 'add': | |
| $link = $value; | ||
| $fqdnlink = (strpos($link,"http") === 0) ? $link : ($nginx['NGINX_DEFAULTURL']??'').$link; | ||
| break; | ||
| case 'u': | ||
| $customFilename = $value; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| $unread = "{$unread}/".safe_filename("{$event}-{$ticket}.notify"); | ||
| $archive = "{$archive}/".safe_filename("{$event}-{$ticket}.notify"); | ||
| if ($customFilename) { | ||
| $filename = safe_filename($customFilename); | ||
| } else { | ||
| // suffix length: _{timestamp}.notify = 1+10+7 = 18 chars. | ||
| $suffix = "_{$ticket}.notify"; | ||
| $max_name_len = 255 - strlen($suffix); | ||
| // sanitize event, truncating it to leave room for suffix | ||
| $clean_name = safe_filename($event, $max_name_len); | ||
| // construct filename with suffix (underscore separator matches safe_filename behavior) | ||
| $filename = "{$clean_name}{$suffix}"; | ||
| } | ||
|
|
||
| $unread = "{$unread}/{$filename}"; | ||
| $archive = "{$archive}/{$filename}"; | ||
| if (file_exists($archive)) break; | ||
|
Comment on lines
+259
to
273
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Custom filenames lack the When a custom filename is provided (line 260), it's sanitized without enforcing the The auto-generated path (lines 264-268) explicitly includes the Recommend either:
Regarding the 🤖 Prompt for AI Agents |
||
| $entity = $overrule===false ? $notify[$importance] : $overrule; | ||
| $cleanSubject = clean_subject($subject); | ||
|
|
@@ -274,8 +293,8 @@ case 'add': | |
| ]; | ||
| file_put_contents($unread, build_ini_string($unreadData)); | ||
| } | ||
| if (($entity & 2)==2 || $mailtest) generate_email($event, $cleanSubject, str_replace('<br>','. ',$description), $importance, $message, $recipients, $fqdnlink); | ||
| if (($entity & 4)==4 && !$mailtest) { if (is_array($agents)) {foreach ($agents as $agent) {exec("TIMESTAMP='$timestamp' EVENT=".escapeshellarg($event)." SUBJECT=".escapeshellarg($cleanSubject)." DESCRIPTION=".escapeshellarg($description)." IMPORTANCE=".escapeshellarg($importance)." CONTENT=".escapeshellarg($message)." LINK=".escapeshellarg($fqdnlink)." bash ".$agent);};}}; | ||
| if (($entity & 2)==2 || $mailtest) generate_email($event, clean_subject($subject), str_replace('<br>','. ',$description), $importance, $message, $recipients, $fqdnlink); | ||
| if (($entity & 4)==4 && !$mailtest) { if (is_array($agents)) {foreach ($agents as $agent) {exec("TIMESTAMP='$timestamp' EVENT=".escapeshellarg($event)." SUBJECT=".escapeshellarg(clean_subject($subject))." DESCRIPTION=".escapeshellarg($description)." IMPORTANCE=".escapeshellarg($importance)." CONTENT=".escapeshellarg($message)." LINK=".escapeshellarg($fqdnlink)." bash ".$agent);};}}; | ||
| break; | ||
|
|
||
| case 'get': | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: unraid/webgui
Length of output: 50371
🏁 Script executed:
Repository: unraid/webgui
Length of output: 1762
🏁 Script executed:
Repository: unraid/webgui
Length of output: 7884
🏁 Script executed:
Repository: unraid/webgui
Length of output: 278
🏁 Script executed:
Repository: unraid/webgui
Length of output: 7555
🏁 Script executed:
Repository: unraid/webgui
Length of output: 2791
🏁 Script executed:
Repository: unraid/webgui
Length of output: 615
Add server-side validation to enforce max popup bounds.
The max notification popups field has client-side HTML5 constraints (min=1, max=10) but update.php writes form values directly to the configuration file without any bounds checking. Add validation to reject values outside the 1-10 range before saving to prevent invalid configurations from direct POST requests or manual config editing.
🤖 Prompt for AI Agents