Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprules html doesn't always generate parsable configs #4158
Comments
This comment has been minimized.
This comment has been minimized.
|
A fix for this could be to wrap everything in quotes, or just those with a leading (or trailing) |
adamdecaf
referenced this issue
May 11, 2018
Closed
"mapping values are not allowed in this context" error from promtool #14
This comment has been minimized.
This comment has been minimized.
|
This smells like a bug in the yaml library we use. |
brian-brazil
added
kind/bug
component/ui
labels
May 11, 2018
This comment has been minimized.
This comment has been minimized.
|
Probably that is because the YAML field value itself doesn't start with a colon, but with an HTML tag, only the browser then shows it as starting with a colon, since it interprets the HTML. Maybe we need to add some quoting ourselves around the actual text in the HTML. |
This comment has been minimized.
This comment has been minimized.
|
Relevant code piece: Lines 112 to 132 in b3ff5f6 |
This comment has been minimized.
This comment has been minimized.
|
Ah, we're doing our own escaping rather than relying on Go templates. We should probably switch this to Go templates, as they have protections for this sort of thing. |
This comment has been minimized.
This comment has been minimized.
|
The problem here is not an HTML escaping issue though, but a YAML field escaping issue. Basically we want to make the YAML field value a link, so we have to interpret it as HTML, but the YAML library doesn't know this. |
This comment has been minimized.
This comment has been minimized.
|
In either case, I propose we not pass in a blob to template.HTML and hope it gets it right and instead use template.HTML in the way it was designed. |
This comment has been minimized.
This comment has been minimized.
|
The problem is that we have three nesting layers: HTML in YAML in HTML. If we don't handle the inner HTML layer ourselves, then we also need to handle the YAML layer in the Go template. So probably best keep handling the inner HTML ourselves. |
This comment has been minimized.
This comment has been minimized.
|
I propose that we get rid of two of the layers, and do this all up in |
This comment has been minimized.
This comment has been minimized.
|
It's still going to be layered in this way with the same issues no matter where we handle it though? Unless we get rid of the HTML linking within the YAML completely, which I don't think is the plan. |
This comment has been minimized.
This comment has been minimized.
|
No, we can render it entirely inside one template rather than spreading the logic around. |
This comment has been minimized.
This comment has been minimized.
|
Hm, how would that work? Since Go templates are rather primitive in what they can do directly, don't you still need the same kind of external helper functions that do the initial HTML-in-YAML wrapping? |
This comment has been minimized.
This comment has been minimized.
|
We only need to make it look like YAML, and the structure is pretty simple and unchanging. |
This comment has been minimized.
This comment has been minimized.
|
Heh ok, had that possibility in my mind as well of course, but I thought we wouldn't want to go down that road because that seems too dirty (e.g. when we're going to add rule options or other fields, those need to be added to the custom marshaling there too). Well, let's see who actually sends a fix, I still like the idea of manually escaping the YAML field value more :) |
This comment has been minimized.
This comment has been minimized.
|
I'd rather risk missing some fields when we make a change than introducing an XSS. |
adamdecaf commentedMay 11, 2018
•
edited
Bug Report
What did you do?
Recording rules can have
:on either the front of end of their name. Without quotes in yaml this leads to a parsing error.Example:

Running
promtool(or prometheus) over the following gives an error:What did you expect to see?
I expected for the HTML rules output to be a valid config.
Environment
2.2.1