Commit Graph

24 Commits

Author SHA1 Message Date
Jinho Seo 046fc17e53 This change hardens DTD FileSystemService workspace-root enforcement against symlink escapes.
Previously, FileSystem.readFileAsString, writeFileAsString, and
listDirectoryContents only validated the requested path textually against the
configured IDE workspace roots. A symlink inside the workspace could
therefore resolve to a location outside the workspace and still be accessed.

This patch resolves workspace roots and requested filesystem targets before
performing the authorization check, and resolves the nearest existing ancestor
for write targets so new files inside a workspace continue to work.

It also adds a source-backed regression test in pkg/dtd_impl/test/dtd_test.dart
that verifies read, write, and directory listing requests through a symlink
escaping the workspace all fail with permission denied.

R=bquinlan@google.com

Tested:
- HOME=/tmp XDG_CONFIG_HOME=/tmp DART_SUPPRESS_ANALYTICS=1 /tmp/dart-sdk-3.12.0-221.0.dev/dart-sdk/bin/dart test pkg/dtd_impl/test/dtd_test.dart
Change-Id: I7abf00f6220bff42b352e2942f396167af53adb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493420
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Auto-Submit: 진호 <orangemush777@gmail.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2026-04-08 10:13:43 -07:00
Jake Macdonald 44b700e9f2 add IDE information from env vars to DTDConnectionInfo
See https://github.com/Dart-Code/Dart-Code/issues/5561 for info on these environment variables.

Bug: https://github.com/dart-lang/sdk/issues/62985
Change-Id: Ic65a3cc64bacfe7c13bbf512d3ed3f8a6b2e5ba9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492940
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2026-04-03 14:42:03 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
Jaime Wren 3846e59caf Enable stricter lints in dtd_impl using dart_flutter_team_lints
Change-Id: Ic630f00e1c608467f9c15b3a35f0ce28b8d8c94c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488880
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
2026-03-18 13:27:49 -07:00
Jaime Wren 7278245213 [dtd_impl] Fix race condition in pid_file_discovery_test
Increase the wait loop iteration count from 20 to 100 iterations (up to 5 seconds) inside `startDtdProcess()` to give the daemon ample time to create the PID file on slower bots.

Also: dart format changes.

Bug: https://github.com/dart-lang/sdk/issues/62872
Change-Id: I55ff087108fbae1f05491894b79ebc8d36030422
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488660
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
2026-03-18 07:39:12 -07:00
Jaime Wren 13e2321be3 [dtd_impl] Update PID file logic to use dart_data_home logic
See https://dart-review.googlesource.com/c/sdk/+/487000

Change-Id: I37d3ccc911041e56b5e3eeabc2aeaf4cde1785f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487543
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
2026-03-17 11:19:11 -07:00
Jaime Wren 049778a5b2 [dtd_impl] Replace dynamic type usages with strict types
Change-Id: Icf31ea11d50ffbb704214f6dbc17602e6777e0c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486861
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-03-10 14:32:41 -07:00
Jaime Wren 4a144e9969 [dtd] Verify DTD connection info contains correct workspace root
Change-Id: I7bc5302614f886217630d6206bc4ab289c421b43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486860
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
2026-03-10 11:28:31 -07:00
Jaime Wren ab678e0a24 [dtd] Implement PID-file based DTD instance discovery
See parent issue https://github.com/flutter/flutter/issues/182155

- Adds `dart run bin/dtd.dart --list` to discover and print active instances.
- Adds `--machine` flag to output the discovered instances as a JSON array.
- Adds integration tests verifying the file creation, discovery, `--machine` JSON output, and stale process cleanup.

Bug: https://github.com/flutter/flutter/issues/183421

Change-Id: I07f8c079ec0959cc0a292d7049e1cbb4d8280f41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486541
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-03-10 09:43:00 -07:00
Danny Tuppeny 4f377da9e3 Disable DTD WebSocket ping by default, making it opt-in
The WebSocket client that IntelliJ is using does not handle pings (despite them being part of the spec), so this change resulted in connections being dropped after 15s.

This changes pings to be opt-in, which unfortunately means other clients that don't opt-in won't get the behaviour (and therefore might see issues with Norton and other antivirus programs that proxy and drop idle connections), but this is better than all IJ users being broken.

See https://github.com/flutter/dart-intellij-third-party/issues/205

Change-Id: I7d5f5225cb9d04c15552970a821f5441c45ace18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472580
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-01-14 08:58:43 -08:00
Danny Tuppeny 5d3a0c2f3c [dtd] Enable web socket ping to avoid dropped idle connections
This enables the web socket ping by default at an interval of 15s. Having ping enables can prevent proxies/antivirus from dropping the web connections if they have no traffic for some period.

Having Norton 360 installed results in idle DTD connections dropping after 60s even if every feature is disabled, because the connections still go through it and it still drops idle connections.

I implemented this in the server because it applies to all uses of DTD regardless of client and it was easier to do here because pingInterval isn't exposed everywhere (but pkg:shelf does have a pass-through).

See https://github.com/Dart-Code/Dart-Code/issues/5794

Fixes https://github.com/dart-lang/sdk/issues/62148

Change-Id: If9df674b061b397cef1aa321602b563f44b9525d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465680
Reviewed-by: Jessy Yameogo <yjessy@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-12-09 10:42:23 -08:00
Kenzie Davisson 0010cc416f Use constants instead of raw strings throughout package:dtd
Change-Id: Ie4b0dfb115a820fb3f0741ce193c70f6b7d560cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432725
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-06-04 08:52:33 -07:00
Kenzie Davisson 10dd59c039 Add a DTD method to get all registered services.
This CL contains breaking changes for package:dtd and prepares both package:dart_service_protocol_shared and package:dtd for publish.

This CL also fixes https://github.com/dart-lang/sdk/issues/60757 so that DTD-registered services are sent over the `Service` stream upon initial subscription like what is done for client-registered services.

Change-Id: I619af816e64af01864c7ed9b98743c6691bf7e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429161
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Kenzie Davisson <kenzieschmoll@google.com>
2025-05-22 13:52:54 -07:00
Danny Tuppeny 44cc865f7d [dtd] Improve the error thrown when trying to call a service method without a complete name
This now behaves the same as for any other method that doesn't exist, rather than throwing a generic RPC error with a `RangeError` inside.

Fixes https://github.com/dart-lang/sdk/issues/56540

Change-Id: I1171fe1c0c2a4a6f56d7a653af87b17a76af9d68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381643
Reviewed-by: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-08-22 18:03:50 +00:00
Danny Tuppeny 15356d576d [dtd] Add a test a disconnecting DTD client results in error responses for any in-progress requests to them
This question came up in another change, about whether a client would have hanging requests if the other DTD client providing the service disconnected.

This adds a test to ensure that any pending requests are terminated with an error.

It also tidies up some other tests to give better errors if they fail.

Change-Id: I77e04ee59f757498af090878da542d6ed1d152b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374946
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
2024-07-16 18:45:53 +00:00
Danny Tuppeny 214088a7a0 [dtd] Prevent clients from using internal service names or dots in service names
See https://github.com/dart-lang/sdk/issues/56177

Change-Id: I9765f232e71026a0ae6ee2ce95248472fb69ba3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374980
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-07-11 15:59:23 +00:00
Danny Tuppeny 3c66c16122 [dtd] Move DTD implementation classes from lib/ to lib/src/ to avoid src/ files importing from lib/
Fixes https://github.com/dart-lang/sdk/issues/56178

Change-Id: I1f461e0f9c787e69eade7a5e4806c0a85bb23c23
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374981
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
2024-07-09 19:55:17 +00:00
Danny Tuppeny 23de3198fa Add support for notifying DTD clients of registered services
Fixes https://github.com/dart-lang/sdk/issues/56057

Change-Id: I57144297b8cb68b1c8b35d7bdcc619ad293fb4ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372940
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-07-08 16:12:21 +00:00
Danny Tuppeny 499277c690 [dtd] Add support for '--disable-service-auth-codes'
See https://github.com/dart-lang/sdk/issues/54932

Change-Id: Ie85eb76eb5e8c01dda957d038286ae498748ca70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373340
Reviewed-by: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-07-03 14:51:43 +00:00
Danny Tuppeny d209ea9333 [dtd] Allow passing an explicit port to DTD
Removes the port from `startService()` (which as far as I can see is unused) and parses it from `args` instead.

I had to add support for "options" in the argument classes and switched from a bool flag `isFlag` to an enum to be a bit more descriptive (and be easier to support multi-options in future if required).

Fixes https://github.com/dart-lang/sdk/issues/56000

Change-Id: Ib08513139f58e8845a7c2cbbeeea06787dbc2df1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371840
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-06-17 14:58:19 +00:00
Dan Chevalier 68c74e2a97 Add obfuscation token to DTD uri
Adding this token adds a small layer of security since the caller needs to have gathered the uri in some way rather than just stumbling on the DTD port.

Change-Id: I0665f4718d162daf94cb49fa1c6f4206c83d77cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355220
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-03-07 19:33:19 +00:00
Dan Chevalier 03f797a85a Solidify dtd lifecycle
- devtools server can now take the dtd uri as a parameter on startup
   - dtdUri is passed to the server handler so that devtools can request it.
- FileService is implemented inside the Dart Tooling Daemon (dtd_impl)
    - Added FileService.setProjectRoots
    - Added unit tests and rpc exceptions
- on startup dtd now prints { uri, secret } so that the caller has the secret that allows them to call FileService.setProjectRoots

Fixes: https://github.com/dart-lang/sdk/issues/54790

Change-Id: I7a66aca2f8f06f6a611a46c727a9d5c2485fbe3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346922
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Dan Chevalier <danchevalier@google.com>
2024-02-13 16:17:18 +00:00
Dan Chevalier a995f7930b Solidify, test and document DTD errors
Change-Id: Ied0f1af43954e47a2c51837bd2fc8d7ce0e03fa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345800
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2024-01-18 16:07:31 +00:00
Dan Chevalier a32d37ef84 Initial implementation of Dart Tooling Daemon server
This will contain the code for running the DTD server.

When this is fully funcitonal VSCode will be responsible for running the, and letting our other tools(i.e. DevTools) know which address it is running at.

Change-Id: Ia4cc9553f000a5e765f604541f4846b107d4d00c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338501
Commit-Queue: Dan Chevalier <danchevalier@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-12-15 15:05:09 +00:00