Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ jobs:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.3', '8.4']

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
- uses: actions/checkout@v4
Comment thread
coderabbitai[bot] marked this conversation as resolved.
with:
persist-credentials: false
- uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- uses: actions/checkout@v3
php-version: ${{ matrix.php-version }}
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SquidAllowedIp/CreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function rules(): array
public function createSquidAllowedIp() : SquidAllowedIp
{
$squidAllowedIp = new SquidAllowedIp($this->validated());
$squidAllowedIp->user_id = $this->route()->parameter('user_id');
$squidAllowedIp->user_id = (int) $this->route()->parameter('user_id');

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

echo "== route definitions mentioning user_id =="
fd -t f . routes | xargs -r rg -n -C2 "user_id|whereNumber|Route::"

echo
echo "== request files using route()->parameter('user_id') =="
fd -t f 'CreateRequest.php' app/Http/Requests | xargs -r rg -n -C2 "route\(\)->parameter\('user_id'\)|\(int\)\s*\$this->route\(\)->parameter\('user_id'\)"

Repository: 39ff/squid-db-auth-web

Length of output: 6596


🏁 Script executed:

#!/bin/bash
set -eu

echo "== app/Http/Requests/SquidAllowedIp/CreateRequest.php =="
cat -n app/Http/Requests/SquidAllowedIp/CreateRequest.php

echo
echo "== routes/web.php relevant section =="
sed -n '27,43p' routes/web.php

echo
echo "== routes/api.php relevant section =="
sed -n '24,45p' routes/api.php

Repository: 39ff/squid-db-auth-web

Length of output: 4083


user_id に数値制約を追加してください
route() の値を (int) で入れているため、非数値が 0 になります。whereNumber('user_id') か FormRequest 側の整数検証を追加してください。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/Http/Requests/SquidAllowedIp/CreateRequest.php` at line 34, The user_id
route parameter in CreateRequest is being cast with (int), which turns
non-numeric input into 0 instead of rejecting it; add numeric validation to the
route binding or FormRequest so invalid values are blocked. Update the
CreateRequest validation rules or the route definition that feeds
$this->route()->parameter('user_id') to enforce integer-only input, then keep
the assignment to $squidAllowedIp->user_id relying on validated data.


return $squidAllowedIp;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SquidUser/CreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function rules(): array
public function createSquidUser() : SquidUser
{
$squidUser = new SquidUser($this->validated());
$squidUser->user_id = $this->route()->parameter('user_id');
$squidUser->user_id = (int) $this->route()->parameter('user_id');

return $squidUser;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SquidUser/ModifyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function rules(): array
public function modifySquidUser() : SquidUser
{
$squidUser = new SquidUser($this->validated());
$squidUser->id = $this->route()->parameter('id');
$squidUser->id = (int) $this->route()->parameter('id');

return $squidUser;
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/User/ModifyRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function rules(): array
public function modifyUser(): User
{
$user = new User($this->validated());
$user->id = $this->route()->parameter('id');
$user->id = (int) $this->route()->parameter('id');

return $user;
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Resources/SquidAllowedIpCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use JsonSerializable;

class SquidAllowedIpCollection extends ResourceCollection
{
Expand All @@ -13,7 +12,7 @@ class SquidAllowedIpCollection extends ResourceCollection
/**
* Transform the resource collection into an array.
*
* @return array|\Illuminate\Contracts\Support\Arrayable|JsonSerializable
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Resources/SquidAllowedIpResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use JsonSerializable;

class SquidAllowedIpResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array|\Illuminate\Contracts\Support\Arrayable|JsonSerializable
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Resources/SquidUserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use JsonSerializable;

class SquidUserCollection extends ResourceCollection
{
Expand All @@ -13,7 +12,7 @@ class SquidUserCollection extends ResourceCollection
/**
* Transform the resource collection into an array.
*
* @return array|\Illuminate\Contracts\Support\Arrayable|JsonSerializable
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Resources/SquidUserResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use JsonSerializable;

class SquidUserResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @return array|\Illuminate\Contracts\Support\Arrayable|JsonSerializable
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Resources/UserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
use JsonSerializable;

class UserCollection extends ResourceCollection
{
/**
* Transform the resource collection into an array.
*
* @return array|\Illuminate\Contracts\Support\Arrayable|JsonSerializable
* @return array<int|string, mixed>
*/
public function toArray(Request $request): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Models/SquidAllowedIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Scopes\SquidUserScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SquidAllowedIp extends Model
{
Expand All @@ -19,7 +20,7 @@ protected static function booted()
static::addGlobalScope(new SquidUserScope());
}

public function laravel_user()
public function laravel_user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
Expand Down
3 changes: 2 additions & 1 deletion app/Models/SquidUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Scopes\SquidUserScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SquidUser extends Model
{
Expand All @@ -23,7 +24,7 @@ protected static function booted()
static::addGlobalScope(new SquidUserScope());
}

public function laravel_user()
public function laravel_user(): BelongsTo
{
return $this->belongsTo(User::class, 'user_id');
}
Expand Down
4 changes: 2 additions & 2 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class User extends Authenticatable
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
* @var list<string>
*/
protected $fillable = [
'name',
Expand All @@ -27,7 +27,7 @@ class User extends Authenticatable
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
* @var list<string>
*/
protected $hidden = [
'password',
Expand Down
29 changes: 16 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
],
"license": "MIT",
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.4",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.2"
"php": "^8.2",
"guzzlehttp/guzzle": "^7.9",
"laravel/framework": "^12.0",
"laravel/sanctum": "^4.0",
"laravel/tinker": "^2.10",
"laravel/ui": "^4.6"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.0",
"nunomaduro/larastan": "^2.4",
"phpunit/phpunit": "^9.5.10",
"spatie/laravel-ignition": "^2.0"
"fakerphp/faker": "^1.23",
"larastan/larastan": "^3.0",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5",
"spatie/laravel-ignition": "^2.8"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -58,6 +58,9 @@
},
"config": {
"optimize-autoloader": true,
"platform": {
"php": "8.2.0"
},
"preferred-install": "dist",
"sort-packages": true
},
Expand Down
Loading
Loading