Skip to content

Conversation

@KushalNParmar
Copy link

No description provided.

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

Webview debugging is enabled.

Copilot Autofix

AI 25 days 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.


Suggested changeset 1
app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt b/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
--- a/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
+++ b/app/src/main/java/io/pixelbin/glamar/sample/MyApp.kt
@@ -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(
EOF
@@ -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(
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants