mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-18 23:05:20 +00:00
fix(security): enforce company scope on notes, doc-convert, and member bulk-delete (#668)
v3 port of the v2 authorization fixes. - Notes IDOR (GHSA-85wc): NotePolicy checks the note's company_id and NotesController passes the bound model to authorize() on show/update/destroy. - Estimate<->Invoice convert IDOR (GHSA-j2vg): EstimatesController::convertToInvoice and InvoicesController::convertToEstimate authorize 'view' on the source document before creating the target. - Member bulk-delete (GHSA-wxrv): MembersController scopes ids via User::whereCompany() before MemberService::delete. Adds feature tests for cross-company 403s + same-company happy paths.
This commit is contained in:
committed by
GitHub
parent
f3ab0f22fc
commit
c6a00df120
@@ -5,6 +5,7 @@ use App\Http\Requests\DeleteEstimatesRequest;
|
||||
use App\Http\Requests\EstimatesRequest;
|
||||
use App\Http\Requests\SendEstimatesRequest;
|
||||
use App\Mail\SendEstimateMail;
|
||||
use App\Models\Company;
|
||||
use App\Models\Estimate;
|
||||
use App\Models\EstimateItem;
|
||||
use App\Models\Tax;
|
||||
@@ -246,6 +247,16 @@ test('create invoice from estimate', function () {
|
||||
$response->assertStatus(200);
|
||||
});
|
||||
|
||||
test('cannot convert an estimate belonging to another company', function () {
|
||||
$estimate = Estimate::factory()->create([
|
||||
'company_id' => Company::factory()->create()->id,
|
||||
'estimate_date' => now(),
|
||||
'expiry_date' => now()->addMonth(),
|
||||
]);
|
||||
|
||||
postJson("api/v1/estimates/{$estimate->id}/convert-to-invoice")->assertStatus(403);
|
||||
});
|
||||
|
||||
test('delete multiple estimates using a form request', function () {
|
||||
$this->assertActionUsesFormRequest(
|
||||
EstimatesController::class,
|
||||
|
||||
Reference in New Issue
Block a user