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

Replace ncat.exe with a dedicated TCP broker supporting zero-delimited framing #300

Open
emrainey opened this issue Jun 1, 2023 · 7 comments
Assignees

Comments

@emrainey
Copy link
Contributor

emrainey commented Jun 1, 2023

This was flagged by a corporate security audit when I downloaded pycyphal. While I'm on a Mac and I can't directly run this, it does beg the question, why is this needed here?

@pavel-kirienko
Copy link
Member

It is necessary for testing Cyphal/serial on Windows. On GNU/Linux, it is installed as a package during CI workflow execution, but there is no clean way of doing so for Windows that I could find. Here is how it's used:

pycyphal/noxfile.py

Lines 18 to 20 in de11875

DEPS_DIR = ROOT_DIR / ".test_deps"
assert DEPS_DIR.is_dir(), "Invalid configuration"
os.environ["PATH"] += os.pathsep + str(DEPS_DIR)

broker_process = subprocess.Popen(["ncat", "--broker", "--listen", "-p", "50905"], env=session.env)

If you have a better solution in mind, please send a pull request; for now I am closing this. Also, keep in mind that the default Windows security policies tend to misidentify ncat.exe as a "hacking tool"...

@thirtytwobits
Copy link
Member

There's got to be a python solution available here?

@thirtytwobits thirtytwobits reopened this Jun 2, 2023
@pavel-kirienko
Copy link
Member

A contribution changing ncat.exe to something else would be accepted.

@thirtytwobits
Copy link
Member

@emrainey , do you think we could replace this function with a Python library?

@emrainey
Copy link
Contributor Author

Likely we could with a raw socket over UDP? Looks like there are some minor implementation on stack overflow. https://stackoverflow.com/questions/1908878/netcat-implementation-in-python.

ChatGPT could probably pound out an implementation in no time. :)

@pavel-kirienko
Copy link
Member

This is just a TCP broker that bridges all connections accepted through some specified port; it can be implemented easily. Note that it has to be TCP, not UDP.

@pavel-kirienko
Copy link
Member

While we're at it, we should also use zero-byte frame delimiters on each connection to prevent output-queue mangling. This is an issue with ncat.exe that complicates the testing of larger networks.

@pavel-kirienko pavel-kirienko changed the title Do we need NCAT.exe ? Replace ncat.exe with a dedicated TCP broker supporting zero-delimited framing Aug 29, 2023
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

No branches or pull requests

3 participants