Skip to contentSkip to conversation

Add local.conf and auto.conf into error details

PATCH In review [email protected] 5 participants 10 messages Nov 12, 2019 – Mar 22, 2021 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add local.conf and auto.conf into error details

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
 Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++
 Post/models.py                  |  2 ++
 Post/parser.py                  |  2 ++
 Post/test.py                    |  2 ++
 templates/error-details.html    | 10 ++++++++++
 test-data/test-payload.json     |  4 +++-
 6 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 Post/0006_auto_20190917_0419.py
Post/0006_auto_20190917_0419.py new file +24 -0
new file mode 100644
index 0000000..827944e
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('Post', '0005_build_error_type'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='build',
+            name='AUTO_CONF',
+            field=models.TextField(default=b'', max_length=5242880),
+        ),
+        migrations.AddField(
+            model_name='build',
+            name='LOCAL_CONF',
+            field=models.TextField(default=b'', max_length=5242880),
+        ),
+    ]
Post/models.py +2 -0
index ddf2fc7..e9fd010 100644
@@ -43,6 +43,8 @@ class Build(models.Model):
     LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
     ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
                                   default=ErrorType.RECIPE)
+    LOCAL_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
 
     def save(self, *args, **kwargs):
         if self.ERROR_TYPE not in [e_type[0] for e_type in
Post/parser.py +2 -0
index 9639308..69d43c1 100644
@@ -53,6 +53,8 @@ class Parser:
             b.EMAIL = str(jsondata['email'])
             b.LINK_BACK = jsondata.get("link_back", None)
             b.ERROR_TYPE = jsondata.get("error_type", ErrorType.RECIPE)
+            b.LOCAL_CONF = str(jsondata['local_conf'])
+            b.AUTO_CONF = str(jsondata['auto_conf'])
 
             # Extract the branch and commit
             g = re.match(r'(.*): (.*)', jsondata['branch_commit'])
Post/test.py +2 -0
index 6dc7878..4fe236c 100755
@@ -46,6 +46,8 @@ def compare_db_obj_with_payload(self, bf_object):
     self.assertEqual(bf_object.BUILD.NAME == str(payload['username']), True)
     self.assertEqual(bf_object.BUILD.EMAIL == str(payload['email']), True)
     self.assertEqual(bf_object.BUILD.LINK_BACK == payload.get("link_back", None), True)
+    self.assertEqual(bf_object.BUILD.LOCAL_CONF == payload.get("local_conf", None), True)
+    self.assertEqual(bf_object.BUILD.AUTO_CONF == payload.get("auto_conf", None), True)
 
     g = re.match(r'(.*): (.*)', payload['branch_commit'])
 
templates/error-details.html +10 -0
index c30160d..c8fce05 100644
@@ -81,6 +81,16 @@
           {% endwith %}
         </dd>
 
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}
+
       </dl>
       <div>
         <a class="btn btn-block" target="_blank" href="https://bugzilla.yoctoproject.org/enter_bug.cgi?classification=__all" >Open a bug</a>
test-data/test-payload.json +3 -1
index 0428a16..fd21053 100644
@@ -1,4 +1,5 @@
 {
+    "auto_conf": "",
     "branch_commit": "(master-test): 736b49449233c936e3099b314a58e91ad17f9774", 
     "build_sys": "x86_64-linux", 
     "component": "base-passwd", 
@@ -11,7 +12,8 @@
             "package": "base-passwd-3.5.29-r0", 
             "task": "do_install"
         }
-    ], 
+    ],
+    "local_conf": "",
     "machine": "qemux86", 
     "nativelsb": "Ubuntu-14.04", 
     "target_sys": "i586-poky-linux"
Signature · 1 line
2.7.4
#1 lore raw

Hi Changqing,

Some comments below.

Post/0006_auto_20190917_0419.py

Quoted 24 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
 Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++
 Post/models.py                  |  2 ++
 Post/parser.py                  |  2 ++
 Post/test.py                    |  2 ++
 templates/error-details.html    | 10 ++++++++++
 test-data/test-payload.json     |  4 +++-
 6 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 Post/0006_auto_20190917_0419.py
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

Post/models.py class Build(models.Model): · line 47

Quoted 8 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
     LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
     ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
                                   default=ErrorType.RECIPE)
+    LOCAL_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

Post/models.py class Build(models.Model):

Quoted 9 lines
Post/models.py +9 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

Cheers
Paul

Signature · 2 lines
Paul Eggleton
Intel System Software Products
#2 lore raw
Quoted 24 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 19 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
  Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++
  Post/models.py                  |  2 ++
  Post/parser.py                  |  2 ++
  Post/test.py                    |  2 ++
  templates/error-details.html    | 10 ++++++++++
  test-data/test-payload.json     |  4 +++-
  6 files changed, 43 insertions(+), 1 deletion(-)

create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 6 lines

Post/0006_auto_20190917_0419.py

Quoted 5 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 11 lines

Post/models.py class Build(models.Model): · line 47

Quoted 9 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
      LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
      ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
                                    default=ErrorType.RECIPE)
+    LOCAL_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF = models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

Quoted 6 lines

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK,  I will fix this.

Quoted 11 lines

Post/models.py class Build(models.Model):

Quoted 11 lines
Post/models.py +9 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}
Quoted 1 line

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass: replace angle brackets with &lt; and &gt;]

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;"

Do you have good idea to resolve this? Thanks.

Quoted 4 lines

Cheers
Paul

#3 lore raw

correct the mail list to [email protected]

Quoted 97 lines · Changqing Li
Quoted 25 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 20 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
  Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++ Post/models.py                  |  2 ++ Post/parser.py                  |  2 ++ Post/test.py                    |  2 ++ templates/error-details.html    | 10 ++++++++++ test-data/test-payload.json     |  4 +++-

  6 files changed, 43 insertions(+), 1 deletion(-)

  create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 6 lines

Post/0006_auto_20190917_0419.py

Quoted 5 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 13 lines

Post/models.py class Build(models.Model): · line 49

Quoted 11 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
       LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
       ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
                                     default=ErrorType.RECIPE)
+    LOCAL_CONF = 
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF = 
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

Quoted 6 lines

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK,  I will fix this.

Quoted 13 lines
Quoted 5 lines
Post/models.py +3 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ 
Quoted 8 lines

detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}

Quoted 1 line

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass: replace angle brackets with &lt; and &gt;]

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;"

Do you have good idea to resolve this? Thanks.

Quoted 4 lines

Cheers
Paul

#4 lore raw

has this resolved on server side ? since I see that patch to report-error.bbclass is still not applied in oe-core

Quoted 128 lines · Changqing Li

correct the mail list to [email protected]

Quoted 109 lines · Changqing Li
Quoted 27 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 21 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
  Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++
  Post/models.py                  |  2 ++
  Post/parser.py                  |  2 ++
  Post/test.py                    |  2 ++
  templates/error-details.html    | 10 ++++++++++
  test-data/test-payload.json     |  4 +++-
  6 files changed, 43 insertions(+), 1 deletion(-)

create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 8 lines

Post/0006_auto_20190917_0419.py

Quoted 6 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 22 lines
Quoted 12 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
      LINK_BACK = models.TextField(max_length=300, blank=True,
 null=True)
      ERROR_TYPE = models.CharField(max_length=20,
 choices=ERROR_TYPE_CHOICES,
                                    default=ErrorType.RECIPE)
+    LOCAL_CONF =
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF =
Quoted 1 line

models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

Quoted 6 lines

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK, I will fix this.

Quoted 13 lines
Quoted 11 lines
Post/models.py +3 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{

detail.BUILD.LOCAL_CONF | safe }}</dd>

Post/models.py +5 -0
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
Quoted 2 lines

detail.BUILD.AUTO_CONF | safe }}</dd>
+ {% endif %}

Quoted 5 lines

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass:
replace angle brackets with &lt; and &gt;]

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 7 lines

Do you have good idea to resolve this? Thanks.

Quoted 4 lines

Cheers
Paul

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#47707): https://lists.yoctoproject.org/g/yocto/message/47707
Mute This Topic: https://lists.yoctoproject.org/mt/61340472/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#5 lore raw
Quoted 3 lines · Khem Raj

has this resolved on server side ? since I see that patch to report-error.bbclass is still not applied in oe-core

V2 patches is for resolve this problem,  and Paul have 3 comments.

so I need to send a V3 for fix the comments.  It is easy to fix first 2 comments,

but the last comments,  I don't have more proper way.

@Paul,  could you check my reply of comments #3?  Thanks.

Quoted 123 lines · Changqing Li
Quoted 121 lines

correct the mail list to [email protected]

Quoted 105 lines · Changqing Li
Quoted 27 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 21 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
   Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++
   Post/models.py                  |  2 ++
   Post/parser.py                  |  2 ++
   Post/test.py                    |  2 ++
   templates/error-details.html    | 10 ++++++++++
   test-data/test-payload.json     |  4 +++-
   6 files changed, 43 insertions(+), 1 deletion(-)

create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 8 lines

Post/0006_auto_20190917_0419.py

Quoted 6 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 21 lines
Quoted 11 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
       LINK_BACK = models.TextField(max_length=300, blank=True,
 null=True)
       ERROR_TYPE = models.CharField(max_length=20,
 choices=ERROR_TYPE_CHOICES,
                                     default=ErrorType.RECIPE)
+    LOCAL_CONF =
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF =
Quoted 1 line

models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

Quoted 6 lines

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK, I will fix this.

Quoted 12 lines
Quoted 10 lines
Post/models.py +3 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{

detail.BUILD.LOCAL_CONF | safe }}</dd>

Post/models.py +5 -0
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
Quoted 2 lines

detail.BUILD.AUTO_CONF | safe }}</dd>
+ {% endif %}

Quoted 5 lines

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass:
replace angle brackets with &lt; and &gt;]

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 5 lines

Do you have good idea to resolve this? Thanks.

Quoted 3 lines

Cheers
Paul

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#47707): https://lists.yoctoproject.org/g/yocto/message/47707
Mute This Topic: https://lists.yoctoproject.org/mt/61340472/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw
In reply to Changqing Li

Hi, Paul

Could you help to check my reply below, thanks.

Quoted 97 lines · Changqing Li
Quoted 25 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 20 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
  Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++ Post/models.py                  |  2 ++ Post/parser.py                  |  2 ++ Post/test.py                    |  2 ++ templates/error-details.html    | 10 ++++++++++ test-data/test-payload.json     |  4 +++-

  6 files changed, 43 insertions(+), 1 deletion(-)

  create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 6 lines

Post/0006_auto_20190917_0419.py

Quoted 5 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 13 lines

Post/models.py class Build(models.Model): · line 49

Quoted 11 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
       LINK_BACK = models.TextField(max_length=300, blank=True, null=True)
       ERROR_TYPE = models.CharField(max_length=20, choices=ERROR_TYPE_CHOICES,
                                     default=ErrorType.RECIPE)
+    LOCAL_CONF = 
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF = 
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

Quoted 6 lines

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK,  I will fix this.

Quoted 13 lines
Quoted 5 lines
Post/models.py +3 -0
+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{ 
Quoted 8 lines

detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}

Quoted 1 line

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass: replace angle brackets with &lt; and &gt;]

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;"

Do you have good idea to resolve this? Thanks.

Quoted 4 lines

Cheers
Paul

#7 lore raw

Changqing,

Please use [email protected] for now.

According to Linkedin, Paul is now at Microsoft.

- armin

Quoted 123 lines · Changqing Li

Hi, Paul

Could you help to check my reply below, thanks.

Quoted 116 lines · Changqing Li
Quoted 27 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 21 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

Support to display local.conf and auto.conf on error report web. Here is commit in oe-core, which add local.conf/auto.conf into error report
https://git.openembedded.org/openembedded-core/commit/?id=7adf9707c04d8ef6bcd8d8bda555687f705e6ee6

This commit is related to YOCTO #13252

---
  Post/0006_auto_20190917_0419.py | 24 ++++++++++++++++++++++++ Post/models.py                  |  2 ++ Post/parser.py                  |  2 ++ Post/test.py                    |  2 ++ templates/error-details.html    | 10 ++++++++++ test-data/test-payload.json     |  4 +++-

  6 files changed, 43 insertions(+), 1 deletion(-)

  create mode 100644 Post/0006_auto_20190917_0419.py

Quoted 8 lines

Post/0006_auto_20190917_0419.py

Quoted 6 lines
Post/0006_auto_20190917_0419.py new file +0 -0
new file mode 100644
index 0000000..827944e

Could you please give the migration a proper name (-n option to makemigrations) e.g. local_conf_auto_conf

OK, thanks

Quoted 22 lines
Quoted 12 lines
Post/models.py +2 -0
@@ -43,6 +43,8 @@ class Build(models.Model):
       LINK_BACK = models.TextField(max_length=300, blank=True,
 null=True)
       ERROR_TYPE = models.CharField(max_length=20,
 choices=ERROR_TYPE_CHOICES,
                                     default=ErrorType.RECIPE)
+    LOCAL_CONF =
 models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")
+    AUTO_CONF =
Quoted 1 line

models.TextField(max_length=int(settings.MAX_UPLOAD_SIZE), default="")

I'm not sure this is practical, for two reasons:

1) Field sizes should not be variable like this; changing the MAX_UPLOAD_SIZE value after the fact would not change the database structure
2) The value could never actually reach MAX_UPLOAD_SIZE because the overhead of the surrounding JSON would block it from being uploaded if it did

Quoted 6 lines

However, since this is a TextField we don't actually have to specify a max_length (for a TextField max_length only actually affects the frontend, and we don't expose this field in a form) so it can just be removed.

Another thing, instead of default="" you should use blank=True.

OK,  I will fix this.

Quoted 13 lines
Quoted 13 lines

+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}

Quoted 5 lines

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass:
replace angle brackets with &lt; and &gt;]

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;"

Do you have good idea to resolve this? Thanks.

Quoted 4 lines

Cheers
Paul

#8 lore raw
In reply to Changqing Li
Quoted 51 lines · Changqing Li
Quoted 50 lines · Changqing Li
Quoted 20 lines · Paul Eggleton

Hi Changqing,

Some comments below.

Quoted 14 lines · On Tuesday, 12 November 2019 9:32:53 PM NZDT [email protected] wrote:

From: Changqing Li <[email protected]>

+        {% if detail.BUILD.LOCAL_CONF != "" %}
+        <dt></a>Local Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.LOCAL_CONF | safe }}</dd>
+        {% endif %}
+
+        {% if detail.BUILD.AUTO_CONF != "" %}
+        <dt></a>Auto Conf:</dt>
+        <dd style="white-space: pre-wrap;">{{
detail.BUILD.AUTO_CONF | safe }}</dd>
+        {% endif %}

Quoted 5 lines

We cannot use the safe filter here - doing so could open up an XSS vulnerability, since anyone can upload anything to the error-report application and the content could include links or other malicious HTML data. We should allow it to be auto-escaped. Is there a particular issue you were using this to solve?

This is for resolve a problem when there is angle brackets in local.conf/auto.conf.

I have a patch in oe-core [OE-core] [PATCH] report-error.bbclass:
replace angle brackets with &lt; and &gt;]

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 1 line
Quoted 1 line

Do you have good idea to resolve this? Thanks.

Sorry about the delay on this, we do really need to get this resolved. I'm wondering if we should replace the angled brackets test with
https://github.com/mozilla/bleach which would then remove the need for these workarounds.

Would you be able to update the patch for the others issues please and then we can look at this one separately?

Thanks,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw
Quoted 7 lines · Richard Purdie via lists.yoctoproject.org

Sorry about the delay on this, we do really need to get this resolved. I'm wondering if we should replace the angled brackets test with
https://github.com/mozilla/bleach which would then remove the need for these workarounds.

Would you be able to update the patch for the others issues please and then we can look at this one separately?

I just sent out an as yet untested patch which may fix some of the quoting issues by using bleach. I'd still need to add it to the requirements file...

Cheers,

Richard