en un clic
code-review-and-security-audit
// Review code for quality, correctness, and security vulnerabilities. Use when the user asks to review code, audit for security issues, or check for bugs and anti-patterns.
// Review code for quality, correctness, and security vulnerabilities. Use when the user asks to review code, audit for security issues, or check for bugs and anti-patterns.
| name | code-review-and-security-audit |
| description | Review code for quality, correctness, and security vulnerabilities. Use when the user asks to review code, audit for security issues, or check for bugs and anti-patterns. |
| argument-hint | file path, component name, or scope of review |
You are performing code review and security auditing for Low Budget Voice Recognition Input — an on-device Android IME that captures audio and transcribes it via the Gemma 4 E2B ONNX multimodal model.
Two complementary concerns:
!! unless justified.GlobalScope use, dispatchers chosen correctly (Dispatchers.IO for blocking I/O, Dispatchers.Default for CPU work, single-threaded dispatcher for the ONNX session).AudioRecord, OrtSession, OrtEnvironment, FileChannel, OkHttp Response bodies all released in finally or use {}.MutableStateFlow/StateFlow reads/writes follow Compose recomposition rules.remember/rememberSaveable keys, no side effects in composition, LaunchedEffect/DisposableEffect properly keyed, no leaks of the InputMethodService reference into Composables that outlive the IME view.VoiceImeService correctly drives LifecycleRegistry/SavedStateRegistryController across onCreate / onStartInputView / onFinishInputView / onDestroy.runCatching only when the failure mode is genuinely benign.AudioCapture directly in ImeUi.kt is acceptable for the dev skeleton, but flag it once a ViewModel layer exists).when-on-string with sealed types (e.g. language subtype).buildList/buildString.lifecycleScope, repeatOnLifecycle, LifecycleObserver.Log.d, no direct Context reliance where avoidable).This app is an Input Method Editor — it sees what the user is dictating. Treat all transcribed text and captured audio as highly sensitive.
InputConnection text never persists in our process.AudioRecord in the background, never run while onFinishInputView has been called.AudioRecord released on every code path (cancellation, error, success). Confirm recorder.stop() and recorder.release() in finally.RECORD_AUDIO permission on every IME show, not just at process start (user may revoke in Settings while the IME is loaded).huggingface.co/onnx-community/gemma-4-E2B-it-ONNX (HTTPS only).context.filesDir/models/... (app-private storage). Never to external/world-readable storage.<file>.partial, verify, then rename.Range — verify the server's ETag/Content-Length matches between resumes.enable_mem_pattern = false and enable_cpu_mem_arena = false if memory growth is observed.max_new_tokens to prevent runaway generation.VoiceImeService is exported with BIND_INPUT_METHOD permission (correct for IMEs); MainActivity is exported as LAUNCHER. No other components should be exported.RECORD_AUDIO and INTERNET declared; reject any new permission additions without justification.MainActivity doesn't currently consume external intents; if that changes, validate all extras.addJavascriptInterface, no WebView, no dynamic class loading.Cross-check gradle/libs.versions.toml against current advisories for:
androidx.compose.* (Compose BOM)com.microsoft.onnxruntime:onnxruntime-android (when added)androidx.work:work-runtime-ktx (when added)com.squareup.okhttp3:okhttp (when added)Report findings using this structure:
Issues that must be fixed — security vulnerabilities, crashes, data-loss risks, IME confidentiality breaches.
Issues that should be fixed — logic bugs, thread-safety concerns, resource leaks, code smell.
Suggestions for improvement — style, readability, minor optimizations.
For each finding include:
audio/AudioCapture.kt:73)When invoked without arguments, review files changed since the last review or in the current milestone. Without git history available, ask the user which milestone or files to focus on.
When invoked with a specific scope (file, directory, milestone number), focus the review on that area.
For a full audit, systematically review:
ime/)audio/)asr/ — once it exists)model/ — once it exists)MainActivity.kt)AndroidManifest.xml, res/xml/method.xml)gradle/libs.versions.toml)Commit code changes and push via Git. Use when the user asks to commit, push, or save their work to the repository.
Writing/updating project documentation (README, PLAN, PRIVACY-POLICY, NOTICES, changelogs). Use when the user asks to update docs, write changelogs, or modify store listings.
Release engineering tasks — version bumping, building release APKs, tagging releases, writing changelogs. Use when the user asks to prepare a release, bump version, tag, or build for distribution.