Skip to content

fix: enforce project scope for report creation and reassignment - #651

Merged
david-loe merged 4 commits into
mainfrom
fix/approved-advance-project-authorization
Oct 29, 2026
Merged

david-loe merged 4 commits into
mainfrom
fix/approved-advance-project-authorization

Conversation

@david-loe

@david-loe david-loe commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Project-restricted reviewers could create or move reports into projects they do not supervise. For new records, the shared setter does not run checkOldObject; for existing records, the callbacks only checked the stored project. Bulk report imports resolved project references without checking the caller’s project scope.

Check supplied target projects before creating or modifying reports or writing history. Check all resolved projects before a bulk save, rejecting an unauthorized mixed batch in full. Existing-record checks still require authority over the original project. Unrestricted reviewers (an empty supervision list) and personal owner permissions retain their existing behavior.

The covered staff endpoints are:

  • Advances: creation and approval-time project reassignment; bulk approved-advance imports.
  • Travel: creation and approval-time project reassignment, examiner detail edits, and bulk approved-travel imports.
  • Expense reports: examiner-created drafts, detail edits, return-to-draft project reassignment, and bulk draft imports.
  • Health care costs: examiner-created drafts, detail edits, and return-to-draft project reassignment. There is no corresponding report-level bulk import.

Expense and health care examiner creation produces IN_WORK drafts. Their reviewCompleted endpoints already reject reports in unsupervised projects; regression scenarios verify that existing protection.

Validation:

  • Unauthorized creation/reassignment and mixed imports were reproduced before the corresponding fixes.
  • 14 focused HTTP regression scenarios cover the affected creation, reassignment, and bulk-import paths. They verify rejection without persisted changes and successful writes to a supervised project.
  • The regression coverage is consolidated into one 216-line file, removing repeated role, state, and reference-format combinations.
  • Complete backend suite: 333 tests passed, including the 14 new scenarios. Backend build, Biome 2.6.3, and git diff --check passed.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 506d8bc and 49415d6.

Files selected for processing: 1
  • backend/tests/api/projectAuthorization.ts

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between b331919 and 506d8bc.

Files selected for processing: 8
  • backend/controller/advanceController.ts
  • backend/controller/expenseReportController.ts
  • backend/controller/healthCareCostController.ts
  • backend/controller/travelController.ts
  • backend/tests/api/advanceProjectAuthorization.ts
  • backend/tests/api/bulkApprovalProjectAuthorization.ts
  • backend/tests/api/examinationProjectAuthorization.ts
  • backend/tests/api/travelProjectAuthorization.ts

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

Walkthrough

Advance, travel, expense-report, and health-care-cost controllers now check whether the requester supervises the specified project. Bulk operations reject the request if any resolved project fails that check. Individual operations reject unauthorized project assignments before proceeding. New API tests cover denied and permitted operations, project references supplied as IDs or objects, and persisted record and project state.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: Minimal · previous review 506d8

No merge-blocking issue was identified; the project authorization changes appear ready to merge after normal checks.

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 describes real changes involving project-scoped report creation and reassignment. However, it omits the broader and primary scope of advance and travel approval authorization, including bulk…
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 describes real changes involving project-scoped report creation and reassignment. However, it omits the broader and primary scope of advance and travel approval authorization, including bulk imports.

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 5 functions across 8 files.

Resolution

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

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@david-loe david-loe changed the title fix: authorize approved advances against their target project fix: enforce project authorization for advance and travel approvals Oct 29, 2026
@david-loe david-loe changed the title fix: enforce project authorization for advance and travel approvals fix: enforce project scope for report creation and reassignment Oct 29, 2026
@david-loe
david-loe merged commit b01fb8d into main Oct 29, 2026
10 checks passed
@david-loe
david-loe deleted the fix/approved-advance-project-authorization branch November 2, 2026 09:10
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.

1 participant