ref: static TransportSecurity strings
This commit is contained in:
@@ -1,32 +1,6 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Print recursive tree of key-value mappings.
|
let TransportSecurityLocalizedKeys = [
|
||||||
private func recursiveDict(_ dictionary: [String: Any], withReplacements replacements: [String: String] = [:], _ level: Int = 0) -> String {
|
|
||||||
var output = ""
|
|
||||||
for (key, value) in dictionary {
|
|
||||||
let localizedKey = replacements[key] ?? key
|
|
||||||
for _ in 0..<level {
|
|
||||||
output += (level == 1) ? "- " : " "
|
|
||||||
}
|
|
||||||
|
|
||||||
if let subDict = value as? [String: Any] {
|
|
||||||
output += "\(localizedKey):<div class=\"list\">\n"
|
|
||||||
output += recursiveDict(subDict, withReplacements: replacements, level + 1)
|
|
||||||
output += "</div>\n"
|
|
||||||
} else if let number = value as? NSNumber {
|
|
||||||
output += "\(localizedKey): \(number.boolValue ? "YES" : "NO")<br />"
|
|
||||||
} else {
|
|
||||||
output += "\(localizedKey): \(value)<br />"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output
|
|
||||||
}
|
|
||||||
|
|
||||||
extension PreviewGenerator {
|
|
||||||
/// @return List of ATS flags.
|
|
||||||
private func formattedAppTransportSecurity(_ appPlist: PlistDict) -> String {
|
|
||||||
if let value = appPlist["NSAppTransportSecurity"] as? PlistDict {
|
|
||||||
let localizedKeys = [
|
|
||||||
"NSAllowsArbitraryLoads": "Allows Arbitrary Loads",
|
"NSAllowsArbitraryLoads": "Allows Arbitrary Loads",
|
||||||
"NSAllowsArbitraryLoadsForMedia": "Allows Arbitrary Loads for Media",
|
"NSAllowsArbitraryLoadsForMedia": "Allows Arbitrary Loads for Media",
|
||||||
"NSAllowsArbitraryLoadsInWebContent": "Allows Arbitrary Loads in Web Content",
|
"NSAllowsArbitraryLoadsInWebContent": "Allows Arbitrary Loads in Web Content",
|
||||||
@@ -45,7 +19,33 @@ extension PreviewGenerator {
|
|||||||
"NSThirdPartyExceptionRequiresForwardSecrecy": "Requires Forward Secrecy",
|
"NSThirdPartyExceptionRequiresForwardSecrecy": "Requires Forward Secrecy",
|
||||||
]
|
]
|
||||||
|
|
||||||
return "<div class=\"list\">\(recursiveDict(value, withReplacements: localizedKeys))</div>"
|
/// Print recursive tree of key-value mappings.
|
||||||
|
private func recursiveTransportSecurity(_ dictionary: [String: Any], _ level: Int = 0) -> String {
|
||||||
|
var output = ""
|
||||||
|
for (key, value) in dictionary {
|
||||||
|
let localizedKey = TransportSecurityLocalizedKeys[key] ?? key
|
||||||
|
for _ in 0..<level {
|
||||||
|
output += (level == 1) ? "- " : " "
|
||||||
|
}
|
||||||
|
|
||||||
|
if let subDict = value as? [String: Any] {
|
||||||
|
output += "\(localizedKey):<div class=\"list\">\n"
|
||||||
|
output += recursiveTransportSecurity(subDict, level + 1)
|
||||||
|
output += "</div>\n"
|
||||||
|
} else if let number = value as? NSNumber {
|
||||||
|
output += "\(localizedKey): \(number.boolValue ? "YES" : "NO")<br />"
|
||||||
|
} else {
|
||||||
|
output += "\(localizedKey): \(value)<br />"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
|
extension PreviewGenerator {
|
||||||
|
/// @return List of ATS flags.
|
||||||
|
private func formattedAppTransportSecurity(_ appPlist: PlistDict) -> String {
|
||||||
|
if let value = appPlist["NSAppTransportSecurity"] as? PlistDict {
|
||||||
|
return "<div class=\"list\">\(recursiveTransportSecurity(value))</div>"
|
||||||
}
|
}
|
||||||
|
|
||||||
let sdkName = appPlist["DTSDKName"] as? String ?? "0"
|
let sdkName = appPlist["DTSDKName"] as? String ?? "0"
|
||||||
|
|||||||
Reference in New Issue
Block a user