Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Korsgaard <peter@korsgaard.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] package/plg-utils: escape \ in generated legal-info
Date: Sun, 07 Feb 2021 10:35:44 +0100	[thread overview]
Message-ID: <87sg681aq7.fsf@dell.be.48ers.dk> (raw)
In-Reply-To: <20210206085102.1017439-1-yann.morin.1998@free.fr> (Yann E. MORIN's message of "Sat, 6 Feb 2021 09:51:02 +0100")

>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > In the output of legal-info, which is JSON-formatted, we include the
 > CPI_ID (when it is valid).

 > For xerces, the CPE_IS contains two sequences aof \+ (which is exactly
 > what is present in the NIST DB, [0]).

 > However, in JSON, like in C, \ escapes the following character; only a
 > very limited set of characters are valid to escape: " \ / b f n r t u.
 > Escaping any other character is invalid. Conformant JSON parser will
 > choke on invalid sequences, and so does not the json python module:

 >       File "/usr/lib/python2.7/json/decoder.py", line 380, in raw_decode
 >         obj, end = self.scan_once(s, idx)
 >     ValueError: Invalid \escape: line 1 column 608554 (char 608553)

 > We fix that be globally escaping \ in our json output, in the generic
 > sanitsing macro.

 > [0] https://nvd.nist.gov/products/cpe/detail/645?namingFormat=2.3&orderBy=CPEURI&keyword=xerces&status=FINAL

I still wonder if it wouldn't be better to not have the backslashes in
the variable and do whatever escaping is needed inside the CVE logic,
but OK - We need a quick fix and this solves it.

Perhaps we should add a gitlab test to verify that we generate valid
json, E.G. by piping it to jq (or similar).

Committed, thanks.

-- 
Bye, Peter Korsgaard

  reply	other threads:[~2021-02-07  9:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-06  8:51 [Buildroot] [PATCH] package/plg-utils: escape \ in generated legal-info Yann E. MORIN
2021-02-07  9:35 ` Peter Korsgaard [this message]
2021-02-07 11:28   ` Yann E. MORIN
2021-02-07 12:18     ` Peter Korsgaard
2021-02-07 13:17       ` Yann E. MORIN
2021-02-07 13:33       ` Yann E. MORIN
2021-02-07 14:21         ` Peter Korsgaard

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=87sg681aq7.fsf@dell.be.48ers.dk \
    --to=peter@korsgaard.com \
    --cc=buildroot@busybox.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox