internal/perms: Fix grant parser bugs (#3660)

* internal/perms: Fix grant parser bugs

This fixes two bugs in the grant parser:

1. The parser would accept "," as an output field when parsing from JSON.
  This would then make it into the canonical string,
  which would make it look like we had a trailing comma.
  Disallow the use of a comma as an output field.
2. The parser would accept empty IDs when parsing from JSON.
  Make this behavior consistent with the text behavior.

* internal/perms: also handle empty IDs in text form

* internal/perms: disallow any commas

Commas anywhere in ids or output fields corrupt
the canonical output string.

* internal/perms: disallow any reserved characters

id, ids and actions could all contain one of the
reserved characters ",", "=" or ";" when used with
JSON.
This commit is contained in:
Johan Brandhorst-Satzkorn authored and GitHub committed 2023-09-06 09:11:56 -07:00
1 parent 69bafbd4e0
commit a73db844fe
9 files changed
+214 -2

No files matched your search

@@ -0,0 +1,2 @@
go test fuzz v1
string("ids=,;actions=reAd")
@@ -0,0 +1,2 @@
go test fuzz v1
string("{\"output_fields\":[\",\"]}")
@@ -0,0 +1,2 @@
go test fuzz v1
string("{\"id\":\"=\",\"actions\":[\"reAd\"]}")
@@ -0,0 +1,2 @@
go test fuzz v1
string("{\"ids\":[\",00\"],\"actions\":[\"CreAte\"]}")
@@ -0,0 +1,2 @@
go test fuzz v1
string("id=,;output_fields=0")
@@ -0,0 +1,2 @@
go test fuzz v1
string("id=,0;output_fields=0")
@@ -0,0 +1,2 @@
go test fuzz v1
string("{\"ids\":[\"\"],\"actions\":[\"CreAte\"]}")