-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Values injected into the template should be escaped #258
Comments
Unfortunately, I think that this is a bug. This is related to issue #257. However, it might be possible to get around this by escaping the body in the interceptor, and passing the escaped body out of the interceptor? |
Oh interesting! Maybe that'll work 🤔 that means I'd have to write it in a service tho - i feel like fixing it might be easier XD. This was for a POC I was putting together, if the bug's still around when i get back to it I'll try that out @ncskier :pray :D |
Just like with reconcilers / controllers, adding functions of as members of the Sink (or controller) object itself has some downsides: it's hard to tell what the responsibilities of the functions are and how they are coupled to the Sink, and it's harder to write more focused unit tests. I am working on tektoncd#258 in another branch and in that branch I wanted to make some updates to the unit tests for this logic; it's easier to do if it's factored out a bit. There is more factoring we can do here: now that the functions are moved out of Sink we can make decisions around their interfaces and maybe make them even more focused and unit testable. (Though it was a happy surprise to see they were unit tested even though they were members of Sink!)
Just like with reconcilers / controllers, adding functions of as members of the Sink (or controller) object itself has some downsides: it's hard to tell what the responsibilities of the functions are and how they are coupled to the Sink, and it's harder to write more focused unit tests. I am working on tektoncd#258 in another branch and in that branch I wanted to make some updates to the unit tests for this logic; it's easier to do if it's factored out a bit. There is more factoring we can do here: now that the functions are moved out of Sink we can make decisions around their interfaces and maybe make them even more focused and unit testable. (Though it was a happy surprise to see they were unit tested even though they were members of Sink!) Also change usage of xerrors to fmt.Errorf since we're using >= go 1.13 now and we get the error wrapping for free :D
Just like with reconcilers / controllers, adding functions of as members of the Sink (or controller) object itself has some downsides: it's hard to tell what the responsibilities of the functions are and how they are coupled to the Sink, and it's harder to write more focused unit tests. I am working on tektoncd#258 in another branch and in that branch I wanted to make some updates to the unit tests for this logic; it's easier to do if it's factored out a bit. There is more factoring we can do here: now that the functions are moved out of Sink we can make decisions around their interfaces and maybe make them even more focused and unit testable. (Though it was a happy surprise to see they were unit tested even though they were members of Sink!) Also change usage of xerrors to fmt.Errorf since we're using >= go 1.13 now and we get the error wrapping for free :D
Just like with reconcilers / controllers, adding functions of as members of the Sink (or controller) object itself has some downsides: it's hard to tell what the responsibilities of the functions are and how they are coupled to the Sink, and it's harder to write more focused unit tests. I am working on #258 in another branch and in that branch I wanted to make some updates to the unit tests for this logic; it's easier to do if it's factored out a bit. There is more factoring we can do here: now that the functions are moved out of Sink we can make decisions around their interfaces and maybe make them even more focused and unit testable. (Though it was a happy surprise to see they were unit tested even though they were members of Sink!) Also change usage of xerrors to fmt.Errorf since we're using >= go 1.13 now and we get the error wrapping for free :D
Just like with reconcilers / controllers, adding functions of as members of the Sink (or controller) object itself has some downsides: it's hard to tell what the responsibilities of the functions are and how they are coupled to the Sink, and it's harder to write more focused unit tests. I am working on tektoncd#258 in another branch and in that branch I wanted to make some updates to the unit tests for this logic; it's easier to do if it's factored out a bit. There is more factoring we can do here: now that the functions are moved out of Sink we can make decisions around their interfaces and maybe make them even more focused and unit testable. (Though it was a happy surprise to see they were unit tested even though they were members of Sink!)
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes tektoncd#258 Co-authored-by: Dibyo Mukherjee <[email protected]>
I was trying to use Triggers to deliver a payload that included some newlines and carriage returns into the value of a Pipeline param, but along the way they were being turned from actual \ + n to the newline character, etc., which when embedded into the yaml of the CRD I wanted to create was invalid. Now we will treat json strings as json when using the values via json path instead of decoding the the escaped characters. Dropping the quotation marks seems like a pretty big hack but it's the best option we could think of and seems to consistently give us the results we'd expect as users. In the end to end test, when json dictionaries are passed through an EventListener, the order may change, so we are deserializing the example data so that we can compare it in an order agnostic manner. Fixes #258 Co-authored-by: Dibyo Mukherjee <[email protected]>
Expected Behavior
It should be possible for me to pass along the body of a github pull request event to a TaskRun + Task.
Actual Behavior
When I'm trying to trigger from a pull request and pass along the description of the pull request to a Task, I run into trouble b/c the description contains characters like
\r
and\n
and I can't figure out how to escape this in the template properly :SSteps to Reproduce the Problem
Example trigger binding I was using:
Here is an example of the body field of the pull request:
Here is the template I was trying to use:
I end up with an error like:
Additional Info
I can't tell if this is a bug or (I'm hoping!) there is some way I can specify the
$(params.body)
in the trigger template such that the values being passed along can be properly escaped.The text was updated successfully, but these errors were encountered: