parent
16303ee0a2
commit
ebf4120326
4 changed files with 8 additions and 8 deletions
|
@ -46,7 +46,8 @@ def filter_tags_have_repository_event(query, event):
|
||||||
.switch(RepositoryTag)
|
.switch(RepositoryTag)
|
||||||
.join(Repository)
|
.join(Repository)
|
||||||
.join(RepositoryNotification)
|
.join(RepositoryNotification)
|
||||||
.where(RepositoryNotification.event == event))
|
.where(RepositoryNotification.event == event)
|
||||||
|
.order_by(RepositoryTag.lifetime_start_ts.desc()))
|
||||||
|
|
||||||
def list_repository_tags(namespace_name, repository_name, include_hidden=False,
|
def list_repository_tags(namespace_name, repository_name, include_hidden=False,
|
||||||
include_storage=False):
|
include_storage=False):
|
||||||
|
|
|
@ -135,7 +135,7 @@ class VulnerabilityFoundEvent(NotificationEvent):
|
||||||
'name': notification.repository.name,
|
'name': notification.repository.name,
|
||||||
})
|
})
|
||||||
return build_event_data(repo, {
|
return build_event_data(repo, {
|
||||||
'tags': ['latest', 'prod'],
|
'tags': ['latest', 'prod', 'foo', 'bar', 'baz'],
|
||||||
'image': 'some-image-id',
|
'image': 'some-image-id',
|
||||||
'vulnerability': {
|
'vulnerability': {
|
||||||
'id': 'CVE-FAKE-CVE',
|
'id': 'CVE-FAKE-CVE',
|
||||||
|
@ -157,10 +157,9 @@ class VulnerabilityFoundEvent(NotificationEvent):
|
||||||
return actual_level_index <= filter_level_index
|
return actual_level_index <= filter_level_index
|
||||||
|
|
||||||
def get_summary(self, event_data, notification_data):
|
def get_summary(self, event_data, notification_data):
|
||||||
msg = '%s vulnerability detected in repository %s in tags %s'
|
msg = '%s vulnerability detected in repository %s in %s tags'
|
||||||
return msg % (event_data['vulnerability']['priority'],
|
return msg % (event_data['vulnerability']['priority'], event_data['repository'],
|
||||||
event_data['repository'],
|
len(event_data['tags']))
|
||||||
', '.join(event_data['tags']))
|
|
||||||
|
|
||||||
|
|
||||||
class BaseBuildEvent(NotificationEvent):
|
class BaseBuildEvent(NotificationEvent):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
A <a href="{{ event_data.vulnerability.link }}">{{ event_data.vulnerability.priority }} vulnerability</a> ({{ event_data.vulnerability.id }}) was detected in tags
|
A <a href="{{ event_data.vulnerability.link }}">{{ event_data.vulnerability.priority }} vulnerability</a> ({{ event_data.vulnerability.id }}) was detected in tags
|
||||||
{{ 'tags' | icon_image }}
|
{{ 'tags' | icon_image }}
|
||||||
{% for tag in event_data.tags %}{%if loop.index > 1 %}, {% endif %}{{ (event_data.repository, tag) | repository_tag_reference }}{% endfor %} in
|
{% for tag in event_data.tags[0:3] %}{%if loop.index > 1 %}, {% endif %}{{ (event_data.repository, tag) | repository_tag_reference }}{% endfor %} {% if event_data.tags|length > 3 %}(and {{ event_data.tags|length - 3 }} more) {% endif %} in
|
||||||
repository {{ event_data.repository | repository_reference }}
|
repository {{ event_data.repository | repository_reference }}
|
||||||
|
|
|
@ -296,7 +296,7 @@ class TestSecurityScanner(unittest.TestCase):
|
||||||
self.assertIsNotNone(queue_item)
|
self.assertIsNotNone(queue_item)
|
||||||
|
|
||||||
body = json.loads(queue_item.body)
|
body = json.loads(queue_item.body)
|
||||||
self.assertEquals(['latest', 'prod'], body['event_data']['tags'])
|
self.assertEquals(set(['latest', 'prod']), set(body['event_data']['tags']))
|
||||||
self.assertEquals('CVE-2014-9471', body['event_data']['vulnerability']['id'])
|
self.assertEquals('CVE-2014-9471', body['event_data']['vulnerability']['id'])
|
||||||
self.assertEquals('Low', body['event_data']['vulnerability']['priority'])
|
self.assertEquals('Low', body['event_data']['vulnerability']['priority'])
|
||||||
self.assertTrue(body['event_data']['vulnerability']['has_fix'])
|
self.assertTrue(body['event_data']['vulnerability']['has_fix'])
|
||||||
|
|
Reference in a new issue