@@ -13,10 +13,16 @@ struct OSLogStringAlignment {
13
13
static var none = OSLogStringAlignment ( )
14
14
}
15
15
16
+ enum OSLogIntegerFormatting { case decimal }
17
+ enum OSLogInt32ExtendedFormat { case none }
18
+ enum OSLogFloatFormatting { case fixed }
19
+ enum OSLogBoolFormat { case truth }
20
+
16
21
struct OSLogPrivacy {
17
22
enum Mask { case none }
18
23
static var auto = OSLogPrivacy ( )
19
24
static var `private` = OSLogPrivacy ( )
25
+ static var `public` = OSLogPrivacy ( )
20
26
static var sensitive = OSLogPrivacy ( )
21
27
22
28
static func auto( mask: OSLogPrivacy . Mask ) -> OSLogPrivacy { return . auto }
@@ -30,6 +36,23 @@ struct OSLogInterpolation : StringInterpolationProtocol {
30
36
func appendLiteral( _: Self . StringLiteralType ) { }
31
37
mutating func appendInterpolation( _ argumentString: @autoclosure @escaping ( ) -> String , align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
32
38
mutating func appendInterpolation( _ argumentString: @autoclosure @escaping ( ) -> String , align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto, attributes: String ) { }
39
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
40
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int8 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
41
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int16 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
42
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int32 , format: OSLogInt32ExtendedFormat , privacy: OSLogPrivacy = . auto) { }
43
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int32 , format: OSLogInt32ExtendedFormat , privacy: OSLogPrivacy = . auto, attributes: String ) { }
44
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int32 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
45
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Int64 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
46
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> UInt , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
47
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> UInt8 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
48
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> UInt16 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
49
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> UInt32 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
50
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> UInt64 , format: OSLogIntegerFormatting = . decimal, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
51
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Double , format: OSLogFloatFormatting = . fixed, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
52
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Double , format: OSLogFloatFormatting = . fixed, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto, attributes: String ) { }
53
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Float , format: OSLogFloatFormatting = . fixed, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto) { }
54
+ mutating func appendInterpolation( _ number: @autoclosure @escaping ( ) -> Float , format: OSLogFloatFormatting = . fixed, align: OSLogStringAlignment = . none, privacy: OSLogPrivacy = . auto, attributes: String ) { }
55
+ mutating func appendInterpolation( _ boolean: @autoclosure @escaping ( ) -> Bool , format: OSLogBoolFormat = . truth, privacy: OSLogPrivacy = . auto) { }
33
56
}
34
57
35
58
struct OSLogMessage : ExpressibleByStringInterpolation {
@@ -60,32 +83,42 @@ struct Logger {
60
83
// --- tests ---
61
84
62
85
func test1( password: String , passwordHash : String ) {
63
- print ( password) // $ MISSING: hasCleartextLogging=63
64
- print ( password, separator: " " ) // $ MISSING: $ hasCleartextLogging=64
65
- print ( " " , separator: password) // $ hasCleartextLogging=65
66
- print ( password, separator: " " , terminator: " " ) // $ MISSING: hasCleartextLogging=66
67
- print ( " " , separator: password, terminator: " " ) // $ hasCleartextLogging=67
68
- print ( " " , separator: " " , terminator: password) // $ hasCleartextLogging=68
69
-
70
- NSLog ( password) // $ hasCleartextLogging=70
71
- NSLog ( " %@ " , password as! CVarArg ) // $ MISSING: hasCleartextLogging=71
72
- NSLog ( " %@ %@ " , " " as! CVarArg , password as! CVarArg ) // $ MISSING: hasCleartextLogging=72
73
- NSLog ( " \( password) " ) // $ hasCleartextLogging=73
74
- NSLogv ( " %@ " , getVaList ( [ password as! CVarArg ] ) ) // $ MISSING: hasCleartextLogging=74
75
- NSLogv ( " %@ %@ " , getVaList ( [ " " as! CVarArg , password as! CVarArg ] ) ) // $ MISSING: hasCleartextLogging=75
76
-
86
+ print ( password) // $ MISSING: hasCleartextLogging=86
87
+ print ( password, separator: " " ) // $ MISSING: $ hasCleartextLogging=97
88
+ print ( " " , separator: password) // $ hasCleartextLogging=88
89
+ print ( password, separator: " " , terminator: " " ) // $ MISSING: hasCleartextLogging=89
90
+ print ( " " , separator: password, terminator: " " ) // $ hasCleartextLogging=90
91
+ print ( " " , separator: " " , terminator: password) // $ hasCleartextLogging=91
92
+
93
+ NSLog ( password) // $ hasCleartextLogging=93
94
+ NSLog ( " %@ " , password as! CVarArg ) // $ MISSING: hasCleartextLogging=94
95
+ NSLog ( " %@ %@ " , " " as! CVarArg , password as! CVarArg ) // $ MISSING: hasCleartextLogging=95
96
+ NSLog ( " \( password) " ) // $ hasCleartextLogging=96
97
+ NSLogv ( " %@ " , getVaList ( [ password as! CVarArg ] ) ) // $ MISSING: hasCleartextLogging=97
98
+ NSLogv ( " %@ %@ " , getVaList ( [ " " as! CVarArg , password as! CVarArg ] ) ) // $ MISSING: hasCleartextLogging=98
99
+
100
+ let bankAccount : Int = 0
77
101
let log = Logger ( )
78
- log. log ( " \( password) " ) // $ hasCleartextLogging=78
102
+ // These MISSING test cases will be fixed when we properly generate the CFG around autoclosures.
103
+ log. log ( " \( password) " ) // Safe
104
+ log. log ( " \( password, privacy: . auto) " ) // Safe
79
105
log. log ( " \( password, privacy: . private) " ) // Safe
80
- log. log ( level: . default, " \( password) " ) // $ hasCleartextLogging=80
81
- log. trace ( " \( password) " ) // $ hasCleartextLogging=81
82
- log. debug ( " \( password) " ) // $ hasCleartextLogging=82
83
- log. info ( " \( password) " ) // $ hasCleartextLogging=83
84
- log. notice ( " \( password) " ) // $ hasCleartextLogging=84
85
- log. warning ( " \( password) " ) // $ hasCleartextLogging=85
86
- log. error ( " \( password) " ) // $ hasCleartextLogging=86
87
- log. critical ( " \( password) " ) // $ hasCleartextLogging=87
88
- log. fault ( " \( password) " ) // $ hasCleartextLogging=88
106
+ log. log ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=106
107
+ log. log ( " \( password, privacy: . sensitive) " ) // Safe
108
+ log. log ( " \( bankAccount) " ) // $ MISSING: hasCleartextLogging=108
109
+ log. log ( " \( bankAccount, privacy: . auto) " ) // $ MISSING: hasCleartextLogging=109
110
+ log. log ( " \( bankAccount, privacy: . private) " ) // Safe
111
+ log. log ( " \( bankAccount, privacy: . public) " ) // $ MISSING: hasCleartextLogging=111
112
+ log. log ( " \( bankAccount, privacy: . sensitive) " ) // Safe
113
+ log. log ( level: . default, " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=113
114
+ log. trace ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=114
115
+ log. debug ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=115
116
+ log. info ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=116
117
+ log. notice ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=117
118
+ log. warning ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=118
119
+ log. error ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=119
120
+ log. critical ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=120
121
+ log. fault ( " \( password, privacy: . public) " ) // $ MISSING: hasCleartextLogging=121
89
122
}
90
123
/*
91
124
class MyClass {
0 commit comments