Skip to content

Commit fae33b1

Browse files
committedApr 29, 2019
Add PowerAuditor version in ribbon
1 parent 9a20f7e commit fae33b1

9 files changed

+81
-26
lines changed
 

‎PowerAuditor_LastUpdateVulndb.bat

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@echo off
2+
:: PowerAuditor - A simple script to help report writing by https://github.com/1mm0rt41PC
3+
::
4+
:: Filename: PowerAuditor_LastUpdateVulndb.bat - Script for auto update
5+
::
6+
:: This program is free software; you can redistribute it and/or modify
7+
:: it under the terms of the GNU General Public License as published by
8+
:: the Free Software Foundation; either version 2 of the License, or
9+
:: (at your option) any later version.
10+
::
11+
:: This program is distributed in the hope that it will be useful,
12+
:: but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
:: GNU General Public License for more details.
15+
::
16+
:: You should have received a copy of the GNU General Public License
17+
:: along with this program; see the file COPYING. If not, write to the
18+
:: Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19+
20+
set mypath=%~dp0
21+
set mypath=%mypath:~0,-1%
22+
pushd %mypath%\vulndb
23+
git log -1 --format=%%cd --date=short 2>>&1
24+
popd

‎PowerAuditor_last.xlsm

3.95 KB
Binary file not shown.

‎dev/PowerAuditor.xlsm

5.19 KB
Binary file not shown.

‎dev/src/ribbon.xml

+8-5
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,19 @@ https://www.rondebruin.nl/win/s2/win003.htm
3030
<tabs>
3131
<tab id="PowerAuditor" label="PowerAuditor" insertBeforeQ="TabFormat">
3232
<group id="Reports" label="Reports" autoScale="true">
33-
<button id="FillExcelWithProof" label="Fill excel with proof" imageMso="TableAutoFormat" onAction="ThisWorkbook.FillExcelWithProof"/>
33+
<button id="FillExcelWithProof" label="Fill excel with proof" imageMso="TableAutoFormat" onAction="ThisWorkbook.fillExcelWithProof"/>
3434
<button id="ExportExcelToWordTemplate" label="Export Excel to Word" imageMso="HappyFace" onAction="ThisWorkbook.ExportExcelToWordTemplate"/>
35-
<button id="GenSynthesis" label="Generate synthesis" imageMso="ChartInsert" onAction="ThisWorkbook.GenSynthesis"/>
36-
<button id="ExportFinalStaticsDocuments" label="Generate final RA/RD/XL" imageMso="PageOrientationPortraitLandscape" size="large" onAction="ThisWorkbook.ExportFinalStaticsDocuments"/>
35+
<button id="GenSynthesis" label="Generate synthesis" imageMso="ChartInsert" onAction="ThisWorkbook.genSynthesis"/>
36+
<button id="ExportFinalStaticsDocuments" label="Generate final RA/RD/XL" imageMso="PageOrientationPortraitLandscape" size="large" onAction="ThisWorkbook.exportFinalStaticsDocuments"/>
3737
</group>
3838
<group id="TeamSync" label="TeamSync" autoScale="true">
39-
<button id="ExportVulnToGit" label="Export vuln to git" imageMso="FileSaveAsWebPage" size="large" onAction="ThisWorkbook.ExportVulnToGit"/>
39+
<button id="ExportVulnToGit" label="Export vuln to git" imageMso="FileSaveAsWebPage" size="large" onAction="ThisWorkbook.exportVulnToGit"/>
4040
</group>
4141
<group id="Dev" label="Dev" autoScale="true">
42-
<button id="toProd" label="Send template to prod" getEnabled="CustomRibbonTab.GetEnabled" imageMso="SendStatusReport" onAction="ThisWorkbook.toProd"/>
42+
<button id="toProd" label="Send template to prod" getEnabled="CustomRibbonTab.isDevMode" imageMso="SendStatusReport" onAction="ThisWorkbook.toProd"/>
43+
<editBox id="PowerAuditorVersion" imageMso="OpenAttachedCalendar" label="PowerAuditor version" getText="CustomRibbonTab.getVersion" enabled="false" sizeString="99999999999999"/>
44+
<editBox id="TemplateVersion" imageMso="OpenAttachedCalendar" label="Template version" getText="CustomRibbonTab.getVersion" enabled="false" sizeString="99999999999999"/>
45+
<editBox id="VulnDBVersion" imageMso="OpenAttachedCalendar" label="VulnDB version" getText="CustomRibbonTab.LastUpdate" enabled="false" sizeString="99999999999999"/>
4346
</group>
4447
</tab>
4548
</tabs>

‎dev/src/vba/CustomRibbonTab.bas.vb

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,35 @@ Option Explicit
1919
' Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2020

2121
Private G_Ribbon As Object
22+
Private G_TemplateVersion As String
2223

2324
Private Sub onLoad(rb As Object)
2425
Debug.Print "Custon ribbon loaded"
2526
Set CustomRibbonTab.G_Ribbon = rb
2627
CustomRibbonTab.G_Ribbon.ActivateTab "PowerAuditor"
2728
End Sub
2829

29-
3030
Private Sub RibbonOnChange(control As Object, val)
3131
Worksheets("PowerAuditor").Range(control.id).Value2 = val
3232
End Sub
3333

34-
35-
Private Sub GetEnabled(control As Object, ByRef enabled)
34+
Private Sub isDevMode(control As Object, ByRef enabled)
3635
enabled = Common.isDevMode()
3736
End Sub
3837

38+
Private Sub getVersion(control As IRibbonControl, ByRef text)
39+
On Error Resume Next
40+
text = Range(control.id).Value2
41+
Err.Clear
42+
End Sub
3943

40-
Private Sub GetText(control As IRibbonControl, ByRef text)
41-
text = Worksheets("PowerAuditor").Range(control.id).Value2
44+
Private Sub lastUpdate(control As IRibbonControl, ByRef text)
45+
Debug.Print "Getting LastUpdate"
46+
text = Common.trim(IOFile.getOutpoutFromShellCmd(IOFile.getPowerAuditorPath() & "\PowerAuditor_LastUpdateVulndb.bat "))
4247
End Sub
4348

49+
Public Sub invalidAlltext()
50+
On Error Resume Next
51+
CustomRibbonTab.G_Ribbon.InvalidateControl "TemplateVersion"
52+
Err.Clear
53+
End Sub

‎dev/src/vba/IOFile.bas.vb

+12-5
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ Public Function renameDocument(inst, ext As String, pType As String, Optional By
119119
End Function
120120

121121

122-
123-
124122
Public Function git(sArgs As String, Optional sRepo As String = "vulndb") As Boolean
125123
Debug.Print "Git " & sArgs & " on <" & sRepo & ">"
126124
Dim tmpFile As String: tmpFile = Environ("temp") & "\" & randomString(7)
@@ -281,9 +279,18 @@ Public Function getVulnDBPath(sVulnerabilityName As String, Optional bCreateIfNo
281279
sDesktopIni = sDesktopIni & "PersonalizedName=" & sVulnerabilityName & vbCrLf
282280

283281
If Not isFolder Then MkDir (sPath)
284-
Call IOFile.fileSetContent(sPath & "\desktop.ini", sDesktopIni)
285-
oFS.getfile(sPath & "\desktop.ini").Attributes = 39
286-
oFS.getfolder(sPath).Attributes = 17
282+
Dim sDesktopIniPath As String: sDesktopIniPath = sPath & "\desktop.ini"
283+
If IOFile.filenameEncode(sVulnerabilityName) = sVulnerabilityName Then
284+
If isFile(sDesktopIniPath) Then
285+
oFS.getfile(sDesktopIniPath).Attributes = 32
286+
Call removeFile(sDesktopIniPath)
287+
End If
288+
Else
289+
oFS.getfile(sDesktopIniPath).Attributes = 32
290+
Call IOFile.fileSetContent(sPath & "\desktop.ini", sDesktopIni)
291+
oFS.getfile(sPath & "\desktop.ini").Attributes = 39
292+
oFS.getfolder(sPath).Attributes = 17
293+
End If
287294
getVulnDBPath = sPath
288295
End Function
289296

‎dev/src/vba/ThisWorkbook.cls.vb

+8
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ Sub exportFinalStaticsDocuments(control As Object)
157157
Dim ws As Worksheet: Set ws = Worksheets(getInfo("REPORT_TYPE"))
158158
Dim wDoc As Object: Set wDoc = Word.getInstance()
159159
Call RT.exportFinalStaticsDocuments(wDoc, ws)
160+
Call IOFile.runCmd("explorer.exe " & ThisWorkbook.Path & "\output", 1, False)
160161
MsgBox "Generated"
161162
End Sub
162163

@@ -168,6 +169,13 @@ Public Sub ToProd(control As Object)
168169
End If
169170
Application.DisplayAlerts = False
170171
Dim sFilepath As String
172+
173+
If Month(Now) < 10 Then
174+
Range("PowerAuditorVersion").Value2 = Year(Now) & "-0" & Month(Now) & "-" & Day(Now)
175+
Else
176+
Range("PowerAuditorVersion").Value2 = Year(Now) & "-" & Month(Now) & "-" & Day(Now)
177+
End If
178+
Range("TemplateVersion").Value2 = Range("PowerAuditorVersion").Value2
171179

172180
' On upgrade le template vers la bonne destination
173181
Dim wb_exp As Workbook: Set wb_exp = Workbooks.Add

‎dev/src/vba/Word.bas.vb

+13-11
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,16 @@ Public Sub insertVuln(wDoc As Object, ws As Worksheet, iRow As Integer)
170170
Dim subCC As Object
171171
Dim sPath As String: sPath = IOFile.getVulnDBPath(name)
172172
If IOFile.isFile(sPath & "\desc.html") Then
173-
For i = 0 To UBound(toImportHTML)
174-
If IOFile.isFile(sPath & "\" & toImportHTML(i) & ".html") Then
175-
Set subCC = wDoc.SelectContentControlsByTitle("VLN_" & toImportHTML(i) & "_" & id)(1)
176-
If Common.isEmptyString(Common.trim(subCC.Range.text, "x")) Then
177-
Call subCC.Range.InsertFile(sPath & "\" & toImportHTML(i) & ".html", , , False, False)
173+
If MsgBox("Import data from VulnDB for the vulnerability >" & name & "< ?", vbYesNo, "PowerAuditor") = vbYes Then
174+
For i = 0 To UBound(toImportHTML)
175+
If IOFile.isFile(sPath & "\" & toImportHTML(i) & ".html") Then
176+
Set subCC = wDoc.SelectContentControlsByTitle("VLN_" & toImportHTML(i) & "_" & id)(1)
177+
If Common.isEmptyString(Common.trim(subCC.Range.text, "x")) Then
178+
Call subCC.Range.InsertFile(sPath & "\" & toImportHTML(i) & ".html", , , False, False)
179+
End If
178180
End If
179-
End If
180-
Next i
181+
Next i
182+
End If
181183
End If
182184

183185
' On insert les preuves qui proviennent du dossier VULN
@@ -405,21 +407,21 @@ Public Sub updateColorBoldSynthesis(wDoc As Object, aText As Variant, Optional v
405407
Dim i As Integer, j As Integer
406408
Dim color As Variant
407409
'color = Array("GRIS", "JAUNE", "ORANGE", "ROUGE")
408-
If vColor = True And VarType(vColor) = vbBoolean Then
409-
vColor = Array(RGB(133, 133, 133), RGB(255, 255, 0), RGB(255, 192, 0), RGB(255, 0, 0))
410+
If VarType(vColor) = vbBoolean Then
411+
If vColor = True Then vColor = Array(RGB(133, 133, 133), RGB(255, 255, 0), RGB(255, 192, 0), RGB(255, 0, 0))
410412
End If
411413
For i = 0 To UBound(aText)
412414
With wDoc.Content.Find
413415
.ClearFormatting
414416
With .Replacement
415417
.ClearFormatting
416418
.Font.Bold = True
417-
If VarType(vColor) = vbArray Then
419+
If VarType(vColor) <> vbBoolean Then
418420
.Font.color = vColor(Left(aText(i), 1) - 1)
419421
End If
420422
.Font.Shadow = True
421423
End With
422-
If VarType(vColor) = vbArray Then
424+
If VarType(vColor) <> vbBoolean Then
423425
.Execute FindText:="{" & aText(i) & "}", replacewith:=Split(aText(i), " - ")(1), Format:=True, Replace:=wdReplaceAll
424426
Else
425427
.Execute FindText:="**" & aText(i) & "**", replacewith:=aText(i), Format:=True, Replace:=wdReplaceAll

‎dev/src/vba/Xls.bas.vb

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ reTry_loadExcelSheet:
120120
.Interior.color = 0
121121
.Font.color = 0
122122
End With
123+
Call CustomRibbonTab.invalidAlltext
123124
Versionning.G_bDisableExportVBCode = True
124125
Call ws_main.Parent.Save
125126
Call Versionning.loadModule(Split(getInfo("REPORT_TYPE"), "-")(0))

0 commit comments

Comments
 (0)
Please sign in to comment.