mirror of
https://github.com/plankanban/planka.git
synced 2026-07-16 04:03:51 +03:00
fix: Block unsupported local Apprise schemas
This commit is contained in:
@@ -42,7 +42,7 @@ module.exports = {
|
||||
},
|
||||
);
|
||||
} catch (error) {
|
||||
sails.log.error(`Error sending notifications: ${error.stderr || error.message}`);
|
||||
sails.log.error(`Error sending notifications:\n${error.stderr || error.message}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -7,6 +7,18 @@ import logging
|
||||
import apprise
|
||||
|
||||
|
||||
BLOCKED_SCHEMAS_SET = {
|
||||
'syslog',
|
||||
'dbus',
|
||||
'kde',
|
||||
'qt',
|
||||
'glib',
|
||||
'gnome',
|
||||
'macosx',
|
||||
'windows',
|
||||
}
|
||||
|
||||
|
||||
last_apprise_message = None
|
||||
class CaptureWarningHandler(logging.Handler):
|
||||
def emit(self, record):
|
||||
@@ -34,8 +46,15 @@ if __name__ == '__main__':
|
||||
title = sys.argv[2]
|
||||
body_by_format = json.loads(sys.argv[3])
|
||||
|
||||
errors = []
|
||||
for service in services:
|
||||
url = service['url']
|
||||
schema = url.split(':')[0]
|
||||
|
||||
if schema in BLOCKED_SCHEMAS_SET:
|
||||
errors.append(f'[{schema}] Blocked service schema')
|
||||
continue
|
||||
|
||||
body_format = service['format']
|
||||
body = body_by_format[body_format]
|
||||
|
||||
@@ -43,10 +62,14 @@ if __name__ == '__main__':
|
||||
if not send_notification(url, title, body, body_format):
|
||||
if last_apprise_message:
|
||||
if last_apprise_message == 'There are no service(s) to notify':
|
||||
sys.stderr.write('Unknown service URL')
|
||||
errors.append(f'[{schema}] Unknown service URL')
|
||||
else:
|
||||
sys.stderr.write(last_apprise_message)
|
||||
errors.append(f'[{schema}] {last_apprise_message}')
|
||||
else:
|
||||
sys.stderr.write('Unknown error')
|
||||
errors.append(f'[{schema}] Unknown error')
|
||||
|
||||
if errors:
|
||||
for error in errors:
|
||||
print(error, file=sys.stderr)
|
||||
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user