-
Notifications
You must be signed in to change notification settings - Fork 0
Codex/security coderabbit fixes #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,4 @@ data/*/runs/ | |
| data/*/reports/ | ||
| findings/ | ||
| comment.md | ||
| .tmp/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,193 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { test } from "node:test"; | ||
| import { androidExportedComponent } from "./android-exported-component.js"; | ||
| import { androidUriShareWithoutClipData } from "./android-uri-share-without-clipdata.js"; | ||
| import { fileproviderBroadPath } from "./fileprovider-broad-path.js"; | ||
| import { foregroundAudioServiceStart } from "./foreground-audio-service-start.js"; | ||
| import { healthConnectSensitiveFlow } from "./health-connect-sensitive-flow.js"; | ||
| import { sensitiveAndroidLog } from "./sensitive-android-log.js"; | ||
|
|
||
| test("health matcher gates on permission helpers and noise-dose writes", () => { | ||
| const writePermission = healthConnectSensitiveFlow.match( | ||
| "HealthPermission.getWritePermission(ExerciseSessionRecord::class)", | ||
| "app/src/main/java/com/dbcheck/app/HealthPermissions.kt", | ||
| ); | ||
| const noiseDose = healthConnectSensitiveFlow.match( | ||
| "suspend fun sync() = writeNoiseDose(report)", | ||
| "app/src/main/java/com/dbcheck/app/HealthSync.kt", | ||
| ); | ||
|
|
||
| assert.ok(writePermission.some((match) => match.matchedPattern === "Health Connect write permission")); | ||
| assert.ok(noiseDose.some((match) => match.matchedPattern === "Noise-dose write flow")); | ||
| }); | ||
|
|
||
| test("sensitive log matcher covers multiline calls", () => { | ||
| const matches = sensitiveAndroidLog.match( | ||
| `Log.i( | ||
| TAG, | ||
| "Exported session URI: $uri", | ||
| )`, | ||
| "app/src/main/java/com/dbcheck/app/ExportLogger.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| }); | ||
|
|
||
| test("sensitive log matcher does not consume a later Kotlin statement", () => { | ||
| const matches = sensitiveAndroidLog.match( | ||
| `Log.i(TAG, "sync complete") | ||
| val exportedUri = uri`, | ||
| "app/src/main/java/com/dbcheck/app/HealthSync.kt", | ||
| ); | ||
|
|
||
| assert.deepEqual(matches, []); | ||
| }); | ||
|
|
||
| test("sensitive log matcher ignores closing parentheses inside Kotlin comments", () => { | ||
| const matches = sensitiveAndroidLog.match( | ||
| `Log.i( | ||
| TAG, // ) | ||
| "Exported session URI: $uri", | ||
| ) | ||
| Log.w( | ||
| TAG, /* ) */ | ||
| "Backup file URI: $uri", | ||
| )`, | ||
| "app/src/main/java/com/dbcheck/app/ExportLogger.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 2); | ||
| }); | ||
|
|
||
| test("foreground matcher covers direct and ServiceCompat promotion", () => { | ||
| const direct = foregroundAudioServiceStart.match( | ||
| "class MeasurementForegroundService { fun promote() = startForeground(ID, notification) }", | ||
| "app/src/main/java/com/dbcheck/app/MeasurementForegroundService.kt", | ||
| ); | ||
| const compatible = foregroundAudioServiceStart.match( | ||
| "class MeasurementForegroundService { fun promote() = ServiceCompat.startForeground(this, ID, notification, 0) }", | ||
| "app/src/main/java/com/dbcheck/app/MeasurementForegroundService.kt", | ||
| ); | ||
|
|
||
| assert.equal(direct.length, 1); | ||
| assert.equal(compatible.length, 1); | ||
| }); | ||
|
|
||
| test("FileProvider matcher covers single-quoted broad paths", () => { | ||
| const matches = fileproviderBroadPath.match( | ||
| "<paths><cache-path name='cache' path='.'/></paths>", | ||
| "app/src/main/res/xml/file_paths.xml", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| }); | ||
|
|
||
| test("exported component matcher covers single-quoted attributes", () => { | ||
| const matches = androidExportedComponent.match( | ||
| "<manifest><application><service android:name='.SyncService' android:exported='true'/></application></manifest>", | ||
| "app/src/main/AndroidManifest.xml", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| }); | ||
|
|
||
| test("URI share matcher evaluates each share construction independently", () => { | ||
| const content = ` | ||
| fun safe(uri: Uri): Intent = | ||
| Intent(Intent.ACTION_SEND).apply { | ||
| putExtra(Intent.EXTRA_STREAM, uri) | ||
| clipData = ClipData.newUri(resolver, "safe", uri) | ||
| addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
| } | ||
|
|
||
| fun unsafe(uri: Uri): Intent = | ||
| Intent(Intent.ACTION_SEND).apply { | ||
| putExtra(Intent.EXTRA_STREAM, uri) | ||
| } | ||
| `; | ||
|
|
||
| const matches = androidUriShareWithoutClipData.match( | ||
| content, | ||
| "app/src/main/java/com/dbcheck/app/ShareFactory.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| assert.equal( | ||
| matches[0]?.matchedPattern, | ||
| "EXTRA_STREAM content URI share without FLAG_GRANT_READ_URI_PERMISSION", | ||
| ); | ||
| }); | ||
|
|
||
| test("URI share matcher reports a missing ClipData in an otherwise granted scope", () => { | ||
| const matches = androidUriShareWithoutClipData.match( | ||
| `fun share(uri: Uri) = Intent(Intent.ACTION_SEND_MULTIPLE).apply { | ||
| putParcelableArrayListExtra(Intent.EXTRA_STREAM, arrayListOf(uri)) | ||
| addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
| }`, | ||
| "app/src/main/java/com/dbcheck/app/ShareFactory.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| assert.equal(matches[0]?.matchedPattern, "EXTRA_STREAM content URI share without ClipData"); | ||
| }); | ||
|
|
||
| test("URI share matcher bounds an unsafe share to its builder block", () => { | ||
| const matches = androidUriShareWithoutClipData.match( | ||
| `fun share(uri: Uri): Intent { | ||
| val intent = Intent(Intent.ACTION_SEND).apply { | ||
| putExtra(Intent.EXTRA_STREAM, uri) | ||
| } | ||
| val unrelatedClipData = ClipData.newPlainText("preview", "text") | ||
| val unrelatedFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION | ||
| return intent | ||
| }`, | ||
| "app/src/main/java/com/dbcheck/app/ShareFactory.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| assert.equal( | ||
| matches[0]?.matchedPattern, | ||
| "EXTRA_STREAM content URI share without FLAG_GRANT_READ_URI_PERMISSION", | ||
| ); | ||
| }); | ||
|
|
||
| test("URI share matcher continues from a nested constructor to its owning function", () => { | ||
| const matches = androidUriShareWithoutClipData.match( | ||
| `fun share(uri: Uri): Intent { | ||
| val intent = run { | ||
| Intent(Intent.ACTION_SEND) | ||
| } | ||
| intent.putExtra(Intent.EXTRA_STREAM, uri) | ||
| return intent | ||
| }`, | ||
| "app/src/main/java/com/dbcheck/app/ShareFactory.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| assert.equal( | ||
| matches[0]?.matchedPattern, | ||
| "EXTRA_STREAM content URI share without FLAG_GRANT_READ_URI_PERMISSION", | ||
| ); | ||
| }); | ||
|
|
||
| test("URI share matcher recognizes constructor trivia before the opening parenthesis", () => { | ||
| const matches = androidUriShareWithoutClipData.match( | ||
| `fun share(uri: Uri): Intent { | ||
| val intent = Intent /* share constructor */ ( | ||
| Intent.ACTION_SEND | ||
| ).apply { | ||
| putExtra(Intent.EXTRA_STREAM, uri) | ||
| } | ||
| val unrelatedClipData = ClipData.newPlainText("preview", "text") | ||
| val unrelatedFlags = Intent.FLAG_GRANT_READ_URI_PERMISSION | ||
| return intent | ||
| }`, | ||
| "app/src/main/java/com/dbcheck/app/ShareFactory.kt", | ||
| ); | ||
|
|
||
| assert.equal(matches.length, 1); | ||
| assert.equal( | ||
| matches[0]?.matchedPattern, | ||
| "EXTRA_STREAM content URI share without FLAG_GRANT_READ_URI_PERMISSION", | ||
| ); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
EXTRA_STREAMis added insideIntent(...).apply { ... }butclipDataandFLAG_GRANT_READ_URI_PERMISSIONare assigned to that same intent immediately afterward, this return truncates the scope at the closing brace and reports the safe share as missing both protections. Continue through the owning statement/function or track the constructed intent so legitimate post-builder configuration is included.AGENTS.md reference: AGENTS.md:L147-L148
Useful? React with 👍 / 👎.