def evaluate(self, image_obj, context): # Map to a namespace ns = DistroNamespace.for_obj(image_obj) oldest_update = None if ns: for namespace_name in ns.like_namespace_names: # Check feed names group = get_feed_group_detached('vulnerabilities', namespace_name) #vulnerability_feed.group_by_name(namespace_name) if group: # No records yet, but we have the feed, so may just not have any data yet oldest_update = group.last_sync break if self.max_age.value() is not None: try: if oldest_update is not None: oldest_update = calendar.timegm(oldest_update.timetuple()) mintime = time.time() - int(int(self.max_age.value()) * 86400) if oldest_update < mintime: self._fire(msg="The vulnerability feed for this image distro is older than MAXAGE ("+str(self.max_age.value())+") days") else: self._fire( msg="The vulnerability feed for this image distro is older than MAXAGE (" + str(self.max_age.value()) + ") days") except Exception as err: self._fire(msg="Cannot perform data feed up-to-date check - message from server: " + str(err))
def evaluate(self, image_obj, context): # Map to a namespace ns = DistroNamespace.for_obj(image_obj) oldest_update = None if ns: for namespace_name in ns.like_namespace_names: # Check feed names for feed in feed_registry.registered_vulnerability_feed_names( ): # First match, assume only one matches for the namespace group = get_feed_group_detached(feed, namespace_name) if group: # No records yet, but we have the feed, so may just not have any data yet oldest_update = group.last_sync logger.debug( "Found date for oldest update in feed %s group %s date = %s", feed, group.name, oldest_update, ) break if self.max_age.value() is not None: try: if oldest_update is not None: oldest_update = calendar.timegm(oldest_update.timetuple()) mintime = time.time() - int( int(self.max_age.value()) * 86400) if oldest_update < mintime: self._fire( msg= "The vulnerability feed for this image distro is older than MAXAGE (" + str(self.max_age.value()) + ") days") else: self._fire( msg= "The vulnerability feed for this image distro is older than MAXAGE (" + str(self.max_age.value()) + ") days") except Exception as err: self._fire( msg= "Cannot perform data feed up-to-date check - message from server: " + str(err))