summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrevor Gamblin <tgamblin@baylibre.com>2023-10-25 10:47:39 -0400
committerSteve Sakoman <steve@sakoman.com>2023-11-24 05:01:37 -1000
commit3f4011aba42814dfd9c019c7140364553c08231e (patch)
tree917fbb072c7a65045ae5f114bd2df5b3c787bd76
parent48537fb77b51c9b7e0bdee5264d78cf9a0c4b6af (diff)
downloadpoky-3f4011aba42814dfd9c019c7140364553c08231e.tar.gz
patchtest-send-results: check max line length, simplify responses
Check that the maximum line length of the testresult file is less than 220 characters, to help guard against malicious changes being sent in email responses. If any line exceeds this length, replace the normal testresults used in the response with a line stating that tests failed, but the results could not be processed. Also clean up the respone substrings slightly to go along with the change. (From OE-Core rev: 8e7e39134df926203b7bdfad22916e0d5da0589d) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit b0d53cf587dc9afb97f00c1089e45b758e96dd7c) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rwxr-xr-xscripts/patchtest-send-results17
1 files changed, 9 insertions, 8 deletions
diff --git a/scripts/patchtest-send-results b/scripts/patchtest-send-results
index bb4604aeaf..078651ec38 100755
--- a/scripts/patchtest-send-results
+++ b/scripts/patchtest-send-results
@@ -25,12 +25,8 @@ more information:\n\n---\n"""
25 25
26suggestions = """\n---\n\nPlease address the issues identified and 26suggestions = """\n---\n\nPlease address the issues identified and
27submit a new revision of the patch, or alternatively, reply to this 27submit a new revision of the patch, or alternatively, reply to this
28email with an explanation of why the patch format should be accepted. 28email with an explanation of why the patch format should be accepted. If
29Note that patchtest may report failures in the merge-on-head test for 29you believe these results are due to an error in patchtest, please
30patches that are part of a series if they rely on changes from
31preceeding entries.
32
33If you believe these results are due to an error in patchtest, please
34submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' 30submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest'
35category under 'Yocto Project Subprojects'). Thank you!""" 31category under 'Yocto Project Subprojects'). Thank you!"""
36 32
@@ -52,8 +48,6 @@ testresult = None
52with open(result_file, "r") as f: 48with open(result_file, "r") as f:
53 testresult = f.read() 49 testresult = f.read()
54 50
55reply_contents = greeting + testresult + suggestions
56
57# we know these patch files will only contain a single patch, so only 51# we know these patch files will only contain a single patch, so only
58# worry about the first element for getting the subject 52# worry about the first element for getting the subject
59mbox = mailbox.mbox(args.patch) 53mbox = mailbox.mbox(args.patch)
@@ -61,6 +55,13 @@ mbox_subject = mbox[0]['subject']
61subject_line = f"Patchtest results for {mbox_subject}" 55subject_line = f"Patchtest results for {mbox_subject}"
62 56
63if "FAIL" in testresult: 57if "FAIL" in testresult:
58 reply_contents = None
59 if len(max(open(result_file, 'r'), key=len)) > 220:
60 warning = "Tests failed for the patch, but the results log could not be processed due to excessive result line length."
61 reply_contents = greeting + warning + suggestions
62 else:
63 reply_contents = greeting + testresult + suggestions
64
64 ses_client = boto3.client('ses', region_name='us-west-2') 65 ses_client = boto3.client('ses', region_name='us-west-2')
65 response = ses_client.send_email( 66 response = ses_client.send_email(
66 Source='patchtest@automation.yoctoproject.org', 67 Source='patchtest@automation.yoctoproject.org',