package/plg-utils: escape \ in generated legal-info
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
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.
--- package/pkg-utils.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
package/pkg-utils.mk +2 -1
@@ -171,8 +171,9 @@ endef clean-json = $(strip \ $(subst $(comma)},}, $(subst $(comma)$(space)},$(space)}, \ $(subst $(comma)],], $(subst $(comma)$(space)],$(space)], \ + $(subst \,\\, \ $(strip $(1)) \ - )))) \ + ))))) \ ) ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
Signature · 1 line
2.25.1
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
In the output of legal-info, which is JSON-formatted, we include the
CPI_ID(when it is valid).For xerces, the
CPE_IScontains 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:
Quoted 8 lines
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.
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.
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
Peter, All,
On 2021-02-07 10:35 +0100, Peter Korsgaard spake thusly:
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
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,
I think quite the opposite, in fact: we want the CPE_ID value to be exactly what is in the NVD database without any mangling on our side.
The rules to encode the CPE stuff are non-trivial at least to me), requiring some escaping/de-escaping in the various formats, and with different rules for the attributes and their representation
All is defined in NISTIR 7695 [0], in the following chapters:
5.3.2 - Restrictions on attribute-value strings 6.2.1 - Syntax for Formatted String Binding
[0] https://doi.org/10.6028/NIST.IR.7695
Quoted 4 lines
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).
Yeah, I'm working on it... But we can't do that in gitlab, because the output of show-info depends on the selected packages, so it would have to be done in the autobuilders.
Quoted 1 line
Committed, thanks.
Thanks.
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2021-02-07 10:35 +0100, Peter Korsgaard spake thusly:Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
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,
I think quite the opposite, in fact: we want the
CPE_IDvalue to be exactly what is in the NVD database without any mangling on our side.The rules to encode the CPE stuff are non-trivial at least to me), requiring some escaping/de-escaping in the various formats, and with different rules for the attributes and their representation
Quoted 5 lines
All is defined in NISTIR 7695 [0], in the following chapters:
5.3.2 - Restrictions on attribute-value strings 6.2.1 - Syntax for Formatted String Binding
Ok.
Quoted 8 lines
Quoted 4 lines
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).
Yeah, I'm working on it... But we can't do that in gitlab, because the output of show-info depends on the selected packages, so it would have to be done in the autobuilders.
But that then requires jq on the autobuilder. Can't we just do a 'make allyespackageconfig' in gitlab?
Signature · 1 line
Bye, Peter Korsgaard
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
Peter, All,
On 2021-02-07 13:18 +0100, Peter Korsgaard spake thusly:
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Perhaps we should add a gitlab test to verify that we generate valid json, E.G. by piping it to jq (or similar).
Yeah, I'm working on it... But we can't do that in gitlab, because the output of show-info depends on the selected packages, so it would have to be done in the autobuilders.
But that then requires jq on the autobuilder. Can't we just do a 'make allyespackageconfig' in gitlab?
We don't have jq in our current base image either... We can push a new image, though.
As for the autobuilders, we can build host-jq...
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
In reply to Peter KorsgaardPeter, All,
On 2021-02-07 13:18 +0100, Peter Korsgaard spake thusly:
Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2021-02-07 10:35 +0100, Peter Korsgaard spake thusly:Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Perhaps we should add a gitlab test to verify that we generate valid json, E.G. by piping it to jq (or similar).
Yeah, I'm working on it... But we can't do that in gitlab, because the output of show-info depends on the selected packages, so it would have to be done in the autobuilders.
But that then requires jq on the autobuilder. Can't we just do a 'make allyespackageconfig' in gitlab?
So, allyespackageconfig is not buildable:
package/luajit/luajit.mk:77: *** Configuration error: both "luajit" and "lua" are selected as providers for virtual package "luainterpreter". Only one provider can be selected at a time. Please fix your configuration. Stop.
Solving this means reimplementing parts of the logic in the autobuilders... So I still think it would be better to augment the autobuilder script to run and validate show-info against a valid configuration...
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/1 package/plg-utils: escape \ in generated legal-info
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2021-02-07 13:18 +0100, Peter Korsgaard spake thusly:Quoted 11 lines
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Peter, All,
On 2021-02-07 10:35 +0100, Peter Korsgaard spake thusly:Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
Perhaps we should add a gitlab test to verify that we generate valid json, E.G. by piping it to jq (or similar).
Yeah, I'm working on it... But we can't do that in gitlab, because the output of show-info depends on the selected packages, so it would have to be done in the autobuilders.
But that then requires jq on the autobuilder. Can't we just do a 'make allyespackageconfig' in gitlab?
Quoted 6 lines
So, allyespackageconfig is not buildable:
package/luajit/luajit.mk:77: *** Configuration error: both "luajit" and "lua" are selected as providers for virtual package "luainterpreter". Only one provider can be selected at a time. Please fix your configuration. Stop.
:/
Quoted 4 lines
Solving this means reimplementing parts of the logic in the autobuilders... So I still think it would be better to augment the autobuilder script to run and validate show-info against a valid configuration...
That is also fine by me.
Signature · 1 line
Bye, Peter Korsgaard