Skip to content

Commit

Permalink
Merge pull request #835 from wazuh/3.10-fix-group-pdf
Browse files Browse the repository at this point in the history
Fix export group configuration
  • Loading branch information
Manuel J. Bernal authored Sep 12, 2019
2 parents 7a8d07a + 35c335e commit 67591ca
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
All notable changes to the Wazuh app for Splunk project will be documented in this file.


## Wazuh v3.10.0 - Splunk Enterprise v7.3.0 / v7.3.1 - Revision 41
## Wazuh v3.10.0 - Splunk Enterprise v7.3.0 / v7.3.1 - Revision 42

### Added

Expand Down
54 changes: 45 additions & 9 deletions SplunkAppForWazuh/appserver/controllers/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def addCustomTable(self,customTables,pdf,labels,currentSection):
rows.append(nextRow)
if rows and fields and type(rows) is list and rows[0]:
newTable[tableKey] = { "fields": fields, "rows": rows}
self.addTables(newTable,pdf,185,12)
self.addTables(newTable,pdf,185,10)
elif type(value) is dict:
customKeyList = []
customValueList = []
pdf.ln(5)
self.setTableTitle(pdf)
pdf.cell(0, 5, txt = self.getString(key,labels).capitalize(), border = '', align = '', fill = False, link = '')
pdf.set_margins(12, 0, 12)
pdf.set_margins(10, 0, 10)
pdf.ln(5)
for currentTableKey, currentTableValue in value.iteritems():
if type(currentTableValue) is dict:
Expand All @@ -422,7 +422,30 @@ def addCustomTable(self,customTables,pdf,labels,currentSection):
self.addKeyValueTable(customKeyList,customValueList,pdf)



def addSyscheckTable(self, data, pdf, labels,currentSection = {}):
customKeyList = []
customValueList = []
keySet = set()
#Calculate list of keys, the amount of keys is different on all keys
for currentDirectory in data:
for currentDirectoryKey in currentDirectory.keys():
keySet.add(currentDirectoryKey)
customKeyList = list(keySet)
pathIndex = customKeyList.index('path')
customKeyList[0], customKeyList[pathIndex] = customKeyList[pathIndex], customKeyList[0]

for currentDirectory in data:
rowValue = []
for currentKey in customKeyList:
if currentKey in currentDirectory:
rowValue.append(currentDirectory[currentKey])
else:
rowValue.append('-')
customValueList.append(rowValue)

directoriesTable = {}
directoriesTable['Directories'] = { "fields": customKeyList, "rows": customValueList}
self.addTables(directoriesTable,pdf,185,10)

def addTable(self, data, pdf, labels,currentSection = {}):
try:
Expand All @@ -449,7 +472,7 @@ def addTable(self, data, pdf, labels,currentSection = {}):
newRow = self.getDirectoriesChecks(row)
rows.append(newRow)
directoriesTable['Monitored directories'] = { "fields": fields, "rows": rows}
self.addTables(directoriesTable,pdf,185,12)
self.addTables(directoriesTable,pdf,185,10)
pdf.set_text_color(75, 179, 204)
pdf.cell(0, 5, txt = "Rt: Real Time | Wd: Who-Data | Per: Permission | Mt: Modification Time | Sl: Symbolic link | Rl: Recursion Level ", border = '',ln=1, align = '', fill = False, link = '')
pdf.ln(5)
Expand Down Expand Up @@ -506,7 +529,7 @@ def addSubtitle(self,currentSection,pdf):
pdf.set_text_color(0,0,0)
pdf.set_font('RobotoLight', '', 11)
pdf.cell(0, 6, txt = currentSection['desc'], border = '', align = 'L', fill = False, link = '')
pdf.set_margins(11, 0, 11)
pdf.set_margins(10, 0, 10)
pdf.ln(6)
del currentSection['subtitle']

Expand Down Expand Up @@ -723,7 +746,7 @@ def generateConfigurationReport(self, **kwargs):
conf_data = jsonbak.loads(conf_data)
if not conf_data or 'data' not in conf_data:
pass
elif 'items' in conf_data['data'] and 'filters' in conf_data['data']['items'][0] and not conf_data['data']['items'][0]['filters']:
elif 'items' not in conf_data['data']:
self.setTableTitle(pdf)
pdf.cell(0, 10, txt = "Group configuration is not available." , border = 'B', ln = 1, align = 'C', fill = False, link = 'https://documentation.wazuh.com/3.9/user-manual/reference/centralized-configuration.html')
pdf.add_page()
Expand Down Expand Up @@ -751,8 +774,21 @@ def generateConfigurationReport(self, **kwargs):
del item['filters']
if 'config' in item:
pdf.set_font('RobotoLight', '', 10)
pdf.set_margins(12, 0, 12)
pdf.set_margins(10, 0, 10)
pdf.ln(1)
if 'syscheck' in item['config']:
self.setTableTitle(pdf)
pdf.set_margins(10, 0, 10)
pdf.ln(5)
pdf.cell(190, 5, txt = 'Syscheck', border = '', align = '', fill = False, link = '')
pdf.ln(5)
syscheck_directories = {}
if 'directories' in item['config']['syscheck']:
syscheck_directories = item['config']['syscheck']['directories']
del(item['config']['syscheck']['directories'])
self.addTable(item['config']['syscheck'], pdf, customLabels,currentSection)
self.addSyscheckTable(syscheck_directories, pdf, customLabels,currentSection)
del(item['config']['syscheck'])
self.addTable(item['config'], pdf, customLabels,currentSection)
pdf.add_page()
pdf.ln(20)
Expand Down Expand Up @@ -797,7 +833,7 @@ def generateConfigurationReport(self, **kwargs):
currentAgentRow.append('-')
rows.append(currentAgentRow)
table["Agent List"] = { "fields" : fields, "rows" : rows , "title": False}
self.addTables(table,pdf,185,12)
self.addTables(table,pdf,185,10)
else:
self.setTableTitle(pdf)
pdf.cell(0, 10, txt = "No agents have been assigned to this group" , border = 'B', ln = 1, align = 'C', fill = False, link = '')
Expand All @@ -816,7 +852,7 @@ def generateConfigurationReport(self, **kwargs):
filteredTables = self.filterTableByField(currentConfig['filterBy'], conf_data['data'][configuration])
self.addTable(filteredTables, pdf, customLabels,currentSection)
else:
pdf.set_margins(11, 0, 11)
pdf.set_margins(10, 0, 10)
self.addTable(conf_data['data'][configuration], pdf, customLabels,currentSection)

if 'wodle' in currentSection:
Expand Down
2 changes: 1 addition & 1 deletion SplunkAppForWazuh/default/package.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[app]
version = 3.10.0
revision = 41
revision = 42

[wazuh]
version = 3.10.0
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "wazuh-splunk",
"version": "3.10.0",
"revision": "41",
"code": "41-0",
"revision": "42",
"code": "42-0",
"description": "Splunk app for Wazuh",
"main": "index.js",
"keywords": [
Expand Down

0 comments on commit 67591ca

Please sign in to comment.