@@ -151,10 +151,18 @@ open class CoderProtocolHandler(
151
151
isInitialized.waitForTrue()
152
152
reInitialize(restClient, cli)
153
153
154
+ val environmentId = " ${workspace.name} .${agent.name} "
154
155
context.cs.launch {
155
156
context.ui.showWindow()
156
157
context.envPageManager.showPluginEnvironmentsPage(true )
157
- context.envPageManager.showEnvironmentPage(" ${workspace.name} .${agent.name} " , false )
158
+ context.envPageManager.showEnvironmentPage(environmentId, false )
159
+ val productCode = params.ideProductCode()
160
+ val buildNumber = params.ideBuildNumber()
161
+ if (! productCode.isNullOrBlank() && ! buildNumber.isNullOrBlank()) {
162
+ val ideVersion = " $productCode -$buildNumber "
163
+ context.logger.info(" installing $ideVersion on $environmentId " )
164
+ context.ideOrchestrator.prepareClient(environmentId, ideVersion)
165
+ }
158
166
// without a yield or a delay(0) the env page does not show up. My assumption is that
159
167
// the coroutine is finishing too fast without giving enough time to compose main thread
160
168
// to catch the state change. Yielding gives other coroutines the chance to run
@@ -228,73 +236,6 @@ open class CoderProtocolHandler(
228
236
return client
229
237
}
230
238
231
- /* *
232
- * Check that the link is allowlisted. If not, confirm with the user.
233
- */
234
- private suspend fun verifyDownloadLink (parameters : Map <String , String >) {
235
- val link = parameters.ideDownloadLink()
236
- if (link.isNullOrBlank()) {
237
- return // Nothing to verify
238
- }
239
-
240
- val url =
241
- try {
242
- link.toURL()
243
- } catch (ex: Exception ) {
244
- throw IllegalArgumentException (" $link is not a valid URL" )
245
- }
246
-
247
- val (allowlisted, https, linkWithRedirect) =
248
- try {
249
- isAllowlisted(url)
250
- } catch (e: Exception ) {
251
- throw IllegalArgumentException (" Unable to verify $url : $e " )
252
- }
253
- if (allowlisted && https) {
254
- return
255
- }
256
-
257
- val comment =
258
- if (allowlisted) {
259
- " The download link is from a non-allowlisted URL"
260
- } else if (https) {
261
- " The download link is not using HTTPS"
262
- } else {
263
- " The download link is from a non-allowlisted URL and is not using HTTPS"
264
- }
265
-
266
- if (! dialogUi.confirm(
267
- context.i18n.ptrl(" Confirm download URL" ),
268
- context.i18n.pnotr(" $comment . Would you like to proceed to $linkWithRedirect ?" ),
269
- )
270
- ) {
271
- throw IllegalArgumentException (" $linkWithRedirect is not allowlisted" )
272
- }
273
- }
274
- }
275
-
276
- /* *
277
- * Return if the URL is allowlisted, https, and the URL and its final
278
- * destination, if it is a different host.
279
- */
280
- private fun isAllowlisted (url : URL ): Triple <Boolean , Boolean , String > {
281
- // TODO: Setting for the allowlist, and remember previously allowed
282
- // domains.
283
- val domainAllowlist = listOf (" intellij.net" , " jetbrains.com" )
284
-
285
- // Resolve any redirects.
286
- val finalUrl = resolveRedirects(url)
287
-
288
- var linkWithRedirect = url.toString()
289
- if (finalUrl.host != url.host) {
290
- linkWithRedirect = " $linkWithRedirect (redirects to to $finalUrl )"
291
- }
292
-
293
- val allowlisted =
294
- domainAllowlist.any { url.host == it || url.host.endsWith(" .$it " ) } &&
295
- domainAllowlist.any { finalUrl.host == it || finalUrl.host.endsWith(" .$it " ) }
296
- val https = url.protocol == " https" && finalUrl.protocol == " https"
297
- return Triple (allowlisted, https, linkWithRedirect)
298
239
}
299
240
300
241
/* *
0 commit comments