-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
RunSurvey.kt
105 lines (92 loc) · 3.52 KB
/
RunSurvey.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (C) 2022 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package okhttp3.survey
import java.security.Security
import okhttp3.Cache
import okhttp3.OkHttpClient
import okhttp3.survey.ssllabs.SslLabsClient
import okhttp3.survey.types.Client
import okhttp3.survey.types.SuiteId
import okio.FileSystem
import okio.Path.Companion.toPath
import org.conscrypt.Conscrypt
@Suppress("ktlint:standard:property-naming")
suspend fun main() {
val includeConscrypt = false
val client =
OkHttpClient.Builder()
.cache(Cache(FileSystem.SYSTEM, "build/okhttp_cache".toPath(), 100_000_000))
.build()
val sslLabsClients = SslLabsClient(client).clients()
val ianaSuitesNew = fetchIanaSuites(client)
val android5 = sslLabsClients.first { it.userAgent == "Android" && it.version == "5.0.0" }
val android9 = sslLabsClients.first { it.userAgent == "Android" && it.version == "9.0" }
val chrome33 = sslLabsClients.first { it.userAgent == "Chrome" && it.version == "33" }
val chrome57 = sslLabsClients.first { it.userAgent == "Chrome" && it.version == "57" }
val chrome80 = sslLabsClients.first { it.userAgent == "Chrome" && it.version == "80" }
val firefox34 = sslLabsClients.first { it.userAgent == "Firefox" && it.version == "34" }
val firefox53 = sslLabsClients.first { it.userAgent == "Firefox" && it.version == "53" }
val firefox73 = sslLabsClients.first { it.userAgent == "Firefox" && it.version == "73" }
val java7 = sslLabsClients.first { it.userAgent == "Java" && it.version == "7u25" }
val java12 = sslLabsClients.first { it.userAgent == "Java" && it.version == "12.0.1" }
val safari12iOS = sslLabsClients.first { it.userAgent == "Safari" && it.platform == "iOS 12.3.1" }
val safari12Osx =
sslLabsClients.first { it.userAgent == "Safari" && it.platform == "MacOS 10.14.6 Beta" }
val okhttp = currentOkHttp(ianaSuitesNew)
val okHttp_4_10 = historicOkHttp("4.10")
val okHttp_3_14 = historicOkHttp("3.14")
val okHttp_3_13 = historicOkHttp("3.13")
val okHttp_3_11 = historicOkHttp("3.11")
val okHttp_3_9 = historicOkHttp("3.9")
val currentVm = currentVm(ianaSuitesNew)
val conscrypt =
if (includeConscrypt) {
Security.addProvider(Conscrypt.newProvider())
conscrypt(ianaSuitesNew)
} else {
Client("Conscrypt", "Disabled", null, listOf())
}
val clients =
listOf(
okhttp,
chrome80,
firefox73,
android9,
safari12iOS,
conscrypt,
currentVm,
okHttp_3_9,
okHttp_3_11,
okHttp_3_13,
okHttp_3_14,
okHttp_4_10,
android5,
java7,
java12,
firefox34,
firefox53,
chrome33,
chrome57,
safari12Osx,
)
val orderBy = okhttp.enabled + chrome80.enabled + safari12Osx.enabled + rest(clients)
val survey = CipherSuiteSurvey(clients = clients, ianaSuites = ianaSuitesNew, orderBy = orderBy)
survey.printGoogleSheet()
}
fun rest(clients: List<Client>): List<SuiteId> {
// combine all ciphers to get these near the top
return clients.flatMap { it.enabled }
}