Skip to content

security: bind Brew cleanup audit records to private storage - #187

Draft
seonghobae wants to merge 17 commits into
mainfrom
security/brew-cleanup-audit-private-authority-v1
Draft

security: bind Brew cleanup audit records to private storage#187
seonghobae wants to merge 17 commits into
mainfrom
security/brew-cleanup-audit-private-authority-v1

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Purpose

Bind immutable Homebrew cleanup audit publication to the exact private directory object that was authorized, closing shared-writable storage and same-user pathname-replacement authority gaps without changing Homebrew command, model, human-approval, or evidence semantics.

Exact current state

  • exact source head: 8d1733849884bc517171e44065e1219568120e66
  • protected main: 93aa7477629753187da101a8af0e7276480f1a86
  • main -> head is ahead-only with merge base exactly protected main; semantic delta remains exactly four paths: src-tauri/Cargo.toml, src-tauri/src/brew_cleanup.rs, src-tauri/src/brew_cleanup_audit_authority_tests.rs, and src-tauri/src/lib.rs
  • current Release 32318545189 completed success; Test 32318545203, Security Scan 32318545190, and SAST Semgrep 32318545195 are queued and therefore non-passing
  • PR remains Draft; mergeability is not merge authorization

Test-first security repair

The implementation proves the object-bound publication contract by opening the audit directory with no-follow directory semantics, validating opened object and pathname device/inode identity plus private mode, creating immutable records descriptor-relative with openat(O_CREAT | O_EXCL | O_NOFOLLOW), writing/fsyncing and hardening through the exact opened record, fsyncing the exact directory, cleaning failures descriptor-relative, and revalidating directory/record identities before returning. A same-user rename-and-replacement race fails closed with brew-cleanup-audit-directory-identity-drift and does not redirect the record into the replacement directory.

Unsupported non-Unix publication remains explicit/fail-closed; Homebrew execution authority remains macOS-only.

Stack / ownership

This PR remains the dependency-root proving owner for issue #194's descriptor/handle-relative publication primitive. Downstream #205 has now been advanced onto this exact head while retaining only its Intel Homebrew compatibility delta. Downstream #228 has likewise been advanced onto this exact head while retaining only its shared private_evidence object-bound publication delta. #206 remains downstream of #205.

#174 owns generic cleanup, #156 repository-wide exact coverage/release evidence, #150 Podman desktop evidence, and #149 canonical acquisition documentation.

Required before merge

Keep Draft until the unchanged exact head satisfies every applicable live required workflow, repository-wide exact 100% owned-production coverage without threshold or production-scope weakening, zero valid current-head findings, fresh live-base ancestry, and actual live governance. Pending, queued, skipped-required, failed, stale, predecessor, model-only, status-only, diagnostic-only, synthetic, or author-only evidence is non-passing.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review the unchanged exact head 8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5 against live protected main be418bac9bfbdc8aa41b1a698713833e3dbccfdc. Release compilation has completed successfully on Linux, macOS, and Windows; Test, Security Scan, and SAST remain pending and are not represented as passing.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Git identity and delta =='
git rev-parse HEAD
git rev-parse 8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5
git merge-base be418bac9bfbdc8aa41b1a698713833e3dbccfdc 8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5
git diff --name-status be418bac9bfbdc8aa41b1a698713833e3dbccfdc 8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5

echo '== Rust structure =='
ast-grep outline src-tauri/src/brew_cleanup.rs --items all --type function,impl,struct,mod --view expanded
ast-grep outline src-tauri/src/brew_cleanup_audit_authority_tests.rs --items all --type function,mod --view expanded
ast-grep outline src-tauri/src/lib.rs --items all --type mod --view expanded

echo '== Focused audit implementation references =='
rg -n -C 5 --type rust \
  'write_audit_record|brew-cleanup-audit-(parent|directory)-writable-by-others|brew-cleanup-records|DirBuilderExt|OpenOptionsExt|set_permissions|sync_all|remove_file' \
  src-tauri/src/brew_cleanup.rs src-tauri/src/brew_cleanup_audit_authority_tests.rs src-tauri/src/lib.rs

echo '== PR and check state =='
gh pr view 187 --repo ContextualWisdomLab/disksage \
  --json number,headRefOid,baseRefOid,mergeStateStatus,statusCheckRollup,files \
  --jq '{number, headRefOid, baseRefOid, mergeStateStatus, checks: [.statusCheckRollup[] | {name, status, conclusion, detailsUrl}], files: [.files[].path]}'

Length of output: 1981


🏁 Script executed:

#!/bin/bash
set -u

echo '== Supported structural maps =='
ast-grep outline src-tauri/src/brew_cleanup.rs --items all --type function,struct,mod --view expanded || true
ast-grep outline src-tauri/src/brew_cleanup_audit_authority_tests.rs --items all --type function,struct,mod --view expanded || true
ast-grep outline src-tauri/src/lib.rs --items all --type function,struct,mod --view expanded || true

echo '== Exact source diff =='
git diff --no-ext-diff --unified=80 \
  be418bac9bfbdc8aa41b1a698713833e3dbccfdc \
  8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5 \
  -- src-tauri/src/brew_cleanup.rs src-tauri/src/brew_cleanup_audit_authority_tests.rs src-tauri/src/lib.rs

echo '== Focused implementation and regression source =='
rg -n -C 12 --type rust \
  'fn write_audit_record|fn .*writable|brew-cleanup-audit-(parent|directory)-writable-by-others|brew-cleanup-records|DirBuilderExt|OpenOptionsExt|set_permissions|sync_all|remove_file|audit_authority_tests' \
  src-tauri/src/brew_cleanup.rs src-tauri/src/brew_cleanup_audit_authority_tests.rs src-tauri/src/lib.rs

Length of output: 37684


🏁 Script executed:

#!/bin/bash
set -euo pipefail

gh pr view 187 --repo ContextualWisdomLab/disksage \
  --json number,headRefOid,baseRefOid,mergeStateStatus,statusCheckRollup,files \
  --jq '{number, headRefOid, baseRefOid, mergeStateStatus, checks: [.statusCheckRollup[] | {name, status, conclusion, detailsUrl}], files: [.files[].path]}'

Length of output: 5512


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== Existing audit-record tests =='
sed -n '620,760p' src-tauri/src/brew_cleanup.rs

echo '== Test configuration candidates =='
fd -a -t f 'Cargo.toml|Cargo.lock' . \
  -E target -E node_modules \
  | while IFS= read -r file; do
      echo "--- $file"
      rg -n -C 3 'tempfile|^\[dev-dependencies\]|^\[workspace' "$file" || true
    done

echo '== Direct audit writer references and test module registration =='
rg -n -C 5 --type rust \
  '\bwrite_audit_record\s*\(|mod\s+brew_cleanup_audit_authority_tests\b|audit_records_are_create_new_and_private' \
  src-tauri/src

Length of output: 9131


@seonghobae No blocking source findings found in the exact be418bac9bfbdc8aa41b1a698713833e3dbccfdc..8e676ea5e89dd473a7b0c6ca763ddb7f71599ea5 delta.

The implementation rejects group and other write authority on the app-data directory and on an existing audit directory. It creates the audit directory with mode 0o700. It creates audit records with create_new(true) and mode 0o400. It hardens the opened file with file.set_permissions, without re-resolving the record pathname.

The existing audit test verifies create-once behavior and final Unix mode 0o400. The new crate-internal tests use schema-valid records and independently cover 0o020 and 0o002 for both storage boundaries.

The Linux, macOS, and Windows Release builds succeeded. Test, Semgrep, and Security Scan checks remain queued. The PR remains BLOCKED. These checks, plus the immutable predecessor’s intended RED evidence and required coverage evidence, must complete before approval.

⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head b633e3efc90fcb053db3b6ca4f3695304206cf2c.

  • Head SHA: b633e3efc90fcb053db3b6ca4f3695304206cf2c

  • Workflow run: 31796494843

  • Workflow attempt: 1

Coverage evidence

Coverage Decision

  • Result: FAIL
  • Test evidence: not proven passing
  • Docstring evidence: not proven passing when configured
  • Failure count: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (4 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (4 files)"]
  R1 --> V1["required checks"]
Loading

@opencode-agent

opencode-agent Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: b633e3efc90fcb053db3b6ca4f3695304206cf2c
  • Workflow run: 31799045915
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head b633e3efc90fcb053db3b6ca4f3695304206cf2c.

  • Head SHA: b633e3efc90fcb053db3b6ca4f3695304206cf2c

  • Workflow run: 31799045915

  • Workflow attempt: 1

Coverage evidence

Coverage Decision

  • Result: FAIL
  • Test evidence: not proven passing
  • Docstring evidence: not proven passing when configured
  • Failure count: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (4 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (4 files)"]
  R1 --> V1["required checks"]
Loading

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

OpenCode cannot approve yet because required coverage evidence did not pass.

Review outcome

1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence

  • Problem: The required coverage-evidence job result was failure, so OpenCode cannot establish approval sufficiency for this head.

  • Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.

  • Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present.

  • Result: REQUEST_CHANGES

  • Reason: coverage-evidence result was failure, so required test/docstring evidence was not proven for current head b633e3efc90fcb053db3b6ca4f3695304206cf2c.

  • Head SHA: b633e3efc90fcb053db3b6ca4f3695304206cf2c

  • Workflow run: 31799045915

  • Workflow attempt: 1

Coverage evidence

Coverage Decision

  • Result: FAIL
  • Test evidence: not proven passing
  • Docstring evidence: not proven passing when configured
  • Failure count: 1

Changed-File Evidence Map

flowchart LR
  PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
  Evidence --> S1["Changed file (4 files)"]
  S1 --> I1["repository behavior"]
  I1 --> R1["Review risk: Changed file (4 files)"]
  R1 --> V1["required checks"]
Loading

@seonghobae
seonghobae marked this pull request as draft August 14, 2026 20:18
@seonghobae
seonghobae marked this pull request as ready for review August 16, 2026 21:19
@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@seonghobae
seonghobae marked this pull request as draft August 17, 2026 09:05
@seonghobae
seonghobae marked this pull request as ready for review August 20, 2026 10:38
@seonghobae
seonghobae marked this pull request as draft August 20, 2026 16:10
@seonghobae
seonghobae dismissed opencode-agent[bot]’s stale review August 22, 2026 07:35

Dismissing: this REQUEST_CHANGES was posted against commit b633e3e where coverage-evidence failed. The PR's current head has coverage-evidence passing (verified via gh pr checks). No unresolved review threads remain. Re-request review to re-validate.

@opencode-agent opencode-agent Bot added area: security Security boundary, hardening, or vulnerability prevention priority: high High-priority or P1 work status: draft Draft pull request type: security Security vulnerability or security-specific remediation labels Aug 22, 2026
* test: prove private evidence parent replacement race

* fix: bind private evidence writes to opened parent

* test: prove private evidence parent permission drift

* fix: revalidate private evidence parent permissions

* test: preserve replaced private evidence on failed cleanup

* security: preserve identity-mismatched evidence replacements

* security: invalidate failed evidence through opened descriptor

* test: prove private evidence mode survives restrictive umask

* fix: normalize private evidence mode after open

* test: isolate restrictive umask to record creation

* test: cover post-create parent replacement

* refactor: centralize private parent validation

* fix(stack): preserve current audit root in private evidence owner

* test: expose pre-open private evidence parent race

* fix: bind private evidence parent before canonicalization

* refactor: expose object-bound evidence publication primitive

* test: expose shared object-bound publication seam

* fix: use C-compatible private evidence mode argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: security Security boundary, hardening, or vulnerability prevention priority: high High-priority or P1 work status: draft Draft pull request type: security Security vulnerability or security-specific remediation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant