Skip to content
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

feat(mocknet): change HTTP request logic #10023

Merged
merged 3 commits into from
Oct 30, 2023

Conversation

marcelo-gonzalez
Copy link
Contributor

We'll change things to bind to "localhost" instead of "0.0.0.0", and make HTTP requests by SSH + curl on the remote server. It's also possible to set up an explicit SSH/SOCKS proxy, but that would require one for each server and would be long-lived, which might be a bit annoying for people running the test scripts

We'll change things to bind to "localhost" instead of "0.0.0.0", and
make HTTP requests by SSH + curl on the remote server. It's also possible
to set up an explicit SSH/SOCKS proxy, but that would require one for each
server and would be long-lived, which might be a bit annoying for people
running the test scripts
@marcelo-gonzalez marcelo-gonzalez requested a review from a team as a code owner October 27, 2023 18:03
Copy link
Collaborator

@Ekleog-NEAR Ekleog-NEAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security-wise this seems good. I just submitted a comment for an issue I saw, I’ll let @wacban make the call on whether, from a code standpoint, this approach is the best one :)

'jsonrpc': '2.0'
}
body = json.dumps(body)
r = run_cmd(node, f'curl localhost:3000 -d \'{body}\'')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that’s important? but here if method or params contain a quote, then this will fail. Might need to replace all ' in body with '"'"' first

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would feel slightly better with some escaping provided by a library but as long as this works it's ok.

Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks for fixing!

pytest/tests/mocknet/helpers/neard_runner.py Show resolved Hide resolved
'jsonrpc': '2.0'
}
body = json.dumps(body)
r = run_cmd(node, f'curl localhost:3000 -d \'{body}\'')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would feel slightly better with some escaping provided by a library but as long as this works it's ok.

@marcelo-gonzalez marcelo-gonzalez added this pull request to the merge queue Oct 30, 2023
Merged via the queue into near:master with commit dfc1d80 Oct 30, 2023
@marcelo-gonzalez marcelo-gonzalez deleted the mirror branch October 30, 2023 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants