Changing eval for getattr because security reasons, spotted by @jmesquita

This commit is contained in:
Angel Velasquez 2016-05-12 16:32:33 -03:00
parent 6031f3e694
commit eb14f1afb6
3 changed files with 7 additions and 5 deletions
integrations/mailer

View file

@ -58,12 +58,12 @@ above.
```
[notification:foo]
field = alert.resource
field = resource
regex = db-\w+
contacts = dba@lists.mycompany.com, dev@lists.mycompany.com
[notification:bar]
field = alert.resource
field = resource
regex = web-\w+
contacts = dev@lists.mycompany.com
```

View file

@ -197,8 +197,10 @@ class MailSender(threading.Thread):
LOG.debug('Checking %d group rules' % len(OPTIONS['group_rules']))
for rules in OPTIONS['group_rules']:
LOG.debug('Matching regex %s to %s (%s)' % (rules['regex'],
rules['field'], eval(rules['field'])))
if re.match(rules['regex'], eval(rules['field'])):
rules['field'],
getattr(alert, rules['field'], None)))
if re.match(rules['regex'],
getattr(alert, rules['field'], None)):
LOG.debug('Regex matched')
# Add up any new contacts
new_contacts = [x.strip() for x in rules['contacts'].split(',')

View file

@ -2,7 +2,7 @@
import setuptools
version = '3.3.1'
version = '3.3.2'
setuptools.setup(
name="alerta-mailer",