Conversation
| GlamArLogger.d("Glam_myApp", "onCreate: ") | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||
| WebView.setWebContentsDebuggingEnabled(true) |
Check failure
Code scanning / CodeQL
Android Webview debugging enabled High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the issue, we should ensure that WebView debugging is enabled only during debug builds. This is typically done by checking the ApplicationInfo.FLAG_DEBUGGABLE flag at runtime. In Kotlin, within an Application subclass, you can obtain this by evaluating the following condition:
if (0 != applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE)We need to change the block (lines 16-18) to perform this conditional check instead of always enabling debugging. No additional imports are needed unless android.content.pm.ApplicationInfo is referenced by name, but in this case ApplicationInfo is accessible via android.app.Application. So only the specific lines need adjustment, and no extra methods or variable definitions are required.
| @@ -14,7 +14,9 @@ | ||
| GlamArLogger.d("Glam_myApp", "onCreate: ") | ||
|
|
||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | ||
| WebView.setWebContentsDebuggingEnabled(true) | ||
| if (0 != applicationInfo.flags and android.content.pm.ApplicationInfo.FLAG_DEBUGGABLE) { | ||
| WebView.setWebContentsDebuggingEnabled(true) | ||
| } | ||
| } | ||
|
|
||
| val webView = WebView( |
No description provided.