Skip to content

Commit

Permalink
[Wasm] Explicitly allow insecure protocols for download js tools
Browse files Browse the repository at this point in the history
^KT-66388 fixed
  • Loading branch information
ilgonmic authored and qodana-bot committed Dec 13, 2024
1 parent 87b9ce0 commit ee56193
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2927,6 +2927,7 @@ public abstract interface annotation class org/jetbrains/kotlin/gradle/swiftexpo
}

public abstract interface class org/jetbrains/kotlin/gradle/targets/js/AbstractEnv {
public abstract fun getAllowInsecureProtocol ()Z
public abstract fun getCleanableStore ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public abstract fun getDir ()Ljava/io/File;
public abstract fun getDownload ()Z
Expand Down Expand Up @@ -2955,6 +2956,7 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask :
public fun <init> (Lorg/jetbrains/kotlin/gradle/targets/js/EnvSpec;)V
public final fun exec ()V
public abstract fun extract (Ljava/io/File;)V
public final fun getAllowInsecureProtocol ()Lorg/gradle/api/provider/Provider;
protected abstract fun getArtifactModule ()Ljava/lang/String;
protected abstract fun getArtifactName ()Ljava/lang/String;
protected abstract fun getArtifactPattern ()Ljava/lang/String;
Expand All @@ -2974,6 +2976,7 @@ public final class org/jetbrains/kotlin/gradle/targets/js/AbstractSetupTask$Comp

public abstract class org/jetbrains/kotlin/gradle/targets/js/EnvSpec {
public fun <init> ()V
public abstract fun getAllowInsecureProtocol ()Lorg/gradle/api/provider/Property;
public abstract fun getCommand ()Lorg/gradle/api/provider/Property;
public abstract fun getDownload ()Lorg/gradle/api/provider/Property;
public abstract fun getDownloadBaseUrl ()Lorg/gradle/api/provider/Property;
Expand Down Expand Up @@ -3147,17 +3150,19 @@ public final class org/jetbrains/kotlin/gradle/targets/js/UtilsKt {
}

public final class org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv : org/jetbrains/kotlin/gradle/targets/js/AbstractEnv {
public fun <init> (ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)V
public fun <init> (ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)V
public final fun component1 ()Z
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component3 ()Z
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()Ljava/io/File;
public final fun component6 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component7 ()Z
public final fun copy (ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;ZILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Ljava/io/File;
public final fun component7 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component8 ()Z
public final fun copy (ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;ZILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenEnv;
public fun equals (Ljava/lang/Object;)Z
public fun getAllowInsecureProtocol ()Z
public fun getCleanableStore ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public fun getDir ()Ljava/io/File;
public fun getDownload ()Z
Expand Down Expand Up @@ -3240,17 +3245,19 @@ public final class org/jetbrains/kotlin/gradle/targets/js/binaryen/BinaryenSetup
}

public final class org/jetbrains/kotlin/gradle/targets/js/d8/D8Env : org/jetbrains/kotlin/gradle/targets/js/AbstractEnv {
public fun <init> (ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)V
public fun <init> (ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)V
public final fun component1 ()Z
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Ljava/lang/String;
public final fun component3 ()Z
public final fun component4 ()Ljava/lang/String;
public final fun component5 ()Ljava/io/File;
public final fun component6 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component7 ()Z
public final fun copy (ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;ZILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;
public final fun component5 ()Ljava/lang/String;
public final fun component6 ()Ljava/io/File;
public final fun component7 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component8 ()Z
public final fun copy (ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Z)Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;ZLjava/lang/String;ZLjava/lang/String;Ljava/lang/String;Ljava/io/File;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;ZILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/d8/D8Env;
public fun equals (Ljava/lang/Object;)Z
public fun getAllowInsecureProtocol ()Z
public fun getCleanableStore ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public fun getDir ()Ljava/io/File;
public fun getDownload ()Z
Expand Down Expand Up @@ -4031,8 +4038,9 @@ public final class org/jetbrains/kotlin/gradle/targets/js/ir/WebpackConfigurator
}

public final class org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv : org/jetbrains/kotlin/gradle/targets/js/AbstractEnv {
public fun <init> (ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
public fun <init> (ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V
public final fun component1 ()Z
public final fun component10 ()Z
public final fun component2 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component3 ()Ljava/io/File;
public final fun component4 ()Ljava/io/File;
Expand All @@ -4041,9 +4049,10 @@ public final class org/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv : org
public final fun component7 ()Ljava/lang/String;
public final fun component8 ()Ljava/lang/String;
public final fun component9 ()Ljava/lang/String;
public final fun copy (ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;
public final fun copy (ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/nodejs/NodeJsEnv;
public fun equals (Ljava/lang/Object;)Z
public fun getAllowInsecureProtocol ()Z
public final fun getArchitectureName ()Ljava/lang/String;
public fun getCleanableStore ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public fun getDir ()Ljava/io/File;
Expand Down Expand Up @@ -5700,21 +5709,23 @@ public abstract class org/jetbrains/kotlin/gradle/targets/js/yarn/YarnBasics : o
}

public final class org/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv : org/jetbrains/kotlin/gradle/targets/js/AbstractEnv {
public fun <init> (ZLjava/lang/String;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;)V
public fun <init> (ZLjava/lang/String;ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;)V
public final fun component1 ()Z
public final fun component10 ()Z
public final fun component11 ()Ljava/util/List;
public final fun component11 ()Z
public final fun component12 ()Ljava/util/List;
public final fun component2 ()Ljava/lang/String;
public final fun component3 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component4 ()Ljava/io/File;
public final fun component5 ()Ljava/lang/String;
public final fun component3 ()Z
public final fun component4 ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public final fun component5 ()Ljava/io/File;
public final fun component6 ()Ljava/lang/String;
public final fun component7 ()Z
public final fun component8 ()Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;
public final fun component9 ()Z
public final fun copy (ZLjava/lang/String;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;)Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;ZLjava/lang/String;Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;
public final fun component7 ()Ljava/lang/String;
public final fun component8 ()Z
public final fun component9 ()Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;
public final fun copy (ZLjava/lang/String;ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;)Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;
public static synthetic fun copy$default (Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;ZLjava/lang/String;ZLorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ZLorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnLockMismatchReport;ZZLjava/util/List;ILjava/lang/Object;)Lorg/jetbrains/kotlin/gradle/targets/js/yarn/YarnEnv;
public fun equals (Ljava/lang/Object;)Z
public fun getAllowInsecureProtocol ()Z
public fun getCleanableStore ()Lorg/jetbrains/kotlin/gradle/tasks/internal/CleanableStore;
public fun getDir ()Ljava/io/File;
public fun getDownload ()Z
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ interface AbstractEnv {

val downloadBaseUrl: String?

val allowInsecureProtocol: Boolean

val ivyDependency: String

val dir: File
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package org.jetbrains.kotlin.gradle.targets.js
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.provider.Property
import org.gradle.api.provider.Provider
import org.gradle.api.provider.ProviderFactory
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnEnv

/**
* Instance which describes specific runtimes for JS and Wasm targets
Expand All @@ -26,6 +24,14 @@ abstract class EnvSpec<T : AbstractEnv> {
*/
abstract val downloadBaseUrl: Property<String>

/**
* Indicates whether the use of an insecure protocol is allowable for downloading the tool.
*
* This property determines if insecure protocols (such as HTTP instead of HTTPS) can be permitted
* for downloading the required tool.
*/
abstract val allowInsecureProtocol: Property<Boolean>

/**
* Specify where the tool is installed
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ abstract class AbstractSetupTask<Env : AbstractEnv, Spec : EnvSpec<Env>>(
it.downloadBaseUrl
}

@get:Input
val allowInsecureProtocol: Provider<Boolean> = env.map {
it.allowInsecureProtocol
}

@Deprecated("Use downloadBaseUrlProvider instead. It uses Gradle Provider API.")
val downloadBaseUrl: String?
@Internal
Expand Down Expand Up @@ -144,6 +149,8 @@ abstract class AbstractSetupTask<Env : AbstractEnv, Spec : EnvSpec<Env>>(
repo.name = "Distributions at ${it}"
repo.url = URI(it)

repo.isAllowInsecureProtocol = allowInsecureProtocol.get()

repo.patternLayout {
it.artifact(artifactPattern)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.io.File
data class BinaryenEnv(
override val download: Boolean,
override val downloadBaseUrl: String?,
override val allowInsecureProtocol: Boolean,
override val ivyDependency: String,
override val executable: String,
override val dir: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ abstract class BinaryenRootEnvSpec : EnvSpec<BinaryenEnv>() {
BinaryenEnv(
download = downloadValue,
downloadBaseUrl = downloadBaseUrl.orNull,
allowInsecureProtocol = allowInsecureProtocol.get(),
ivyDependency = "com.github.webassembly:binaryen:$versionValue:${platformValue.platform}@tar.gz",
executable = getExecutable("wasm-opt", command.get(), "exe"),
dir = targetPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ open class BinaryenRootPlugin : Plugin<Project> {
) {
download.convention(rootBinaryen.downloadProperty)
downloadBaseUrl.convention(rootBinaryen.downloadBaseUrlProperty)
allowInsecureProtocol.convention(false)
installationDirectory.convention(rootBinaryen.installationDirectory)
version.convention(rootBinaryen.versionProperty)
command.convention(rootBinaryen.commandProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.io.File
data class D8Env(
override val download: Boolean,
override val downloadBaseUrl: String?,
override val allowInsecureProtocol: Boolean,
override val ivyDependency: String,
override val executable: String,
override val dir: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ abstract class D8EnvSpec : EnvSpec<D8Env>() {
D8Env(
download = downloadValue,
downloadBaseUrl = downloadBaseUrl.orNull,
allowInsecureProtocol = allowInsecureProtocol.get(),
ivyDependency = "google.d8:v8:$requiredVersion@zip",
executable = getExecutable("d8", command.get(), "exe"),
dir = targetPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ open class D8Plugin : Plugin<Project> {
) {
download.convention(d8.downloadProperty)
downloadBaseUrl.convention(d8.downloadBaseUrlProperty)
allowInsecureProtocol.convention(false)
installationDirectory.convention(d8.installationDirectory)
version.convention(d8.versionProperty)
edition.convention(d8.edition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ data class NodeJsEnv(
val architectureName: String,
override val ivyDependency: String,
override val downloadBaseUrl: String?,
override val allowInsecureProtocol: Boolean,
) : AbstractEnv {
val isWindows: Boolean
get() = platformName == "win"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ abstract class NodeJsEnvSpec : EnvSpec<NodeJsEnv>() {
architectureName = architecture,
ivyDependency = getIvyDependency(),
downloadBaseUrl = downloadBaseUrl.orNull,
allowInsecureProtocol = allowInsecureProtocol.get(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ open class NodeJsPlugin : Plugin<Project> {
download.convention(objects.providerWithLazyConvention { nodeJsConstructor().download })
// set instead of convention because it is possible to have null value
downloadBaseUrl.set(objects.providerWithLazyConvention { nodeJsConstructor().downloadBaseUrl })
allowInsecureProtocol.convention(false)
version.convention(objects.providerWithLazyConvention { nodeJsConstructor().version })
command.convention(objects.providerWithLazyConvention { nodeJsConstructor().command })

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import java.io.File
data class YarnEnv(
override val download: Boolean,
override val downloadBaseUrl: String?,
override val allowInsecureProtocol: Boolean,
override val cleanableStore: CleanableStore,
override val dir: File,
override val executable: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ open class YarnPlugin : Plugin<Project> {
) {
download.convention(yarnRootExtension.downloadProperty)
downloadBaseUrl.convention(yarnRootExtension.downloadBaseUrlProperty)
allowInsecureProtocol.convention(false)
installationDirectory.convention(yarnRootExtension.installationDirectory)
version.convention(yarnRootExtension.versionProperty)
command.convention(yarnRootExtension.commandProperty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ abstract class YarnRootEnvSpec : EnvSpec<YarnEnv>() {
YarnEnv(
download = downloadValue,
downloadBaseUrl = downloadBaseUrl.orNull,
allowInsecureProtocol = allowInsecureProtocol.get(),
cleanableStore = cleanableStore,
dir = home,
executable = getExecutable("yarn", command.get(), "cmd"),
Expand Down

0 comments on commit ee56193

Please sign in to comment.