-
Notifications
You must be signed in to change notification settings - Fork 253
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
Adding transaction_call endpoint #832
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #832 +/- ##
==========================================
- Coverage 60.81% 60.33% -0.49%
==========================================
Files 220 220
Lines 23414 23763 +349
==========================================
+ Hits 14240 14338 +98
- Misses 8007 8241 +234
- Partials 1167 1184 +17 ☔ View full report in Codecov by Sentry. |
This pull request has been marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions. |
6e7853e
to
da734f1
Compare
} | ||
} | ||
|
||
return c.ResponseWriter.Write(b) |
Check warning
Code scanning / CodeQL
Reflected cross-site scripting Medium
user-provided value
Cross-site scripting vulnerability due to
user-provided value
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the reflected cross-site scripting vulnerability, we need to ensure that any user input is properly sanitized or escaped before being written to the HTTP response. In this case, we can use the html.EscapeString
function from the html
package to escape any potentially dangerous characters in the user input.
- We will modify the
Write
method incallTxResponseWriter
to escape the user input before writing it to the response. - Specifically, we will escape the
VMError
field in theresp
struct before writing the response.
-
Copy modified line R20 -
Copy modified line R68
@@ -19,2 +19,3 @@ | ||
"github.com/vechain/thor/v2/metrics" | ||
"html" | ||
) | ||
@@ -66,3 +67,3 @@ | ||
if resp.VMError != "" { | ||
c.VMError = resp.VMError | ||
c.VMError = html.EscapeString(resp.VMError) | ||
} |
@@ -300,6 +301,25 @@ func TestClient_GetTransaction(t *testing.T) { | |||
assert.Equal(t, expectedTx, tx) | |||
} | |||
|
|||
func TestClient_CallTransaction(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we also add negative tests ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can but those are mock tests afaik. So not sure what the benefit of returning a hardcoded "error" response will be and checking if its what we expect.
Description
This PR adds a new endpoint that allows to simulate and estimate based on transactions instead of clauses.
The added value is to bring api communication to the transaction level. This allows for gotchas like, chaintag, expiration, nonce, etc to be more visible and allows executing transactions in a given block revision
Summary of the endpoint:
Goal: Execute a transaction at the head of a specified block. Retrieve the total gas cost at the transaction level.
(Note: Can be expanded to execute in a block at a given tx position.)
Fixes # (issue)
Type of change
How Has This Been Tested?
Checklist: