android-skills 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +22 -171
  2. package/android-ui/SKILL.md +187 -0
  3. package/android-ui/references/anti-slop-checklist.md +61 -0
  4. package/android-ui/references/checklist.md +95 -0
  5. package/android-ui/references/clarifying-questions.md +55 -0
  6. package/android-ui/references/color-and-contrast.md +104 -0
  7. package/android-ui/references/components-intents.md +74 -0
  8. package/android-ui/references/compose-patterns.md +120 -0
  9. package/android-ui/references/compose-risks.md +86 -0
  10. package/android-ui/references/input-and-state.md +77 -0
  11. package/android-ui/references/network-storage.md +87 -0
  12. package/android-ui/references/reconstruction-workflow.md +74 -0
  13. package/android-ui/references/report-template.md +71 -0
  14. package/android-ui/references/sensitive-data-ui.md +73 -0
  15. package/android-ui/references/typography-spacing.md +93 -0
  16. package/android-ui/references/webview.md +105 -0
  17. package/{android-ui-minimal → android-ui}/scripts/contrast.py +8 -8
  18. package/{android-ui-minimal → android-ui}/scripts/gen_tokens.py +11 -11
  19. package/{android-ui-minimal → android-ui}/scripts/lint_ui.py +29 -29
  20. package/{android-ui-security-review → android-ui}/scripts/scan.py +146 -146
  21. package/bin/android-skills.js +10 -10
  22. package/install.py +79 -65
  23. package/opencode/commands/ui.md +13 -0
  24. package/package.json +2 -3
  25. package/android-ui-minimal/SKILL.md +0 -98
  26. package/android-ui-minimal/references/anti-slop-checklist.md +0 -61
  27. package/android-ui-minimal/references/clarifying-questions.md +0 -55
  28. package/android-ui-minimal/references/color-and-contrast.md +0 -104
  29. package/android-ui-minimal/references/compose-patterns.md +0 -120
  30. package/android-ui-minimal/references/reconstruction-workflow.md +0 -74
  31. package/android-ui-minimal/references/typography-spacing.md +0 -93
  32. package/android-ui-security-review/SKILL.md +0 -93
  33. package/android-ui-security-review/references/checklist.md +0 -95
  34. package/android-ui-security-review/references/components-intents.md +0 -74
  35. package/android-ui-security-review/references/compose-risks.md +0 -86
  36. package/android-ui-security-review/references/input-and-state.md +0 -77
  37. package/android-ui-security-review/references/network-storage.md +0 -87
  38. package/android-ui-security-review/references/report-template.md +0 -71
  39. package/android-ui-security-review/references/sensitive-data-ui.md +0 -73
  40. package/android-ui-security-review/references/webview.md +0 -105
  41. package/opencode/commands/ui-minimal.md +0 -9
  42. package/opencode/commands/ui-security.md +0 -9
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env python3
2
- """Pemindai statis risiko keamanan frontend Android (Kotlin, Java, XML, Manifest).
2
+ """Static scanner for Android frontend/UI security risks (Kotlin, Java, XML, Manifest).
3
3
 
4
- Ini pemindai berbasis pola, bukan analisis aliran data. Setiap temuan harus
5
- diverifikasi manual. ID aturan sama dengan references/checklist.md.
4
+ This is a pattern-based scanner, not data-flow analysis. Every finding must
5
+ be verified manually. Rule IDs match references/checklist.md.
6
6
 
7
- Pemakaian:
7
+ Usage:
8
8
  python3 scan.py <path> [--format text|md|json] [--out FILE]
9
9
  [--min-severity info|low|medium|high|critical]
10
10
  [--fail-on high] [--include-tests]
11
11
 
12
- Tekan temuan dengan komentar (alasan wajib): // sec-ignore: RULE_ID alasan
13
- (di AndroidManifest.xml: <!-- sec-ignore: RULE_ID alasan -->, tepat di atas elemen)
14
- Kode keluar: 1 jika ada temuan >= --fail-on, selain itu 0.
12
+ Suppress a finding with a comment (reason required): // sec-ignore: RULE_ID reason
13
+ (in AndroidManifest.xml: <!-- sec-ignore: RULE_ID reason -->, directly above the element)
14
+ Exit code: 1 if any finding >= --fail-on, else 0.
15
15
  """
16
16
  import argparse
17
17
  import json
@@ -43,131 +43,131 @@ class Rule:
43
43
  I = re.I
44
44
  RULES = [
45
45
  # WebView
46
- Rule("W-JS", "medium", "JavaScript aktif di WebView",
46
+ Rule("W-JS", "medium", "JavaScript enabled in WebView",
47
47
  r"setJavaScriptEnabled\(\s*true\s*\)|javaScriptEnabled\s*=\s*true",
48
- "Aktifkan hanya jika perlu dan hanya untuk konten tepercaya. Batasi origin yang dimuat."),
48
+ "Enable only when needed and only for trusted content. Restrict the origins loaded."),
49
49
  Rule("W-INTERFACE", "high", "addJavascriptInterface",
50
50
  r"addJavascriptInterface\(",
51
- "Hanya untuk konten lokal tepercaya. Beri @JavascriptInterface pada metode minimal, atau pakai WebMessageListener dengan allowedOriginRules."),
52
- Rule("W-FILE", "high", "Akses file WebView terlalu longgar",
51
+ "Only for trusted local content. Annotate a minimal set of methods with @JavascriptInterface, or use a WebMessageListener with allowedOriginRules."),
52
+ Rule("W-FILE", "high", "WebView file access too loose",
53
53
  r"(setAllowUniversalAccessFromFileURLs|setAllowFileAccessFromFileURLs)\(\s*true|allow(UniversalAccessFromFileURLs|FileAccessFromFileURLs)\s*=\s*true",
54
- "Nonaktifkan. Muat aset lokal lewat WebViewAssetLoader."),
55
- Rule("W-FILE2", "medium", "allowFileAccess aktif",
54
+ "Disable. Load local assets through WebViewAssetLoader."),
55
+ Rule("W-FILE2", "medium", "allowFileAccess enabled",
56
56
  r"setAllowFileAccess\(\s*true|allowFileAccess\s*=\s*true",
57
- "Matikan, atau pakai WebViewAssetLoader."),
58
- Rule("W-CONTENT", "medium", "allowContentAccess aktif",
57
+ "Turn off, or use WebViewAssetLoader."),
58
+ Rule("W-CONTENT", "medium", "allowContentAccess enabled",
59
59
  r"setAllowContentAccess\(\s*true|allowContentAccess\s*=\s*true",
60
- "Matikan jika tidak butuh konten provider."),
61
- Rule("W-MIXED", "high", "Mixed content diizinkan",
62
- r"MIXED_CONTENT_ALWAYS_ALLOW", "Gunakan MIXED_CONTENT_NEVER_ALLOW dan HTTPS saja."),
63
- Rule("W-DEBUG", "medium", "WebView debugging aktif",
60
+ "Turn off unless content providers are needed."),
61
+ Rule("W-MIXED", "high", "Mixed content allowed",
62
+ r"MIXED_CONTENT_ALWAYS_ALLOW", "Use MIXED_CONTENT_NEVER_ALLOW and HTTPS only."),
63
+ Rule("W-DEBUG", "medium", "WebView debugging enabled",
64
64
  r"setWebContentsDebuggingEnabled\(\s*true",
65
- "Bungkus dengan BuildConfig.DEBUG atau (applicationInfo.flags and FLAG_DEBUGGABLE)."),
66
- Rule("W-LOADURL-HTTP", "high", "WebView memuat URL http",
67
- r"(loadUrl|loadDataWithBaseURL)\(\s*\"http://", "Gunakan HTTPS."),
68
- Rule("W-LOADURL-DYN", "low", "loadUrl dengan nilai dinamis",
69
- r"\.loadUrl\(\s*[^\"\s)]", "Pastikan URL divalidasi terhadap allowlist skema dan host sebelum dimuat.",
65
+ "Guard with BuildConfig.DEBUG or (applicationInfo.flags and FLAG_DEBUGGABLE)."),
66
+ Rule("W-LOADURL-HTTP", "high", "WebView loads an http URL",
67
+ r"(loadUrl|loadDataWithBaseURL)\(\s*\"http://", "Use HTTPS."),
68
+ Rule("W-LOADURL-DYN", "low", "loadUrl with a dynamic value",
69
+ r"\.loadUrl\(\s*[^\"\s)]", "Make sure the URL is validated against a scheme and host allowlist before loading.",
70
70
  neg=r"javascript:", conf="low"),
71
- Rule("W-LOADDATA", "medium", "loadData dengan interpolasi",
71
+ Rule("W-LOADDATA", "medium", "loadData with interpolation",
72
72
  r"(loadData|loadDataWithBaseURL)\(.*(\$\{?\w|\+\s*\w)",
73
- "Escape atau hindari menyisipkan data tak tepercaya ke HTML."),
74
- Rule("W-EVALJS", "medium", "evaluateJavascript dengan interpolasi",
73
+ "Escape, or avoid interpolating untrusted data into HTML."),
74
+ Rule("W-EVALJS", "medium", "evaluateJavascript with interpolation",
75
75
  r"evaluateJavascript\(.*(\$\{?\w|\"\s*\+|\+\s*\")",
76
- "Kirim data lewat JSON yang di-escape atau postWebMessage, jangan merangkai string."),
77
- Rule("W-SSL", "critical", "Mengabaikan error SSL di WebView",
78
- r"onReceivedSslError", "Jangan panggil handler.proceed(). Panggil cancel().",
76
+ "Send data via escaped JSON or postWebMessage, do not build strings."),
77
+ Rule("W-SSL", "critical", "SSL error ignored in WebView",
78
+ r"onReceivedSslError", "Do not call handler.proceed(). Call cancel().",
79
79
  need=r"\.proceed\(\)", window=6),
80
- # Komponen dan intent
81
- Rule("C-REDIRECT", "medium", "Kemungkinan intent redirection",
80
+ # Components and intents
81
+ Rule("C-REDIRECT", "medium", "Possible intent redirection",
82
82
  r"getParcelableExtra(<Intent>)?\(|getParcelable(<Intent>)?\(.*Intent",
83
- "Jangan meluncurkan Intent yang diterima dari luar. Validasi komponen tujuan dan hapus flag URI permission.",
83
+ "Do not launch an Intent received from outside. Validate the target component and strip URI permission flags.",
84
84
  need=r"Intent", conf="low"),
85
- Rule("C-PENDING", "high", "PendingIntent tanpa flag mutability",
85
+ Rule("C-PENDING", "high", "PendingIntent without a mutability flag",
86
86
  r"PendingIntent\.get(Activity|Broadcast|Service|Activities|ForegroundService)\(",
87
- "Tambahkan FLAG_IMMUTABLE (atau FLAG_MUTABLE bila benar-benar perlu) dan Intent eksplisit.",
87
+ "Add FLAG_IMMUTABLE (or FLAG_MUTABLE only when truly needed) and an explicit Intent.",
88
88
  neg=r"FLAG_IMMUTABLE|FLAG_MUTABLE", window=3),
89
- Rule("C-RECEIVER", "medium", "registerReceiver tanpa flag export",
90
- r"registerReceiver\(", "Pada Android 13+ tentukan RECEIVER_NOT_EXPORTED bila tidak untuk aplikasi lain.",
89
+ Rule("C-RECEIVER", "medium", "registerReceiver without an export flag",
90
+ r"registerReceiver\(", "On Android 13+ set RECEIVER_NOT_EXPORTED unless it is meant for other apps.",
91
91
  neg=r"RECEIVER_NOT_EXPORTED|RECEIVER_EXPORTED", window=2),
92
- Rule("C-BROADCAST", "low", "sendBroadcast tanpa batas penerima",
93
- r"sendBroadcast\(", "Gunakan setPackage atau izin penerima agar data tidak bocor ke aplikasi lain.",
92
+ Rule("C-BROADCAST", "low", "sendBroadcast without a receiver limit",
93
+ r"sendBroadcast\(", "Use setPackage or a receiver permission so data does not leak to other apps.",
94
94
  neg=r"setPackage|permission|Permission", window=2, conf="low"),
95
- Rule("C-IMPLICIT", "medium", "startActivity dengan Intent implisit dari data dinamis",
95
+ Rule("C-IMPLICIT", "medium", "startActivity with an implicit Intent from dynamic data",
96
96
  r"Intent\(\s*Intent\.ACTION_VIEW\s*,\s*Uri\.parse\(\s*[^\"\s)]",
97
- "Validasi skema dan host Uri sebelum membuka. Tangani ActivityNotFoundException.", conf="low"),
98
- Rule("C-FILEPROVIDER", "high", "FileProvider membuka path root",
99
- r"<root-path|<external-path\s+[^>]*path=\"\.?/?\"", "Batasi path FileProvider ke subfolder spesifik.", kinds="xml"),
100
- # Data sensitif di UI
101
- Rule("U-LOG", "high", "Data sensitif ditulis ke log",
97
+ "Validate the Uri scheme and host before opening. Handle ActivityNotFoundException.", conf="low"),
98
+ Rule("C-FILEPROVIDER", "high", "FileProvider opens a root path",
99
+ r"<root-path|<external-path\s+[^>]*path=\"\.?/?\"", "Restrict FileProvider paths to a specific subfolder.", kinds="xml"),
100
+ # Sensitive data in the UI
101
+ Rule("U-LOG", "high", "Sensitive data written to logs",
102
102
  r"(Log\.[dviwe]|Timber\.[dviwe]|println)\s*\(.*" + SENS,
103
- "Hapus log atau jangan sertakan nilai sensitif. Pastikan log debug dibuang di release.", flags=I),
104
- Rule("U-STACKTRACE", "low", "printStackTrace dan pesan exception ke UI",
103
+ "Remove the log or do not include sensitive values. Make sure debug logging is stripped in release.", flags=I),
104
+ Rule("U-STACKTRACE", "low", "printStackTrace and exception messages to the UI",
105
105
  r"printStackTrace\(\)|Toast\.makeText\(.*(\.message|\.localizedMessage|\.toString\(\))",
106
- "Log ringkas via logger yang dimatikan di release. Tampilkan pesan generik ke pengguna."),
107
- Rule("U-CLIPBOARD", "medium", "Data sensitif disalin ke clipboard",
106
+ "Log concisely via a logger disabled in release. Show a generic message to the user."),
107
+ Rule("U-CLIPBOARD", "medium", "Sensitive data copied to the clipboard",
108
108
  r"(setPrimaryClip|ClipData\.newPlainText)\(.*" + SENS,
109
- "Hindari menyalin data sensitif. Jika perlu, tandai ClipDescription.EXTRA_IS_SENSITIVE dan hapus otomatis.", flags=I),
110
- Rule("U-SAVEABLE", "medium", "Data sensitif disimpan di rememberSaveable",
109
+ "Avoid copying sensitive data. If needed, mark ClipDescription.EXTRA_IS_SENSITIVE and clear it automatically.", flags=I),
110
+ Rule("U-SAVEABLE", "medium", "Sensitive data stored in rememberSaveable",
111
111
  r"(rememberSaveable.*" + SENS + r"|" + SENS + r".*rememberSaveable)",
112
- "State disimpan ke Bundle dan bisa bertahan di process death. Pakai remember biasa untuk rahasia.", flags=I),
113
- Rule("U-PWFIELD", "medium", "Field password tanpa transformasi atau tipe keyboard",
114
- r"\b(Outlined)?(Basic)?TextField\(", "Gunakan PasswordVisualTransformation dan KeyboardType.Password. Pertimbangkan tombol tampilkan sementara.",
112
+ "State is persisted to the Bundle and can survive process death. Use plain remember for secrets.", flags=I),
113
+ Rule("U-PWFIELD", "medium", "Password field without transformation or keyboard type",
114
+ r"\b(Outlined)?(Basic)?TextField\(", "Use PasswordVisualTransformation and KeyboardType.Password. Consider a temporary show toggle.",
115
115
  need=r"password|passwd|kata sandi", neg=r"PasswordVisualTransformation|KeyboardType\.(Password|NumberPassword)",
116
116
  window=25, flags=I),
117
- Rule("U-INPUTTYPE", "medium", "EditText sensitif tanpa inputType password",
118
- r"<EditText|<com\.google\.android\.material\.textfield\.TextInputEditText", "Set android:inputType=\"textPassword\" untuk field rahasia.",
117
+ Rule("U-INPUTTYPE", "medium", "Sensitive EditText without a password inputType",
118
+ r"<EditText|<com\.google\.android\.material\.textfield\.TextInputEditText", "Set android:inputType=\"textPassword\" for secret fields.",
119
119
  kinds="xml", need=r"password|pin|otp", neg=r"inputType=\"[^\"]*(Password|numberPassword)", window=8, flags=I, conf="low"),
120
- Rule("U-AUTOFILL", "info", "AutoFill diaktifkan manual",
121
- r"importantForAutofill\s*=\s*\"yes\"", "Pastikan field sensitif tidak mengirim data ke layanan autofill pihak ketiga yang tidak diinginkan.", kinds="xml"),
122
- # Secret
123
- Rule("S-SECRET", "high", "Secret hardcode",
120
+ Rule("U-AUTOFILL", "info", "AutoFill enabled manually",
121
+ r"importantForAutofill\s*=\s*\"yes\"", "Make sure sensitive fields do not send data to an unwanted third-party autofill service.", kinds="xml"),
122
+ # Secrets
123
+ Rule("S-SECRET", "high", "Hardcoded secret",
124
124
  r"(api[_-]?key|secret|passwd|password|token|bearer|client[_-]?secret)\w*\s*(=|:)\s*\"(?=[A-Za-z_\-/+=.]*\d)(?=[0-9_\-/+=.]*[A-Za-z])[A-Za-z0-9_\-/+=.]{16,}\"",
125
- "Jangan simpan secret di APK. Pindahkan ke backend atau gunakan proxy. Rotasi kunci yang sudah terlanjur dikomit.",
125
+ "Do not store secrets in the APK. Move them to the backend or a proxy. Rotate any key that was already committed.",
126
126
  kinds="all", neg=r"BuildConfig|R\.string|getString|stringResource|example|your_|changeme|xxxx", flags=I, conf="low"),
127
- Rule("S-PRIVKEY", "critical", "Kunci privat di source",
128
- r"-----BEGIN (RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----", "Hapus dari repo, rotasi, dan bersihkan histori git.", kinds="all"),
129
- Rule("S-AWS", "critical", "Access key AWS",
130
- r"\bAKIA[0-9A-Z]{16}\b", "Cabut dan rotasi segera.", kinds="all"),
131
- Rule("S-GOOGLEKEY", "medium", "API key Google di source",
132
- r"\bAIza[0-9A-Za-z_\-]{35}\b", "Batasi key di console (package name + SHA-1, daftar API). Jangan pakai key tanpa batasan.", kinds="all"),
133
- Rule("S-TOKENFMT", "high", "Token berformat dikenal",
134
- r"\b(ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9]{32,})\b", "Cabut dan rotasi.", kinds="all"),
135
- # Penyimpanan
136
- Rule("S-PREFS", "medium", "Data sensitif di SharedPreferences biasa",
137
- r"(putString|edit\(\).*put\w+)\(\s*\"[^\"]*" + SENS, "Simpan rahasia dengan enkripsi berbasis Android Keystore (cek rekomendasi terbaru untuk library enkripsi yang dipakai).", flags=I),
138
- Rule("S-WORLD", "high", "Mode file world-readable/writable",
139
- r"MODE_WORLD_(READABLE|WRITEABLE)", "Gunakan MODE_PRIVATE."),
140
- Rule("S-EXTERNAL", "low", "Penyimpanan eksternal",
141
- r"getExternalStorageDirectory\(|Environment\.getExternalStorage", "Jangan simpan data sensitif di eksternal. Pakai penyimpanan privat aplikasi."),
142
- # Jaringan
143
- Rule("N-HTTP", "medium", "URL http (cleartext)",
144
- r"\"http://(?!localhost|127\.0\.0\.1|10\.0\.2\.2|schemas\.android\.com|www\.w3\.org|schemas\.microsoft)", "Gunakan HTTPS.", kinds="all"),
145
- Rule("N-HOSTNAME", "critical", "HostnameVerifier menerima semua",
127
+ Rule("S-PRIVKEY", "critical", "Private key in source",
128
+ r"-----BEGIN (RSA |EC |OPENSSH |DSA )?PRIVATE KEY-----", "Remove from the repo, rotate, and clean git history.", kinds="all"),
129
+ Rule("S-AWS", "critical", "AWS access key",
130
+ r"\bAKIA[0-9A-Z]{16}\b", "Revoke and rotate immediately.", kinds="all"),
131
+ Rule("S-GOOGLEKEY", "medium", "Google API key in source",
132
+ r"\bAIza[0-9A-Za-z_\-]{35}\b", "Restrict the key in the console (package name + SHA-1, API allowlist). Do not use an unrestricted key.", kinds="all"),
133
+ Rule("S-TOKENFMT", "high", "Token in a known format",
134
+ r"\b(ghp_[A-Za-z0-9]{36}|xox[baprs]-[A-Za-z0-9-]{10,}|sk-[A-Za-z0-9]{32,})\b", "Revoke and rotate.", kinds="all"),
135
+ # Storage
136
+ Rule("S-PREFS", "medium", "Sensitive data in plain SharedPreferences",
137
+ r"(putString|edit\(\).*put\w+)\(\s*\"[^\"]*" + SENS, "Store secrets with Android Keystore-backed encryption (check the current recommendation for the encryption library in use).", flags=I),
138
+ Rule("S-WORLD", "high", "World-readable/writable file mode",
139
+ r"MODE_WORLD_(READABLE|WRITEABLE)", "Use MODE_PRIVATE."),
140
+ Rule("S-EXTERNAL", "low", "External storage",
141
+ r"getExternalStorageDirectory\(|Environment\.getExternalStorage", "Do not store sensitive data on external storage. Use the app's private storage."),
142
+ # Network
143
+ Rule("N-HTTP", "medium", "http URL (cleartext)",
144
+ r"\"http://(?!localhost|127\.0\.0\.1|10\.0\.2\.2|schemas\.android\.com|www\.w3\.org|schemas\.microsoft)", "Use HTTPS.", kinds="all"),
145
+ Rule("N-HOSTNAME", "critical", "HostnameVerifier accepts everything",
146
146
  r"ALLOW_ALL_HOSTNAME_VERIFIER|HostnameVerifier\s*\{[^}]*\btrue\b|hostnameVerifier\s*\{\s*_\s*,\s*_\s*->\s*true",
147
- "Hapus. Gunakan verifikasi default."),
148
- Rule("N-TRUSTALL", "critical", "TrustManager menerima semua",
149
- r"object\s*:\s*X509TrustManager|implements\s+X509TrustManager|new\s+X509TrustManager", "Jangan implementasi TrustManager kustom yang melewati validasi. Gunakan network_security_config atau CertificatePinner.",
147
+ "Remove. Use the default verification."),
148
+ Rule("N-TRUSTALL", "critical", "TrustManager accepts everything",
149
+ r"object\s*:\s*X509TrustManager|implements\s+X509TrustManager|new\s+X509TrustManager", "Do not implement a custom TrustManager that bypasses validation. Use network_security_config or CertificatePinner.",
150
150
  need=r"checkServerTrusted\s*\([^)]*\)\s*(:\s*\w+\s*)?\{\s*(//[^\n]*\n\s*)*\}", window=12),
151
- Rule("N-PINNING", "info", "OkHttp tanpa CertificatePinner (cek manual)",
152
- r"OkHttpClient\.Builder\(\)", "Untuk aplikasi berisiko tinggi, pertimbangkan certificate pinning dengan strategi rotasi.",
151
+ Rule("N-PINNING", "info", "OkHttp without a CertificatePinner (check manually)",
152
+ r"OkHttpClient\.Builder\(\)", "For high-risk apps, consider certificate pinning with a rotation strategy.",
153
153
  neg=r"certificatePinner|CertificatePinner", window=15, conf="low"),
154
- # Input dan injeksi
155
- Rule("I-SQL", "high", "SQL dirangkai dari string",
156
- r"(rawQuery|execSQL|SimpleSQLiteQuery)\(.*(\+\s*\w|\$\{?\w)", "Gunakan parameter binding (?) atau Room dengan @Query berparameter."),
157
- Rule("I-PATH", "medium", "Path file dari input luar",
158
- r"File\(.*(getStringExtra|getQueryParameter|lastPathSegment|\.path\b|getString\()",
159
- "Normalisasi dengan canonicalPath dan pastikan berada di direktori yang diizinkan. Tolak '..'.", conf="low"),
160
- Rule("I-DEEPLINK", "info", "Parameter deep link dipakai",
161
- r"getQueryParameter\(|intent\??\.data\b|intent\??\.getStringExtra\(", "Validasi tipe, panjang, dan nilai. Jangan pakai langsung untuk navigasi atau query.", conf="low"),
162
- Rule("I-HTML", "low", "Html.fromHtml dari data dinamis",
163
- r"Html\.fromHtml\(\s*[^\"\s)]", "Pastikan sumber tepercaya. Hindari merender HTML dari input pengguna.", conf="low"),
164
- Rule("I-RANDOM", "medium", "Random non-kriptografis untuk nilai keamanan",
165
- r"\bjava\.util\.Random\(|\bRandom\(\)|Math\.random\(\)", "Pakai SecureRandom untuk token, OTP, nonce.",
154
+ # Inputs and injection
155
+ Rule("I-SQL", "high", "SQL built from strings",
156
+ r"(rawQuery|execSQL|SimpleSQLiteQuery)\(.*(\+\s*\w|\$\{?\w)", "Use parameter binding (?) or Room with a parameterized @Query."),
157
+ Rule("I-PATH", "medium", "File path from external input",
158
+ r"File\(.*( getStringExtra|getQueryParameter|lastPathSegment|\.path\b|getString\()",
159
+ "Normalize with canonicalPath and make sure it stays inside an allowed directory. Reject '..'.", conf="low"),
160
+ Rule("I-DEEPLINK", "info", "Deep link parameter used",
161
+ r"getQueryParameter\(|intent\??\.data\b|intent\??\.getStringExtra\(", "Validate type, length, and value. Do not use it directly for navigation or queries.", conf="low"),
162
+ Rule("I-HTML", "low", "Html.fromHtml from dynamic data",
163
+ r"Html\.fromHtml\(\s*[^\"\s)]", "Make sure the source is trusted. Avoid rendering HTML from user input.", conf="low"),
164
+ Rule("I-RANDOM", "medium", "Non-crypto Random for security values",
165
+ r"\bjava\.util\.Random\(|\bRandom\(\)|Math\.random\(\)", "Use SecureRandom for tokens, OTPs, nonces.",
166
166
  need=r"token|otp|session|password|nonce|key", window=3, flags=I),
167
- Rule("I-HASH", "medium", "Hash lemah",
168
- r"MessageDigest\.getInstance\(\s*\"(MD5|SHA-?1)\"\s*\)", "Pakai SHA-256 atau lebih kuat. Untuk password gunakan KDF di server."),
169
- Rule("I-CIPHER", "high", "Cipher lemah atau mode ECB",
170
- r"Cipher\.getInstance\(\s*\"(AES|DES|DESede|RC4|Blowfish)(/ECB/\w+)?\"\s*\)", "Pakai AES/GCM/NoPadding dengan IV acak per pesan."),
167
+ Rule("I-HASH", "medium", "Weak hash",
168
+ r"MessageDigest\.getInstance\(\s*\"(MD5|SHA-?1)\"\s*\)", "Use SHA-256 or stronger. For passwords use a server-side KDF."),
169
+ Rule("I-CIPHER", "high", "Weak cipher or ECB mode",
170
+ r"Cipher\.getInstance\(\s*\"(AES|DES|DESede|RC4|Blowfish)(/ECB/\w+)?\"\s*\)", "Use AES/GCM/NoPadding with a random IV per message."),
171
171
  ]
172
172
 
173
173
  PROJECT_NOTES = []
@@ -235,7 +235,7 @@ def scan_manifest(path, text, findings):
235
235
  return
236
236
  if is_debug_path(path) and sev in ("high", "medium"):
237
237
  sev = "info"
238
- title += " (source set debug)"
238
+ title += " (debug source set)"
239
239
  findings.append(dict(rule=rid, severity=sev, title=title, file=path, line=ln,
240
240
  snippet=needle[:160], advice=advice, confidence=conf))
241
241
 
@@ -246,12 +246,12 @@ def scan_manifest(path, text, findings):
246
246
  app = root.find("application")
247
247
  if app is not None:
248
248
  if app.get(ANDROID_NS + "debuggable") == "true":
249
- add("M-DEBUGGABLE", "high", "debuggable=true", "android:debuggable", "Hapus atribut. Biarkan build type yang mengatur.")
249
+ add("M-DEBUGGABLE", "high", "debuggable=true", "android:debuggable", "Remove the attribute. Let the build type decide.")
250
250
  if app.get(ANDROID_NS + "allowBackup") == "true":
251
251
  add("M-BACKUP", "medium", "allowBackup=true", "android:allowBackup",
252
- "Set false atau definisikan dataExtractionRules dan fullBackupContent yang mengecualikan data sensitif.")
252
+ "Set false, or define dataExtractionRules and fullBackupContent that exclude sensitive data.")
253
253
  if app.get(ANDROID_NS + "usesCleartextTraffic") == "true":
254
- add("M-CLEARTEXT", "high", "usesCleartextTraffic=true", "android:usesCleartextTraffic", "Set false dan gunakan HTTPS.")
254
+ add("M-CLEARTEXT", "high", "usesCleartextTraffic=true", "android:usesCleartextTraffic", "Set false and use HTTPS.")
255
255
  for comp in app:
256
256
  tag = comp.tag
257
257
  if tag not in ("activity", "activity-alias", "service", "receiver", "provider"):
@@ -263,22 +263,22 @@ def scan_manifest(path, text, findings):
263
263
  launcher = any(c.get(ANDROID_NS + "name") == "android.intent.category.LAUNCHER"
264
264
  for f in filters for c in f.findall("category"))
265
265
  if filters and exported is None:
266
- add("M-EXPORT-IMPLICIT", "high", f"{tag} dengan intent-filter tanpa android:exported ({name})", name,
267
- "Android 12+ mewajibkan atribut eksplisit. Set true hanya jika memang untuk aplikasi lain.")
266
+ add("M-EXPORT-IMPLICIT", "high", f"{tag} with an intent-filter and no android:exported ({name})", name,
267
+ "Android 12+ requires the attribute explicitly. Set true only if it is meant for other apps.")
268
268
  if exported == "true" and not launcher:
269
269
  if tag == "activity" or tag == "activity-alias":
270
- add("M-EXPORT", "medium", f"Activity exported ({name})", name,
271
- "Validasi semua extra dan data intent. Pertimbangkan izin atau exported=false.", "medium")
270
+ add("M-EXPORT", "medium", f"Exported activity ({name})", name,
271
+ "Validate all intent extras and data. Consider a permission or exported=false.", "medium")
272
272
  elif not perm and tag != "provider":
273
- add("M-EXPORT", "high", f"{tag} exported tanpa permission ({name})", name,
274
- "Set exported=false atau lindungi dengan permission signature-level.")
273
+ add("M-EXPORT", "high", f"{tag} exported without a permission ({name})", name,
274
+ "Set exported=false or protect it with a signature-level permission.")
275
275
  if tag == "provider":
276
276
  if exported == "true":
277
- add("M-PROVIDER", "high", f"ContentProvider exported ({name})", name,
278
- "Set exported=false, atau lindungi dengan readPermission/writePermission dan batasi path.")
277
+ add("M-PROVIDER", "high", f"Exported ContentProvider ({name})", name,
278
+ "Set exported=false, or protect it with readPermission/writePermission and restrict the paths.")
279
279
  if comp.get(ANDROID_NS + "grantUriPermissions") == "true":
280
280
  add("M-GRANT", "medium", f"grantUriPermissions=true ({name})", name,
281
- "Batasi dengan <grant-uri-permission> pada path tertentu.", "medium")
281
+ "Restrict with <grant-uri-permission> on specific paths.", "medium")
282
282
  for f in filters:
283
283
  cats = {c.get(ANDROID_NS + "name") for c in f.findall("category")}
284
284
  datas = f.findall("data")
@@ -286,39 +286,39 @@ def scan_manifest(path, text, findings):
286
286
  schemes = {d.get(ANDROID_NS + "scheme") for d in datas if d.get(ANDROID_NS + "scheme")}
287
287
  web = bool(schemes & {"http", "https"})
288
288
  if web and f.get(ANDROID_NS + "autoVerify") != "true":
289
- add("M-APPLINK", "low", f"Link web tanpa autoVerify ({name})", name,
290
- "Gunakan Android App Links terverifikasi (assetlinks.json) agar tidak bisa dibajak aplikasi lain.", "medium")
289
+ add("M-APPLINK", "low", f"Web link without autoVerify ({name})", name,
290
+ "Use verified Android App Links (assetlinks.json) so it cannot be hijacked by another app.", "medium")
291
291
  add("M-DEEPLINK", "info", f"Deep link {sorted(schemes)} ({name})", name,
292
- "Perlakukan semua parameter sebagai input tak tepercaya.", "medium")
292
+ "Treat all parameters as untrusted input.", "medium")
293
293
  risky = {
294
- "SYSTEM_ALERT_WINDOW": ("medium", "Izin overlay meningkatkan risiko tapjacking dan phishing UI."),
295
- "MANAGE_EXTERNAL_STORAGE": ("medium", "Akses semua file. Gunakan SAF atau MediaStore."),
296
- "REQUEST_INSTALL_PACKAGES": ("low", "Pastikan benar-benar perlu memasang paket."),
297
- "READ_EXTERNAL_STORAGE": ("low", "Pertimbangkan Photo Picker atau SAF."),
298
- "WRITE_EXTERNAL_STORAGE": ("low", "Pertimbangkan MediaStore atau SAF."),
299
- "READ_SMS": ("medium", "Gunakan SMS Retriever API untuk OTP."),
300
- "RECEIVE_SMS": ("medium", "Gunakan SMS Retriever API untuk OTP."),
294
+ "SYSTEM_ALERT_WINDOW": ("medium", "The overlay permission increases tapjacking and UI phishing risk."),
295
+ "MANAGE_EXTERNAL_STORAGE": ("medium", "All-files access. Use SAF or MediaStore."),
296
+ "REQUEST_INSTALL_PACKAGES": ("low", "Make sure installing packages is truly needed."),
297
+ "READ_EXTERNAL_STORAGE": ("low", "Consider the Photo Picker or SAF."),
298
+ "WRITE_EXTERNAL_STORAGE": ("low", "Consider MediaStore or SAF."),
299
+ "READ_SMS": ("medium", "Use the SMS Retriever API for OTPs."),
300
+ "RECEIVE_SMS": ("medium", "Use the SMS Retriever API for OTPs."),
301
301
  }
302
302
  for up in root.findall("uses-permission"):
303
303
  n = (up.get(ANDROID_NS + "name") or "").split(".")[-1]
304
304
  if n in risky:
305
305
  sev, adv = risky[n]
306
- add("M-PERM", sev, f"Izin {n}", n, adv, "medium")
306
+ add("M-PERM", sev, f"Permission {n}", n, adv, "medium")
307
307
 
308
308
 
309
309
  def scan_nsc(path, text, findings):
310
310
  debug_start = text.find("<debug-overrides")
311
311
  debug_end = text.find("</debug-overrides>")
312
312
  for m in re.finditer(r'cleartextTrafficPermitted\s*=\s*"true"', text):
313
- findings.append(dict(rule="N-NSC-CLEAR", severity="high", title="network_security_config mengizinkan cleartext",
313
+ findings.append(dict(rule="N-NSC-CLEAR", severity="high", title="network_security_config allows cleartext",
314
314
  file=path, line=text.count("\n", 0, m.start()) + 1, snippet=m.group(0),
315
- advice="Set false. Kecualikan hanya domain dev tertentu di debug-overrides.", confidence="high"))
315
+ advice="Set false. Only exclude specific dev domains in debug-overrides.", confidence="high"))
316
316
  for m in re.finditer(r'<certificates\s+src\s*=\s*"user"', text):
317
317
  in_debug = debug_start != -1 and debug_start < m.start() < (debug_end if debug_end != -1 else len(text))
318
318
  findings.append(dict(rule="N-NSC-USER", severity="info" if in_debug else "medium",
319
- title="Trust anchor sertifikat pengguna" + (" (debug-overrides)" if in_debug else ""),
319
+ title="User certificate trust anchor" + (" (debug-overrides)" if in_debug else ""),
320
320
  file=path, line=text.count("\n", 0, m.start()) + 1, snippet=m.group(0),
321
- advice="Jangan percayai CA pengguna di release.", confidence="high"))
321
+ advice="Do not trust user CAs in release.", confidence="high"))
322
322
 
323
323
 
324
324
  def project_checks(files_text, findings):
@@ -327,14 +327,14 @@ def project_checks(files_text, findings):
327
327
  if sensitive:
328
328
  all_text = "\n".join(files_text.values())
329
329
  if "FLAG_SECURE" not in all_text and "setSecure" not in all_text:
330
- findings.append(dict(rule="U-SECURE", severity="medium", title="Layar sensitif tanpa FLAG_SECURE",
331
- file=sensitive[0], line=1, snippet="(tingkat proyek: FLAG_SECURE tidak ditemukan)",
332
- advice="Set WindowManager.LayoutParams.FLAG_SECURE pada layar login, OTP, PIN, dan pembayaran untuk mencegah screenshot dan pratinjau recents.",
330
+ findings.append(dict(rule="U-SECURE", severity="medium", title="Sensitive screen without FLAG_SECURE",
331
+ file=sensitive[0], line=1, snippet="(project level: FLAG_SECURE not found)",
332
+ advice="Set WindowManager.LayoutParams.FLAG_SECURE on login, OTP, PIN, and payment screens to block screenshots and the recents preview.",
333
333
  confidence="medium"))
334
334
  if not re.search(r"filterTouchesWhenObscured|FLAG_WINDOW_IS_OBSCURED|MotionEvent\.FLAG_WINDOW_IS_PARTIALLY_OBSCURED", all_text):
335
- findings.append(dict(rule="U-TAPJACK", severity="low", title="Tidak ada perlindungan tapjacking",
336
- file=sensitive[0], line=1, snippet="(tingkat proyek)",
337
- advice="Untuk tombol aksi sensitif, set filterTouchesWhenObscured=true (View) atau periksa flag obscured pada event sentuh di Compose.",
335
+ findings.append(dict(rule="U-TAPJACK", severity="low", title="No tapjacking protection",
336
+ file=sensitive[0], line=1, snippet="(project level)",
337
+ advice="For sensitive action buttons, set filterTouchesWhenObscured=true (Views) or check the obscured flags on touch events in Compose.",
338
338
  confidence="low"))
339
339
 
340
340
 
@@ -372,17 +372,17 @@ def main():
372
372
  if a.format == "json":
373
373
  body = json.dumps({"counts": counts, "files_scanned": len(files_text), "findings": findings}, indent=2, ensure_ascii=False)
374
374
  elif a.format == "md":
375
- out = ["# Laporan pemindaian keamanan UI Android", "",
376
- f"File dipindai: {len(files_text)}", "",
377
- "| Tingkat | Jumlah |", "|---|---|"]
375
+ out = ["# Android UI security scan report", "",
376
+ f"Files scanned: {len(files_text)}", "",
377
+ "| Severity | Count |", "|---|---|"]
378
378
  out += [f"| {s} | {counts.get(s, 0)} |" for s in reversed(SEV)]
379
- out += ["", "Pemindai ini berbasis pola. Verifikasi setiap temuan secara manual sebelum menyimpulkan.", ""]
379
+ out += ["", "This scanner is pattern-based. Verify every finding manually before drawing conclusions.", ""]
380
380
  for f in findings:
381
381
  out += [f"## [{f['severity'].upper()}] {f['rule']}: {f['title']}", "",
382
- f"- Lokasi: `{f['file']}:{f['line']}`",
383
- f"- Keyakinan: {f['confidence']}",
384
- f"- Cuplikan: `{f['snippet']}`",
385
- f"- Perbaikan: {f['advice']}", ""]
382
+ f"- Location: `{f['file']}:{f['line']}`",
383
+ f"- Confidence: {f['confidence']}",
384
+ f"- Snippet: `{f['snippet']}`",
385
+ f"- Fix: {f['advice']}", ""]
386
386
  body = "\n".join(out)
387
387
  else:
388
388
  out = []
@@ -392,14 +392,14 @@ def main():
392
392
  out.append(f" > {f['snippet']}")
393
393
  out.append(f" -> {f['advice']}")
394
394
  out.append("")
395
- out.append("Ringkasan: " + ", ".join(f"{counts.get(s, 0)} {s}" for s in reversed(SEV))
396
- + f" | file dipindai: {len(files_text)}")
395
+ out.append("Summary: " + ", ".join(f"{counts.get(s, 0)} {s}" for s in reversed(SEV))
396
+ + f" | files scanned: {len(files_text)}")
397
397
  body = "\n".join(out)
398
398
 
399
399
  if a.out:
400
400
  with open(a.out, "w", encoding="utf-8") as fh:
401
401
  fh.write(body + "\n")
402
- print(f"Laporan ditulis ke {a.out} ({len(findings)} temuan)")
402
+ print(f"Report written to {a.out} ({len(findings)} findings)")
403
403
  else:
404
404
  print(body)
405
405
 
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  /**
4
- * Wrapper npm untuk android-skills.
5
- * Menjalankan install.py dengan argumen yang sama.
4
+ * npx wrapper for android-skills.
5
+ * Runs install.py with the same arguments.
6
6
  *
7
- * Contoh:
7
+ * Examples:
8
8
  * npx tamvanpr/android-skills --target claude --project .
9
9
  * npx tamvanpr/android-skills --target cursor
10
10
  * npm i -g android-skills && android-skills --help
11
11
  *
12
- * Catatan: installer ini ditulis dalam Python (butuh python3 di mesin).
13
- * Bila python3 tidak ada, pesan instalasi diberikan.
12
+ * Note: the installer is written in Python (requires python3 on the machine).
13
+ * If python3 is missing, an installation message is shown.
14
14
  */
15
15
  const { spawnSync } = require("child_process");
16
16
  const fs = require("fs");
@@ -27,18 +27,18 @@ function findPython() {
27
27
  const py = findPython();
28
28
  if (!py) {
29
29
  console.error(
30
- "python3 tidak ditemukan di PATH.\n" +
31
- "Installer android-skills ditulis dalam Python.\n" +
32
- "Pilihan:\n" +
30
+ "python3 not found in PATH.\n" +
31
+ "The android-skills installer is written in Python.\n" +
32
+ "Options:\n" +
33
33
  " 1) Install Python: pkg install python / apt install python3 / winget install Python.Python.3.12\n" +
34
- " 2) Atau gunakan git clone langsung: git clone https://github.com/tamvanpr/android-skills && python3 install.py --help"
34
+ " 2) Or clone the repo directly: git clone https://github.com/tamvanpr/android-skills && python3 install.py --help"
35
35
  );
36
36
  process.exit(1);
37
37
  }
38
38
 
39
39
  const script = path.join(__dirname, "..", "install.py");
40
40
  if (!fs.existsSync(script)) {
41
- console.error("install.py tidak ditemukan di " + script);
41
+ console.error("install.py not found at " + script);
42
42
  process.exit(1);
43
43
  }
44
44