Skip to content

fix: count only commits visible to the link viewer - #1416

Open
MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/link-stats-match-visible-commits
Open

MrPunyapal wants to merge 1 commit into
dev-null-sh:productionfrom
MrPunyapal:fix/link-stats-match-visible-commits

Conversation

@MrPunyapal

@MrPunyapal MrPunyapal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Link statistics could count commits that are not visible in the feed, making the totals disagree with the content shown to the viewer.

Change

Applies the same visibility rules to the statistics query as the visible commit list, including approval and blocked-author filtering.

Tests

Focused link controller tests passed (7 tests, 98 assertions). Type checks and lint passed.

Summary by CodeRabbit

  • Bug Fixes
    • Link-page commit totals now reflect commits visible to the current viewer, including the viewer’s own pending commits and commits from organizations they belong to. Commits from blocked users and unrelated pending commits remain excluded.
    • The contributor count reflects the distinct people who authored visible commits, keeping both displayed totals consistent with the commits available to that viewer.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Link statistics now use the current user’s commit visibility. The controller passes that user to the stats query. The feature test covers visible commits, including organization commits, and confirms that blocked-user commits and unrelated pending commits remain excluded.

Changes: Link statistics

Layer / File(s) Summary
Calculate and verify visible commit statistics
app/Queries/LinkCommitsQuery.php, app/Http/Controllers/LinkController.php, tests/Feature/Controllers/LinkControllerTest.php
The stats query accepts a user and counts commits visible to that user. The controller passes the current user. The test expects four visible commits by three people and checks excluded commits.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: mnapoli

Merge Risk: Minimal · up to e0488

The change consistently scopes link statistics to commits visible to the current viewer.

Security architecture risk: Low · up to e0488

The change correctly aligns commit counts with the viewer’s access. However, counting distinct posting accounts can expose information that the displayed organization author intentionally hides. Extending that count to pending or rejected organization posts creates a limited identity-inference risk for other organization members.

Retained concerns

  • Medium · security · inferred: The viewer-scoped people aggregate extends a hidden-poster identity oracle to pending and rejected organization posts. A non-moderator organization member viewing a link containing one such post and one approved personal post from a known account can distinguish whether their posting accounts match: people is one if they match and two otherwise. The cards conceal the organization poster, but the aggregate uses that protected identity. Approved-post inference predates this PR; inclusion of non-approved organization posts is the newly expanded exposure.
Security review details

Security Blast Radius

  • inferred — The newly expanded attribution exposure is bounded to authenticated viewers who can see non-approved organization commits through membership. Exploitation requires a suitable link-level set and known posting identities for comparison. It reveals identity equality or attribution through cardinality, not raw account identifiers or unrestricted access to unrelated pending content.

Security Findings and Attack Paths

  • inferred — For a link with a known person’s approved personal post and one pending organization post, a member can infer whether that person also posted for the organization from whether people equals one or two. Base statistics ignored the pending post; head statistics include it. The same class of aggregate inference for approved organization posts already existed and is not attributed to this PR.

Trust Boundaries and Controls

  • observed — The route remains authenticated and the viewer comes from CurrentUser. Both list and aggregate enforce the same link and visibility filters. Normal card serialization preserves the model’s hidden posting-account fields; therefore the concern is aggregate inference across an attribute-level privacy boundary, not viewer impersonation or a direct content-authorization bypass.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: link statistics now count only commits visible to the link viewer. The raw summary confirms LinkCommitsQuery::stats now takes a User and counts commits visible to tha…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title states the main change: link statistics now count only commits visible to the link viewer. The raw summary confirms LinkCommitsQuery::stats now takes a User and counts commits visible to that user instead of approved commits, and LinkController passes the current user. The PR objectives describe the same goal, aligning statistics with the visible commit list. The title follows the conventional commit style and is specific enough for a teammate scanning history.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 3 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe2547d1-6560-42c3-abb3-bf99beb0e035
Commits

Reviewing files that changed from the base of the PR and between 7166270 and e0488a7.

Files selected for processing: 1
  • app/Http/Controllers/LinkController.php

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@MrPunyapal
MrPunyapal force-pushed the fix/link-stats-match-visible-commits branch from 98a4c90 to a97789c Compare November 3, 2026 05:55
@MrPunyapal
MrPunyapal marked this pull request as ready for review November 3, 2026 06:02
@MrPunyapal
MrPunyapal force-pushed the fix/link-stats-match-visible-commits branch 2 times, most recently from 4317053 to 7166270 Compare November 4, 2026 11:08
@MrPunyapal
MrPunyapal force-pushed the fix/link-stats-match-visible-commits branch from 7166270 to e0488a7 Compare November 4, 2026 20:38
@nunomaduro

Copy link
Copy Markdown
Member

fix conflicts plz

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.

2 participants