Skip to contentSkip to conversation

report-error.bbclass: replace angle brackets with < and >

PATCH In review Khem Raj 2 participants 2 messages Mar 15, 2021 – Mar 22, 2021

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 report-error.bbclass: replace angle brackets with < and >

From: Changqing Li <[email protected]>

when we have below content in local.conf or auto.conf:
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj <[email protected]>" send-error-report will fail with "HTTP Error 500: OK"

error-report-web do rudimentary check on all fields that are passed to the graphs page to avoid any XSS happening, if contains '<', the server will return error(Invalid characters in json). fixed by use escape of <> to replace it.

NOTE: with this change, error-report-web need to add filter 'safe' for the string wanted to display to avoid further HTML escaping prior to output. Below is how the content displayed on webpage:
with the filter 'safe':
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj <[email protected]>" without the filter 'safe':
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj &lt;[email protected]&gt;"

Another patch for error-report-web will send to yocto mail list.

[YOCTO #13252]

---
 meta/classes/report-error.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes/report-error.bbclass +1 -0
index 9cb6b0bd31..8dac854944 100644
@@ -38,6 +38,7 @@ def get_conf_data(e, filename):
                     continue
                 else:
                     jsonstring=jsonstring + line
+    jsonstring = jsonstring.replace("<", "&lt;").replace(">", "&gt;")
     return jsonstring
 
 python errorreport_handler () {
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 19 lines · Khem Raj

From: Changqing Li <[email protected]>

when we have below content in local.conf or auto.conf:
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj <[email protected]>" send-error-report will fail with "HTTP Error 500: OK"

error-report-web do rudimentary check on all fields that are passed to the graphs page to avoid any XSS happening, if contains '<', the server will return error(Invalid characters in json). fixed by use escape of <> to replace it.

NOTE: with this change, error-report-web need to add filter 'safe' for the string wanted to display to avoid further HTML escaping prior to output. Below is how the content displayed on webpage:
with the filter 'safe':
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj <[email protected]>" without the filter 'safe':
BUILDHISTORY_COMMIT_AUTHOR ?= "Khem Raj &lt;[email protected]&gt;"

Quoted 3 lines

Another patch for error-report-web will send to yocto mail list.

[YOCTO #13252]

Quoted 25 lines
---
 meta/classes/report-error.bbclass | 1 +
 1 file changed, 1 insertion(+)
meta/classes/report-error.bbclass +1 -0
index 9cb6b0bd31..8dac854944 100644
@@ -38,6 +38,7 @@ def get_conf_data(e, filename):
                     continue
                 else:
                     jsonstring=jsonstring + line
+    jsonstring = jsonstring.replace("<", "&lt;").replace(">", "&gt;")
     return jsonstring
 
 python errorreport_handler () {
Signature · 1 line
2.30.2