@@ -25,19 +25,16 @@ func (a *Analyzer) detectNetworkSecurity(decompDir string) *models.NetworkSecuri
2525
2626 contentStr := strings .ToLower (string (content ))
2727
28- // Check for cleartext traffic
2928 if strings .Contains (contentStr , "cleartexttrafficpermitted=\" true\" " ) {
3029 config .CleartextAllowed = true
3130 config .Risks = append (config .Risks , "Cleartext (HTTP) traffic is permitted - data can be intercepted" )
3231 }
3332
34- // Check for certificate pinning
3533 if strings .Contains (contentStr , "<pin-set>" ) || strings .Contains (contentStr , "<pin " ) {
3634 config .CertificatePinning = true
3735 config .SecurityFeatures = append (config .SecurityFeatures , "Certificate pinning enabled" )
3836 }
3937
40- // Check for trust anchors
4138 if strings .Contains (contentStr , "<trust-anchors>" ) {
4239 if strings .Contains (contentStr , "user" ) {
4340 config .TrustsUserCerts = true
@@ -48,7 +45,6 @@ func (a *Analyzer) detectNetworkSecurity(decompDir string) *models.NetworkSecuri
4845 }
4946 }
5047
51- // Extract domain configs
5248 domainRegex := regexp .MustCompile (`<domain[^>]*>([^<]+)</domain>` )
5349 for _ , match := range domainRegex .FindAllStringSubmatch (string (content ), - 1 ) {
5450 if len (match ) > 1 {
@@ -98,13 +94,11 @@ func (a *Analyzer) detectDataStorage(contentStr string) *models.DataStorageAnaly
9894 }
9995 }
10096
101- // Check for database encryption
10297 if strings .Contains (contentStr , "SQLCipher" ) || strings .Contains (contentStr , "encrypted" ) {
10398 analysis .DatabaseEncryption = true
10499 analysis .SecurityNotes = append (analysis .SecurityNotes , "Database encryption detected" )
105100 }
106101
107- // Check for backup flags
108102 if strings .Contains (contentStr , "allowBackup=\" true\" " ) {
109103 analysis .BackupAllowed = true
110104 analysis .SecurityNotes = append (analysis .SecurityNotes , "App data backup is allowed - sensitive data may be extracted" )
@@ -151,7 +145,6 @@ func (a *Analyzer) detectWebViewSecurity(contentStr string) *models.WebViewSecur
151145 }
152146 }
153147
154- // Check for secure settings
155148 secureSettings := []string {
156149 "setAllowFileAccess(false)" ,
157150 "setJavaScriptEnabled(false)" ,
@@ -171,14 +164,12 @@ func (a *Analyzer) detectWebViewSecurity(contentStr string) *models.WebViewSecur
171164func (a * Analyzer ) detectObfuscation (contentStr string , decompDir string ) * models.ObfuscationAnalysis {
172165 analysis := & models.ObfuscationAnalysis {}
173166
174- // Check for ProGuard/R8 mapping
175167 mappingPath := filepath .Join (decompDir , "mapping.txt" )
176168 if _ , err := os .Stat (mappingPath ); err == nil {
177169 analysis .ProGuardDetected = true
178170 analysis .MappingFileFound = true
179171 }
180172
181- // Heuristics for obfuscation
182173 shortNamePattern := regexp .MustCompile (`\b[a-z]\.[a-z]\.[a-z]\b` )
183174 shortNames := shortNamePattern .FindAllString (contentStr , - 1 )
184175 if len (shortNames ) > 100 {
@@ -187,7 +178,6 @@ func (a *Analyzer) detectObfuscation(contentStr string, decompDir string) *model
187178 analysis .Indicators = append (analysis .Indicators , fmt .Sprintf ("Found %d short class names (a.b.c pattern)" , len (shortNames )))
188179 }
189180
190- // Check for string encryption
191181 stringEncPatterns := []string {
192182 "decrypt" ,
193183 "deobfuscate" ,
@@ -203,7 +193,6 @@ func (a *Analyzer) detectObfuscation(contentStr string, decompDir string) *model
203193 }
204194 }
205195
206- // Check for native library obfuscation
207196 if strings .Contains (contentStr , "UPX" ) {
208197 analysis .NativeObfuscation = true
209198 analysis .Indicators = append (analysis .Indicators , "UPX packer detected in native libraries" )
@@ -217,7 +206,7 @@ func (a *Analyzer) detectDeepLinks(decompDir string) *models.DeepLinkAnalysis {
217206 manifestPath := filepath .Join (decompDir , "AndroidManifest.xml" )
218207 content , err := os .ReadFile (manifestPath )
219208 if err != nil {
220- // Try alternate location
209+
221210 manifestPath = filepath .Join (decompDir , "resources" , "AndroidManifest.xml" )
222211 content , err = os .ReadFile (manifestPath )
223212 if err != nil {
@@ -228,7 +217,6 @@ func (a *Analyzer) detectDeepLinks(decompDir string) *models.DeepLinkAnalysis {
228217 analysis := & models.DeepLinkAnalysis {}
229218 contentStr := string (content )
230219
231- // Extract intent filters with data schemes
232220 schemeRegex := regexp .MustCompile (`android:scheme="([^"]+)"` )
233221 hostRegex := regexp .MustCompile (`android:host="([^"]+)"` )
234222 pathRegex := regexp .MustCompile (`android:path(?:Pattern|Prefix)?="([^"]+)"` )
@@ -255,11 +243,10 @@ func (a *Analyzer) detectDeepLinks(decompDir string) *models.DeepLinkAnalysis {
255243 }
256244 }
257245
258- // Build example deep links
259246 if len (analysis .Schemes ) > 0 && len (analysis .Hosts ) > 0 {
260247 for i , scheme := range analysis .Schemes {
261248 if i >= 3 {
262- break // Limit examples
249+ break
263250 }
264251 for j , host := range analysis .Hosts {
265252 if j >= 2 {
@@ -276,7 +263,6 @@ func (a *Analyzer) detectDeepLinks(decompDir string) *models.DeepLinkAnalysis {
276263 }
277264 }
278265
279- // Check for App Links verification
280266 if strings .Contains (contentStr , "autoVerify=\" true\" " ) {
281267 analysis .AppLinksVerified = true
282268 analysis .SecurityNotes = append (analysis .SecurityNotes , "App Links auto-verification enabled" )
@@ -296,46 +282,38 @@ func (a *Analyzer) detectThirdPartySDKs(packages []models.Package, contentStr st
296282 }
297283
298284 sdkDatabase := map [string ]models.SDKInfo {
299- // Analytics
285+
300286 "firebase_analytics" : {Name : "Firebase Analytics" , Category : "Analytics" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"Device info" , "Usage patterns" , "Crash data" }},
301287 "google_analytics" : {Name : "Google Analytics" , Category : "Analytics" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"User behavior" , "Demographics" , "Events" }},
302288 "mixpanel" : {Name : "Mixpanel" , Category : "Analytics" , Vendor : "Mixpanel" , PrivacyImpact : "High" , DataCollected : []string {"User events" , "User properties" , "Behavioral data" }},
303289 "amplitude" : {Name : "Amplitude" , Category : "Analytics" , Vendor : "Amplitude" , PrivacyImpact : "High" , DataCollected : []string {"Event tracking" , "User segmentation" }},
304290
305- // Advertising
306291 "google_mobile_ads" : {Name : "Google Mobile Ads (AdMob)" , Category : "Advertising" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"Advertising ID" , "Location" , "Device info" }},
307292 "facebook_audience_network" : {Name : "Facebook Audience Network" , Category : "Advertising" , Vendor : "Meta" , PrivacyImpact : "High" , DataCollected : []string {"User profile" , "Device ID" , "Location" }},
308293 "unity_ads" : {Name : "Unity Ads" , Category : "Advertising" , Vendor : "Unity" , PrivacyImpact : "Medium" , DataCollected : []string {"Device info" , "Ad interactions" }},
309294
310- // Crash Reporting
311295 "sentry" : {Name : "Sentry" , Category : "Crash Reporting" , Vendor : "Sentry" , PrivacyImpact : "Medium" , DataCollected : []string {"Crash logs" , "Stack traces" , "Device state" }},
312296 "firebase_crashlytics" : {Name : "Firebase Crashlytics" , Category : "Crash Reporting" , Vendor : "Google" , PrivacyImpact : "Medium" , DataCollected : []string {"Crash data" , "Device info" }},
313297 "bugsnag" : {Name : "Bugsnag" , Category : "Crash Reporting" , Vendor : "Bugsnag" , PrivacyImpact : "Medium" , DataCollected : []string {"Error logs" , "User context" }},
314298
315- // Authentication
316299 "firebase_auth" : {Name : "Firebase Authentication" , Category : "Authentication" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"Email" , "Phone" , "Auth tokens" }},
317300 "google_sign_in" : {Name : "Google Sign-In" , Category : "Authentication" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"Google profile" , "Email" }},
318301 "flutter_facebook_auth" : {Name : "Facebook Login" , Category : "Authentication" , Vendor : "Meta" , PrivacyImpact : "High" , DataCollected : []string {"Facebook profile" , "Email" , "Friends list" }},
319302
320- // Payment
321303 "stripe" : {Name : "Stripe" , Category : "Payment" , Vendor : "Stripe" , PrivacyImpact : "High" , DataCollected : []string {"Payment info" , "Billing address" , "Transaction history" }, RequiresCompliance : []string {"PCI-DSS" }},
322304 "razorpay" : {Name : "Razorpay" , Category : "Payment" , Vendor : "Razorpay" , PrivacyImpact : "High" , DataCollected : []string {"Payment details" , "Contact info" }},
323305 "paypal" : {Name : "PayPal" , Category : "Payment" , Vendor : "PayPal" , PrivacyImpact : "High" , DataCollected : []string {"Payment info" , "Transaction data" }},
324306
325- // Social
326307 "share_plus" : {Name : "Share Plus" , Category : "Social" , Vendor : "Community" , PrivacyImpact : "Low" , DataCollected : []string {"Shared content" }},
327308 "flutter_facebook_sdk" : {Name : "Facebook SDK" , Category : "Social" , Vendor : "Meta" , PrivacyImpact : "High" , DataCollected : []string {"User interactions" , "Device info" }},
328309
329- // Location
330310 "geolocator" : {Name : "Geolocator" , Category : "Location" , Vendor : "Community" , PrivacyImpact : "High" , DataCollected : []string {"GPS coordinates" , "Location history" }},
331311 "google_maps_flutter" : {Name : "Google Maps" , Category : "Maps" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"Location" , "Search queries" , "Navigation history" }},
332312
333- // Storage/Database
334313 "sqflite" : {Name : "SQFlite" , Category : "Storage" , Vendor : "Community" , PrivacyImpact : "Low" , DataCollected : []string {"Local data only" }},
335314 "hive" : {Name : "Hive" , Category : "Storage" , Vendor : "Community" , PrivacyImpact : "Low" , DataCollected : []string {"Local data only" }},
336315 "cloud_firestore" : {Name : "Cloud Firestore" , Category : "Database" , Vendor : "Google" , PrivacyImpact : "High" , DataCollected : []string {"User data" , "Database queries" }},
337316
338- // Push Notifications
339317 "firebase_messaging" : {Name : "Firebase Cloud Messaging" , Category : "Push Notifications" , Vendor : "Google" , PrivacyImpact : "Medium" , DataCollected : []string {"Device tokens" , "Message data" }},
340318 "onesignal" : {Name : "OneSignal" , Category : "Push Notifications" , Vendor : "OneSignal" , PrivacyImpact : "Medium" , DataCollected : []string {"Device info" , "Notification preferences" }},
341319 }
@@ -356,7 +334,6 @@ func (a *Analyzer) detectThirdPartySDKs(packages []models.Package, contentStr st
356334 }
357335 }
358336
359- // Calculate privacy score (0-100, lower is better for privacy)
360337 if analysis .TotalSDKs > 0 {
361338 analysis .PrivacyScore = analysis .HighPrivacyImpactCount * 20
362339 if analysis .PrivacyScore > 100 {
0 commit comments