You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use structured json instead of on-the-fly construction of a JSON string
to avoid json member injection.
This also moves all non-URSim tests for the RobotAPI in a standalone
test file.
This prevents errors and vulnerabilities resulting from a dashboard server responding
with an illegal version string. An unexpected response could potentially
crash the client. With this fix applied, it throws a UrException instead
making this able to resolve. E.g. during G5 client startup we query the version.
If that throws now, connect() returns false instead of the application crashing.
This change does
- make sure the given program name doesn't lead to path traversal on the URL
- verify that the received response does contain something that looks like a program
- make sure the file is written atomically through a tempfile to avoid following pre-placed symlinks
High Risk
Changes authentication-adjacent connect flows, URL/JSON construction from user input, and file download semantics—incorrect validation could break integrations or leave residual security gaps.
Overview
Hardens the dashboard client against malformed robot responses and unsafe use of caller-supplied program names, with the largest behavioral changes in the PolyScope X (DashboardClientImplX) path.
Connection and version handling:connect() on G5 and X now treats bad version discovery (empty/malformed PolyScope replies or invalid Robot API JSON/version strings) as a failed connection (false) instead of leaking non-library exceptions. G5 uses shared token extraction before VersionInformation::fromString(). Version parsing is stricter (2–4 digit-only uint32 components, mixed ./- separators) and is aligned with script reader version literals.
PolyScope X request safety: Robot API JSON goes through a wrapper that maps parse failures to UrException. Load program bodies are built with nlohmann::json instead of string concatenation. Download program rejects path traversal (including multi-pass percent decoding), verifies the payload is a program export with a matching name, and persists via new writeFileAtomically() (exclusive temp file + rename). Docs note unauthenticated dashboard TCP exposure.
Tests: G5 welcome/version connect tests, expanded version/helper coverage, connect-timeout slack, and mock Robot API tests moved into always-built dashboard_client_x_unit_tests.
Reviewed by Cursor Bugbot for commit 0dc1c43. Bugbot is set up for automated code reviews on this repo. Configure here.
❌ Patch coverage is 83.85650% with 36 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.07%. Comparing base (3ead504) to head (0dc1c43).
✅ All tests successful. No failed tests found.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Downloads can silently overwrite the destination with an unverified or wrong program because missing export identities are accepted and percent-decoding alters the requested program name.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
JSON serialization failures bypass the expected UrException contract, while temporary-file handling rejects valid long filenames and can replace destinations despite close errors.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Use a short temporary basename for saved files
src/helpers.cpp:318
Appending seven characters to the complete destination basename rejects otherwise valid save paths near the filesystem's filename limit. On a filesystem with a 255-byte limit, a 255-byte destination can be created normally, but this temporary filename fails with ENAMETOOLONG, so program downloads that previously worked now fail. Use a short, fixed-length temporary basename in the destination directory instead.
Handle close failures before replacing the destination
src/helpers.cpp:335
Please check the close result before renaming the temporary file. Filesystems such as NFS can report delayed I/O, quota, or space errors from close() even after write() returned the full byte count. Currently those failures still replace the existing destination and return success. Treat a failed close as a write failure and clean up the temporary file; check _close() in the Windows branch too.
dump() uses strict UTF-8 validation, so a caller-supplied name containing an invalid byte (for example, std::string(1, '\xff')) now throws nlohmann::json::type_error before sending the request. This exception passes through both public load-program wrappers unchanged and bypasses callers that handle UrException. Translate serialization failures into UrException, as the new response parser does, and cover malformed UTF-8 in the serialization tests.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The atomic-write helper can silently replace an existing destination with an empty file for 4 GiB inputs on 64-bit Windows and incorrectly report success.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Atomic saves can reject valid long filenames or replace destinations despite close failures, invalid UTF-8 leaks third-party exceptions, and unguarded symlink tests can fail on Windows.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate a version-parsing edge case that silently accepts malformed replies, allowing connection and version commands to report success.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Write or close failures can return an empty error message when temporary-file cleanup succeeds, also causing the message assertion in writeFileAtomicallyWriteError to fail.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The stricter parser rejects build-suffix literals still passed by ScriptReader, aborting script generation; the caller needs normalization and a regression test.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Version parsing normalizes every hyphen without validating placement, allowing both dashboard connection paths to accept malformed replies such as 5-12-0 and 5.12-0.123.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because a critical version-ordering inconsistency can make both comparison directions return true and select the wrong script branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds hardening of the dasboard client (Mainly the x-implementation) to avoid escapes from string replacements.
This affects