Commit f566525 Save package analysis on database.

2 files Authored and Committed by davidcarlos 2 months ago
Save package analysis on database.

    
 1 @@ -158,7 +158,7 @@
 2               Report.save(db, dict_analysis, _analyzer.name, name)
 3               kiskadee.logger.debug(
 4                       "MONITOR: Saved analysis done by {} for package: {}-{}"
 5 -                     .format(analyzer, data["name"], data["version"])
 6 +                     .format(analyzer, package.name, version)
 7                   )
 8               return
 9           except Exception as err:
10 @@ -200,7 +200,7 @@
11               db.session.commit()
12               kiskadee.logger.debug(
13                       "MONITOR: Saved analysis reports for {} package"
14 -                     .format(data["name"])
15 +                     .format(package_name)
16                   )
17           except KeyError as key:
18               kiskadee.logger.debug(
19 @@ -211,7 +211,7 @@
20           except Exception as err:
21               kiskadee.logger.debug(
22                       "MONITOR: Failed to get analysis reports to {} package"
23 -                     .format(data["name"])
24 +                     .format(package_name)
25                   )
26               kiskadee.logger.debug(err)
27           return
 1 @@ -77,9 +77,11 @@
 2               return {}
 3           package = self.db.filter_by_name(Package, data['name'])
 4           if not package:
 5 -             Package.save(self.db, data)
 6 +             new_package = Package.save(self.db, data)
 7 +             self.save_package_analysis(data, new_package)
 8           else:
 9 -             Package.update(self.db, package, data)
10 +             updated_package = Package.update(self.db, package, data)
11 +             self.save_package_analysis(data, updated_package)
12   
13       def save_package_analysis(self, data, package):
14           for analyzer, result in data['results'].items():