mirror of
https://github.com/ansible/awx.git
synced 2026-07-03 12:28:01 -02:30
Protect against very large stdout fields
* Defer loading result_stdout_text until specifically needed * Conditionally display it based on the size of the field * Provide a helpful message otherwise
This commit is contained in:
@@ -12,7 +12,7 @@ from StringIO import StringIO
|
||||
|
||||
# Django
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.db import models, connection
|
||||
from django.core.exceptions import NON_FIELD_ERRORS
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -657,6 +657,13 @@ class UnifiedJob(PolymorphicModel, PasswordFieldsModel, CommonModelNameNotUnique
|
||||
def result_stdout(self):
|
||||
return self._result_stdout_raw(escape_ascii=True)
|
||||
|
||||
@property
|
||||
def result_stdout_size(self):
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("select length(result_stdout_text) from main_unifiedjob where id = %d" % self.pk)
|
||||
record_size = cursor.fetchone()[0]
|
||||
return record_size
|
||||
|
||||
def _result_stdout_raw_limited(self, start_line=0, end_line=None, redact_sensitive=True, escape_ascii=False):
|
||||
return_buffer = u""
|
||||
if end_line is not None:
|
||||
|
||||
Reference in New Issue
Block a user