All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Damian Wrobel" <dwrobel@ertelnet.rybnik.pl>
To: openembedded-core@lists.openembedded.org
Cc: Adam Romanek <romanek.adam@gmail.com>
Subject: [PATCH] report-error: Mask AWS credentials to avoid leaking them
Date: Tue, 13 Jul 2021 11:22:42 +0200	[thread overview]
Message-ID: <20210713092242.754717-1-dwrobel@ertelnet.rybnik.pl> (raw)

From: Adam Romanek <romanek.adam@gmail.com>

Removes potentially presonal information from error reports.

Signed-off-by: Adam Romanek <romanek.adam@gmail.com>
Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
---
 meta/classes/report-error.bbclass | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index de48e4ff0f..c17e7e2851 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -38,6 +38,15 @@ def get_conf_data(e, filename):
                     jsonstring=jsonstring + line
     return jsonstring
 
+def errorreport_maskvars(e, logdata):
+    origenv = e.data.getVar("BB_ORIGENV", False)
+    vars_to_mask = ("TOPDIR", "TMPDIR", "AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY")
+    for var_name in vars_to_mask:
+        var_value = e.data.getVar(var_name, True) or (origenv and origenv.getVar(var_name, True))
+        if var_value:
+            logdata = logdata.replace(var_value, var_name)
+    return logdata
+
 python errorreport_handler () {
         import json
         import codecs
@@ -82,11 +91,7 @@ python errorreport_handler () {
                 try:
                     with codecs.open(log, encoding='utf-8') as logFile:
                         logdata = logFile.read()
-                    # Replace host-specific paths so the logs are cleaner
-                    for d in ("TOPDIR", "TMPDIR"):
-                        s = e.data.getVar(d)
-                        if s:
-                            logdata = logdata.replace(s, d)
+                    logdata = errorreport_maskvars(e, logdata)
                 except:
                     logdata = "Unable to read log file"
             else:
-- 
2.31.1


             reply	other threads:[~2021-07-13  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-13  9:22 Damian Wrobel [this message]
2021-07-13  9:41 ` [OE-core] [PATCH] report-error: Mask AWS credentials to avoid leaking them Josef Holzmayr

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210713092242.754717-1-dwrobel@ertelnet.rybnik.pl \
    --to=dwrobel@ertelnet.rybnik.pl \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=romanek.adam@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.