SW-Inventory GUI with special characters in inventorized data
Message-ID: <55080a46.AAOvyoygZIczzl/Q%lm(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 0e9bb6a6346f8d13ce0d26ba08869463c6e12a17
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0e9bb6a6346f8d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 17 12:04:32 2015 +0100
#2147 FIX Fixed exception in HW-/SW-Inventory GUI with special characters in inventorized
data
The information fetched from e.g. windows systems were not properly encoded. This could
lead into exceptions when viewing the data in the GUI.
To get these encoding errors fixed, you need to update to this version and then wait
for all your inventory data being updated. After it has been updated, the errors in the
GUI should be gone.
---
.werks/2147 | 15 +++++++++++++++
ChangeLog | 1 +
inventory/win_bios | 1 +
inventory/win_cpuinfo | 1 +
inventory/win_disks | 1 +
inventory/win_exefiles | 1 +
inventory/win_os | 1 +
inventory/win_reg_uninstall | 1 +
inventory/win_system | 1 +
inventory/win_video | 1 +
inventory/win_wmi_software | 1 +
modules/check_mk_base.py | 14 +++++++++++++-
12 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/.werks/2147 b/.werks/2147
new file mode 100644
index 0000000..ec6a636
--- /dev/null
+++ b/.werks/2147
@@ -0,0 +1,15 @@
+Title: Fixed exception in HW-/SW-Inventory GUI with special characters in inventorized
data
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426590143
+
+The information fetched from e.g. windows systems were not properly encoded. This could
+lead into exceptions when viewing the data in the GUI.
+
+To get these encoding errors fixed, you need to update to this version and then wait
+for all your inventory data being updated. After it has been updated, the errors in the
+GUI should be gone.
diff --git a/ChangeLog b/ChangeLog
index 45f04fc..dd93893 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -403,6 +403,7 @@
* 1851 FIX: win_exefiles: inventory check can now handle time stamps in us english
locale
* 1943 FIX: inventory plugin win_os: no longer detects incorrect i386
architecture...
* 1995 FIX: dmidecode: Fix parsing when memory devices are listed before controller
+ * 2147 FIX: Fixed exception in HW-/SW-Inventory GUI with special characters in
inventorized data...
1.2.6b1:
diff --git a/inventory/win_bios b/inventory/win_bios
index ac199a7..4a79180 100644
--- a/inventory/win_bios
+++ b/inventory/win_bios
@@ -75,5 +75,6 @@ def inv_win_bios(info):
inv_info['win_bios'] = {
"inv_function" : inv_win_bios,
+ "unicode" : True,
}
diff --git a/inventory/win_cpuinfo b/inventory/win_cpuinfo
index 7a614cf..d37cb21 100644
--- a/inventory/win_cpuinfo
+++ b/inventory/win_cpuinfo
@@ -124,5 +124,6 @@ def inv_win_cpuinfo(info):
inv_info['win_cpuinfo'] = {
"inv_function" : inv_win_cpuinfo,
+ "unicode" : True,
}
diff --git a/inventory/win_disks b/inventory/win_disks
index 7514f00..1feba35 100644
--- a/inventory/win_disks
+++ b/inventory/win_disks
@@ -88,4 +88,5 @@ def inv_win_disks(info):
inv_info['win_disks'] = {
"inv_function" : inv_win_disks,
+ "unicode" : True,
}
diff --git a/inventory/win_exefiles b/inventory/win_exefiles
index b5d1862..6c3401b 100644
--- a/inventory/win_exefiles
+++ b/inventory/win_exefiles
@@ -65,4 +65,5 @@ def inv_win_exefiles(info):
inv_info['win_exefiles'] = {
"inv_function" : inv_win_exefiles,
+ "unicode" : True,
}
diff --git a/inventory/win_os b/inventory/win_os
index 9fc5f2c..3d51076 100644
--- a/inventory/win_os
+++ b/inventory/win_os
@@ -47,4 +47,5 @@ def inv_win_os(info):
inv_info['win_os'] = {
"inv_function" : inv_win_os,
+ "unicode" : True,
}
diff --git a/inventory/win_reg_uninstall b/inventory/win_reg_uninstall
index ed21209..1cd4525 100644
--- a/inventory/win_reg_uninstall
+++ b/inventory/win_reg_uninstall
@@ -53,4 +53,5 @@ def inv_win_reg_uninstall(info):
inv_info['win_reg_uninstall'] = {
"inv_function" : inv_win_reg_uninstall,
+ "unicode" : True,
}
diff --git a/inventory/win_system b/inventory/win_system
index 5c232d1..2016694 100644
--- a/inventory/win_system
+++ b/inventory/win_system
@@ -51,4 +51,5 @@ def inv_win_system(info):
inv_info['win_system'] = {
"inv_function" : inv_win_system,
+ "unicode" : True,
}
diff --git a/inventory/win_video b/inventory/win_video
index 4eebf19..127b3de 100644
--- a/inventory/win_video
+++ b/inventory/win_video
@@ -53,4 +53,5 @@ def inv_win_video(info):
inv_info['win_video'] = {
"inv_function" : inv_win_video,
+ "unicode" : True,
}
diff --git a/inventory/win_wmi_software b/inventory/win_wmi_software
index 66382b5..bbec16a 100644
--- a/inventory/win_wmi_software
+++ b/inventory/win_wmi_software
@@ -55,4 +55,5 @@ def inv_win_wmi_software(info):
inv_info['win_wmi_software'] = {
"inv_function" : inv_win_wmi_software,
+ "unicode" : True,
}
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index c48a12e..9251418 100644
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -825,6 +825,7 @@ def parse_info(lines, hostname):
section_options = {}
separator = None
encoding = None
+ to_unicode = False
for line in lines:
line = line.rstrip("\r")
stripped_line = line.strip()
@@ -872,6 +873,13 @@ def parse_info(lines, hostname):
# The section data might have a different encoding
encoding = section_options.get("encoding")
+ # Make the contents of the section unicode strings or UTF-8
+ # encoded bytestrings (like it was done always in the past)
+ try:
+ to_unicode = inv_info.get(section_name, {}).get('unicode',
False)
+ except NameError:
+ pass # e.g. in precompiled mode we have no inv_info. That's ok.
+
elif stripped_line != '':
if "nostrip" not in section_options:
line = stripped_line
@@ -879,9 +887,13 @@ def parse_info(lines, hostname):
if encoding:
try:
decoded_line = line.decode(encoding)
- line = decoded_line.encode('utf-8')
+ if not to_unicode:
+ line = decoded_line.encode('utf-8')
except:
pass
+ elif to_unicode:
+ line = line.decode('utf-8')
+
section.append(line.split(separator))
return info, piggybacked, persist