Exemplo n.º 1
0
def create_toc():
    """Creates the table of contents"""
    table_of_contents = TableOfContents()
    table_of_contents.dotsMinLevel = 0
    header1 = ParagraphStyle(name='Heading1', fontSize=16, leading=16)
    header2 = ParagraphStyle(name='Heading2', fontSize=14, leading=14)
    table_of_contents.levelStyles = [header1, header2]
    return [table_of_contents, PageBreak()]
Exemplo n.º 2
0
    def event_go(self):
        story = list()  # 报告内容存储结构
        story.append(PageBreak())
        # 目录
        toc = TableOfContents()
        toc.dotsMinLevel = 0
        toc.levelStyles = [H1, H2, H3]
        story.append(Paragraph('目录', toc1))
        story.append(toc)
        # 分页
        story.append(PageBreak())
        add_title(story, '1 前言', h1)
        add_title(story, '1.1 报告阅读说明', h2)
        story.append(
            Paragraph(
                '本报告是安全事件情况的统计,主要内容包含攻击源/目标TOP5,安全事件协议分布,安全事件来源分布,'
                '以及安全事件总数随时间分布趋势。', body))
        story.append(Paragraph('北京天地和兴科技有限公司感谢您对我们的信任和支持。现将安全事件报告呈上。', body))
        if self.report_method in [1, 2, 3]:
            add_title(story, '1.2 周期性报表', h2)
        else:
            add_title(story, '1.2 自定义报表', h2)
        self.base_info_table(story)
        story.append(PageBreak())
        story.append(Paragraph('2 安全事件概述', h1))
        add_title(story, '2.1 源地址top5', h2)
        self.src_table(story)
        add_title(story, '2.2 目的地址top5', h2)
        self.dst_table(story)
        story.append(PageBreak())
        add_title(story, '2.3 安全事件协议类型分布图', h2)
        self.event_proto_figure(story)
        story.append(PageBreak())
        add_title(story, '2.4 安全事件来源分布图', h2)
        self.event_src_figure(story)
        add_title(story, '2.5 事件时间分布趋势图', h2)
        self.event_time(story)

        story.append(PageBreak())
        # about_us_3(story)

        try:
            doc = MyDocTemplate(path + '/pdf_tmp/event_report.pdf')
            logger.info(
                "====================enter event report multiBuild............."
            )
            doc.multiBuild(story,
                           onFirstPage=firstPages,
                           onLaterPages=laterPages)
            os.system("rm -rf " + path + "/tmp/")
            os.system("mv " + path + "/pdf_tmp/event_report.pdf " +
                      "/data/report/alarm/")
        except:
            logger.error("MyDocTemplate build error.")
            logger.error(traceback.format_exc())
Exemplo n.º 3
0
    def process(self, block, context):
        toc = TableOfContents()
        toc.dotsMinLevel = 0
        toc.levelStyles = [
            context.styleSheet["Toc0"], context.styleSheet["Toc1"],
            context.styleSheet["Toc2"], context.styleSheet["Toc3"]
        ]

        content = []
        content.append(toc)
        return content
Exemplo n.º 4
0
    def proto_go(self):
        story = list()  # 报告内容存储结构
        story.append(PageBreak())
        # 目录
        toc = TableOfContents()
        toc.dotsMinLevel = 0
        toc.levelStyles = [H1, H2, H3]
        story.append(Paragraph('目录', toc1))
        story.append(toc)
        # 分页
        story.append(PageBreak())
        add_title(story, '1 前言', h1)
        add_title(story, '1.1 报告阅读说明', h2)
        story.append(
            Paragraph('本报告是协议审计情况的统计,主要内容包含协议类型分布,TOP特征值展示,'
                      '以及协议数随时间分布趋势。', body))
        story.append(Paragraph('北京天地和兴科技有限公司感谢您对我们的信任和支持。现将安全审计报告呈上。', body))
        if self.report_method in [1, 2, 3]:
            add_title(story, '1.2 周期性报表', h2)
        else:
            add_title(story, '1.2 自定义报表', h2)
        self.base_info_table(story)
        story.append(PageBreak())
        story.append(Paragraph('2 审计概述', h1))
        add_title(story, '2.1 协议类型分布图', h2)
        self.proto_figure(story)
        add_title(story, '2.2 源地址-目的地址top5', h2)
        self.src_dst_table(story)
        story.append(PageBreak())
        add_title(story, '2.3 协议时间分布趋势图', h2)
        self.proto_time(story)
        # add_title(story, '2.4 传输层分布', h2)
        # self.l2_figure(story)
        # story.append(PageBreak())
        # about_us_3(story)

        try:
            doc = MyDocTemplate(path + '/pdf_tmp/audit_report.pdf')
            logger.info(
                "====================enter proto report multiBuild............."
            )
            doc.multiBuild(story,
                           onFirstPage=firstPages,
                           onLaterPages=laterPages)
            os.system("rm -rf " + path + "/tmp/")
            os.system("mv " + path + "/pdf_tmp/audit_report.pdf " +
                      "/data/report/protocal/")
        except:
            logger.error("MyDocTemplate build error.")
            logger.error(traceback.format_exc())
Exemplo n.º 5
0
    def assets_go(self):
        story = list()  # 报告内容存储结构
        story.append(PageBreak())
        # 目录
        toc = TableOfContents()
        toc.dotsMinLevel = 0
        toc.levelStyles = [H1, H2, H3]
        story.append(Paragraph('目录', toc1))
        story.append(toc)
        # 分页
        story.append(PageBreak())
        add_title(story, '1 前言', h1)
        add_title(story, '1.1 报告阅读说明', h2)
        story.append(
            Paragraph('本报告是资产报告情况的统计,设备在线统计分布,设备类型统计分布,设备身份状态统计分布。', body))
        story.append(Paragraph('北京天地和兴科技有限公司感谢您对我们的信任和支持,现将资产报告呈上。', body))
        if self.report_method in [1, 2, 3]:
            add_title(story, '1.2 周期性报表', h2)
        else:
            add_title(story, '1.2 自定义报表', h2)
        self.base_info_table(story)
        story.append(PageBreak())
        story.append(Paragraph('2 资产报告概述', h1))
        add_title(story, '2.1 设备在线数量分布图', h2)
        self.assets_live(story)
        story.append(PageBreak())
        add_title(story, '2.2 设备类型分布图', h2)
        self.assets_type(story)
        story.append(PageBreak())
        add_title(story, '2.3 设备身份状态分布图', h2)
        self.assets_status(story)

        try:
            doc = MyDocTemplate(path + '/pdf_tmp/assets_report.pdf')
            logger.info(
                "====================enter assets report multiBuild............."
            )
            doc.multiBuild(story,
                           onFirstPage=firstPages,
                           onLaterPages=laterPages)
            os.system("rm -rf " + path + "/tmp/")
            os.system("mv " + path + "/pdf_tmp/assets_report.pdf " +
                      "/data/report/assets/")
        except:
            logger.error("MyDocTemplate build error.")
            logger.error(traceback.format_exc())
Exemplo n.º 6
0
    def log_go(self):
        story = list()  # 报告内容存储结构
        story.append(PageBreak())
        # 目录
        toc = TableOfContents()
        toc.dotsMinLevel = 0
        toc.levelStyles = [H1, H2, H3]
        story.append(Paragraph('目录', toc1))
        story.append(toc)
        # 分页
        story.append(PageBreak())
        add_title(story, '1 前言', h1)
        add_title(story, '1.1 报告阅读说明', h2)
        story.append(
            Paragraph(
                '本报告是对操作日志及系统日志的统计。操作日志主要内容包括操作用户ip地址top5,用户操作情况统计,'
                '以及用户操作日志随时间分布趋势。', body))
        story.append(
            Paragraph('系统日志主要内容包括系统日志分布情况,系统警告日志数量趋势分布,'
                      '以及系统日志总数随时间分布趋势。', body))
        story.append(Paragraph('北京天地和兴科技有限公司感谢您对我们的信任和支持。现将设备运行日志报告呈上。', body))
        if self.report_method in [1, 2, 3]:
            add_title(story, '1.2 周期性报表', h2)
        else:
            add_title(story, '1.2 自定义报表', h2)
        self.base_info_table(story)
        story.append(PageBreak())
        story.append(Paragraph('2 日志概述', h1))
        add_title(story, '2.1 操作日志概述', h2)
        add_title(story, '2.1.1 操作用户ip地址top5', h3)
        self.login_figure(story)
        add_title(story, '2.1.2 用户操作分布情况', h3)
        self.oper_figure(story)
        story.append(PageBreak())
        add_title(story, '2.1.3 用户操作日志趋势分布', h3)
        self.oper_log_time(story)
        story.append(PageBreak())
        add_title(story, '2.2 系统日志概述', h2)
        add_title(story, '2.2.1 系统日志分布情况', h3)
        self.sys_figure(story)
        add_title(story, '2.2.2 系统警告日志趋势分布', h3)
        self.alarm_log_time(story)
        story.append(PageBreak())
        add_title(story, '2.2.3 系统日志趋势分布', h3)
        self.sys_log_time(story)

        story.append(PageBreak())
        # about_us_3(story)

        try:
            doc = MyDocTemplate(path + '/pdf_tmp/log_report.pdf')
            logger.info(
                "====================enter log report multiBuild.............")
            doc.multiBuild(story,
                           onFirstPage=firstPages,
                           onLaterPages=laterPages)
            os.system("rm -rf " + path + "/tmp/")
            os.system("mv " + path + "/pdf_tmp/log_report.pdf " +
                      "/data/report/log/")
        except:
            logger.error("MyDocTemplate build error.")
            logger.error(traceback.format_exc())
Exemplo n.º 7
0
t = Table(coverData, colWidths=[200, 300])
t.setStyle(tableStyleStandard)
Story.append(t)

Story.append(NextPageTemplate('Later'))

Story.append(PageBreak())

# ----------- Table of Contents ----------------------------------------------------------------
Story.append(
    Paragraph("<font size=12>Table of Contents</font>", styles["Normal"]))
Story.append(Spacer(1, 6))

toc = TableOfContents()
toc.dotsMinLevel = 0
toc.levelStyles = [
    ParagraphStyle(fontName='Times-Bold',
                   fontSize=12,
                   name='TOCHeading1',
                   leftIndent=20,
                   firstLineIndent=-20,
                   spaceBefore=5,
                   leading=6),
    ParagraphStyle(fontSize=10,
                   name='TOCHeading2',
                   leftIndent=40,
                   firstLineIndent=-20,
                   spaceBefore=2,
                   leading=6),
    ParagraphStyle(fontSize=10,
Exemplo n.º 8
0
		log.info("MD5 check failed")

t=Table(coverData, colWidths=[200, 300])
t.setStyle(tableStyleStandard)                   
Story.append(t)

Story.append(NextPageTemplate('Later'))

Story.append(PageBreak())

# ----------- Table of Contents ----------------------------------------------------------------
Story.append(Paragraph("<font size=12>Table of Contents</font>", styles["Normal"]))
Story.append(Spacer(1, 6))

toc = TableOfContents()
toc.dotsMinLevel = 0
toc.levelStyles = [
    ParagraphStyle(
    	fontName='Times-Bold', 
    	fontSize=12, 
    	name='TOCHeading1', 
    	leftIndent=20, 
    	firstLineIndent=-20, 
    	spaceBefore=5, 
    	leading=6
    ),
    ParagraphStyle(
    	fontSize=10, 
    	name='TOCHeading2', 
    	leftIndent=40, 
    	firstLineIndent=-20,