예제 #1
0
    def save_image_report(self, imageId, report):
        date = str(int(time.time()))
        thedir = self.imagerootdir + "/" + imageId + "/reports/"
        if not os.path.exists(thedir):
            os.makedirs(thedir)
        thefile = thedir + "/image_report.json"

        if os.path.exists(thefile):
            oldreport = self.load_image_report(imageId)
            if 'tag_history' in oldreport:
                report['tag_history'] = list(oldreport['tag_history'])
            else:
                report['tag_history'] = list()

            if 'anchore_current_tags' not in oldreport:
                oldreport['anchore_current_tags'] = list([date, report['anchore_current_tags']])

            diff = list(set(oldreport['anchore_current_tags']).symmetric_difference(set(report['anchore_current_tags'])))
            if len(diff) > 0:
                # there is a difference between stored tags and new tags
                report['tag_history'].append([date, oldreport['anchore_current_tags']])
        
        if 'tag_history' not in report:
            report['tag_history'] = list()

        if len(report['tag_history']) <= 0:
            report['tag_history'].append([date, report['anchore_current_tags']])

        anchore_utils.update_file_jsonstr(json.dumps(report), thefile, False)
예제 #2
0
    def save_image_report(self, imageId, report):
        date = str(int(time.time()))
        thedir = self.imagerootdir + "/" + imageId + "/reports/"
        if not os.path.exists(thedir):
            os.makedirs(thedir)
        thefile = thedir + "/image_report.json"

        if os.path.exists(thefile):
            oldreport = self.load_image_report(imageId)
            if 'tag_history' in oldreport:
                report['tag_history'] = list(oldreport['tag_history'])
            else:
                report['tag_history'] = list()

            if 'anchore_current_tags' not in oldreport:
                oldreport['anchore_current_tags'] = list(
                    [date, report['anchore_current_tags']])

            diff = list(
                set(oldreport['anchore_current_tags']).symmetric_difference(
                    set(report['anchore_current_tags'])))
            if len(diff) > 0:
                # there is a difference between stored tags and new tags
                report['tag_history'].append(
                    [date, oldreport['anchore_current_tags']])

        if 'tag_history' not in report:
            report['tag_history'] = list()

        if len(report['tag_history']) <= 0:
            report['tag_history'].append(
                [date, report['anchore_current_tags']])

        anchore_utils.update_file_jsonstr(json.dumps(report), thefile, False)
예제 #3
0
 def save_gate_help_output(self, gate_help):
     thedir = os.path.join(self.imagerootdir)
     if not os.path.exists(thedir):
         os.makedirs(thedir)
     thefile = os.path.join(thedir, "gates_info.json")
     rc = anchore_utils.update_file_jsonstr(json.dumps(gate_help), thefile)
     return (rc)
예제 #4
0
    def save_image_report(self, imageId, report):
        # populate image metadata
        thedir = os.path.join(self.imagerootdir, imageId, "image_output",
                              "image_info")
        if not os.path.exists(thedir):
            os.makedirs(thedir)

        thefile = os.path.join(thedir, "image.meta")
        if 'meta' in report:
            anchore_utils.write_kvfile_fromdict(thefile, report['meta'])

        # save the report itself
        date = str(int(time.time()))
        thedir = self.imagerootdir + "/" + imageId + "/reports/"
        if not os.path.exists(thedir):
            os.makedirs(thedir)
        thefile = thedir + "/image_report.json"

        if os.path.exists(thefile):
            oldreport = self.load_image_report(imageId)
            if 'tag_history' in oldreport:
                report['tag_history'] = list(oldreport['tag_history'])
            else:
                report['tag_history'] = list()

            if 'anchore_current_tags' not in oldreport:
                oldreport['anchore_current_tags'] = list(
                    [date, report['anchore_current_tags']])

            diff = list(
                set(oldreport['anchore_current_tags']).symmetric_difference(
                    set(report['anchore_current_tags'])))
            if len(diff) > 0:
                # there is a difference between stored tags and new tags
                report['tag_history'].append(
                    [date, oldreport['anchore_current_tags']])

        if 'tag_history' not in report:
            report['tag_history'] = list()

        if len(report['tag_history']) <= 0:
            report['tag_history'].append(
                [date, report['anchore_current_tags']])

        anchore_utils.update_file_jsonstr(json.dumps(report), thefile, False)
예제 #5
0
 def save_gates_eval_report(self, imageId, report):
     thedir = self.imagerootdir + "/" + imageId + "/reports/"
     if not os.path.exists(thedir):
         os.makedirs(thedir)
     thefile = thedir + "/gates_eval_report.json"
     anchore_utils.update_file_jsonstr(json.dumps(report), thefile, False)
예제 #6
0
 def save_gates_eval_report(self, imageId, report):
     thedir = self.imagerootdir + "/" + imageId + "/reports/"
     if not os.path.exists(thedir):
         os.makedirs(thedir)
     thefile = thedir + "/gates_eval_report.json"
     anchore_utils.update_file_jsonstr(json.dumps(report), thefile, False)