diff --git a/main.go b/main.go index 23bd45a..1e722e9 100644 --- a/main.go +++ b/main.go @@ -88,9 +88,9 @@ func main() { // //安全事件表格生成(需要先执行互联网区防火墙截图) // attackevent.Fw_event(attackevent.HW_fw1_cookie()) //将防火墙安全事件存放到xlsx文件中 //nessus的csv文件生成docx报告 - // wps.CSV_damo() + wps.CSV_damo() // log.Println(wps.Translate("hello")) - wps.Weekly_word() + // wps.Weekly_word() } } else { log.Println("没有授权") diff --git a/temp/lousao_temp.docx b/temp/lousao_temp.docx index e5bbc09..eab4ab3 100644 Binary files a/temp/lousao_temp.docx and b/temp/lousao_temp.docx differ diff --git a/temp/temp.docx b/temp/temp.docx index 45426e2..e46cce0 100644 Binary files a/temp/temp.docx and b/temp/temp.docx differ diff --git a/wps/csv_safety.go b/wps/csv_safety.go index 8bac10e..c2e8d23 100644 --- a/wps/csv_safety.go +++ b/wps/csv_safety.go @@ -41,32 +41,119 @@ func CSV_damo() { return } log.Println("开始将数据填入报告模板") + + table := doc.Tables()[3] + var host string + var con int + var tables []document.Table + // for _, csvstr := range people { + // if csvstr.Host == host { + // row := table.AddRow() + // row.Properties().SetHeight(22, wml.ST_HeightRuleExact) + // // text_s(row.AddCell(), csvstr.Host) //主机IP + // text_s(row.AddCell(), Translate(csvstr.Name)) //风险项 + // if csvstr.Risk == "None" { + // text_s(row.AddCell(), "无") //危险程度 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Risk)) //危险程度 + // } + + // if csvstr.Risk_Factor == "None" { + // text_s(row.AddCell(), "无") //危险因素 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Risk_Factor)) //危险因素 + // } + // text_s(row.AddCell(), Translate(csvstr.Synopsisk)) //摘要 + // text_s(row.AddCell(), Translate(csvstr.Description)) //描述 + // if csvstr.Solution == "n/a" { + // text_s(row.AddCell(), "无") //解决方案 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Solution)) //解决方案 + // } + + // } else { + // con++ + // doc.Tables()[con] = doc.Tables()[3] + // table = doc.Tables()[con] + // row := table.AddRow() + // row.Properties().SetHeight(22, wml.ST_HeightRuleExact) + // // text_s(row.AddCell(), csvstr.Host) //主机IP + // text_s(row.AddCell(), Translate(csvstr.Name)) //风险项 + // if csvstr.Risk == "None" { + // text_s(row.AddCell(), "无") //危险程度 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Risk)) //危险程度 + // } + + // if csvstr.Risk_Factor == "None" { + // text_s(row.AddCell(), "无") //危险因素 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Risk_Factor)) //危险因素 + // } + // text_s(row.AddCell(), Translate(csvstr.Synopsisk)) //摘要 + // text_s(row.AddCell(), Translate(csvstr.Description)) //描述 + // if csvstr.Solution == "n/a" { + // text_s(row.AddCell(), "无") //解决方案 + // } else { + // text_s(row.AddCell(), Translate(csvstr.Solution)) //解决方案 + // } + // } + // host = csvstr.Host + // } for _, csvstr := range people { - table := doc.Tables()[3] - row := table.AddRow() - row.Properties().SetHeight(22, wml.ST_HeightRuleExact) - // :=conn. - text_s(row.AddCell(), csvstr.Host) //主机IP - if csvstr.Risk == "None" { - text_s(row.AddCell(), "无") //危险程度 - } else { - text_s(row.AddCell(), Translate(csvstr.Risk)) //危险程度 - } - text_s(row.AddCell(), Translate(csvstr.Name)) //脆弱点 - if csvstr.Risk_Factor == "None" { - text_s(row.AddCell(), "无") //危险因素 - } else { - text_s(row.AddCell(), Translate(csvstr.Risk_Factor)) //危险因素 - } - text_s(row.AddCell(), Translate(csvstr.Synopsisk)) //摘要 - text_s(row.AddCell(), Translate(csvstr.Description)) //描述 - if csvstr.Solution == "n/a" { - text_s(row.AddCell(), "无") //解决方案 - } else { - text_s(row.AddCell(), Translate(csvstr.Solution)) //解决方案 - } + if csvstr.Host == host { + row := table.AddRow() + row.Properties().SetHeight(22, wml.ST_HeightRuleExact) + // text_s(row.AddCell(), csvstr.Host) //主机IP + text_s(row.AddCell(), csvstr.Name) //风险项 + if csvstr.Risk == "None" { + text_s(row.AddCell(), "无") //危险程度 + } else { + text_s(row.AddCell(), csvstr.Risk) //危险程度 + } + if csvstr.Risk_Factor == "None" { + text_s(row.AddCell(), "无") //危险因素 + } else { + text_s(row.AddCell(), csvstr.Risk_Factor) //危险因素 + } + text_s(row.AddCell(), csvstr.Synopsisk) //摘要 + text_s(row.AddCell(), csvstr.Description) //描述 + if csvstr.Solution == "n/a" { + text_s(row.AddCell(), "无") //解决方案 + } else { + text_s(row.AddCell(), csvstr.Solution) //解决方案 + } + + } else { + con++ + tables[con] = doc.Tables()[3] + table = tables[con] + row := table.AddRow() + row.Properties().SetHeight(22, wml.ST_HeightRuleExact) + // text_s(row.AddCell(), csvstr.Host) //主机IP + text_s(row.AddCell(), csvstr.Name) //风险项 + if csvstr.Risk == "None" { + text_s(row.AddCell(), "无") //危险程度 + } else { + text_s(row.AddCell(), csvstr.Risk) //危险程度 + } + + if csvstr.Risk_Factor == "None" { + text_s(row.AddCell(), "无") //危险因素 + } else { + text_s(row.AddCell(), csvstr.Risk_Factor) //危险因素 + } + text_s(row.AddCell(), csvstr.Synopsisk) //摘要 + text_s(row.AddCell(), csvstr.Description) //描述 + if csvstr.Solution == "n/a" { + text_s(row.AddCell(), "无") //解决方案 + } else { + text_s(row.AddCell(), csvstr.Solution) //解决方案 + } + } + host = csvstr.Host } // cvs_word() //写入CSV