-
Notifications
You must be signed in to change notification settings - Fork 2k
fix: add int type hint to gc() in session database handlers #10418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
0b34a37
e9bc894
5a53402
fc5d53c
2124cc3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,9 @@ | |
| use CodeIgniter\Test\DatabaseTestTrait; | ||
| use CodeIgniter\Test\ReflectionHelper; | ||
| use Config\Database as DatabaseConfig; | ||
| use stdClass; | ||
| use Tests\Support\Database\Seeds\CITestSeeder; | ||
| use TypeError; | ||
|
|
||
| /** | ||
| * @internal | ||
|
|
@@ -122,4 +124,18 @@ public function testGC(): void | |
| $handler = $this->getInstance(); | ||
| $this->assertSame(1, $handler->gc(3600)); | ||
| } | ||
|
|
||
| public function testGCRejectsNonInt(): void | ||
| { | ||
| $handler = $this->getInstance(); | ||
|
|
||
| foreach (['malicious; DROP TABLE sessions; --', null, 1.5, [], new stdClass(), true] as $malicious) { | ||
| try { | ||
| $handler->gc($malicious); // @phpstan-ignore argument.type | ||
| $this->fail('TypeError expected for value: ' . gettype($malicious)); | ||
| } catch (TypeError) { | ||
| $this->addToAssertionCount(1); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ Bugs Fixed | |
| ********** | ||
|
|
||
| - **Logger:** Fixed a bug where interpolating a log message with array or non-stringable context values could raise PHP warnings or errors. | ||
| - **Session:** Added ``int`` type hint to ``DatabaseHandler::gc()`` and ``PostgreHandler::gc()`` to prevent SQL injection from non-integer ``$max_lifetime`` values. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add something like this under the Method Signature Changes section: You can also list all affected handlers - this will match other entries. |
||
|
|
||
| See the repo's | ||
| `CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tests a PHP feature, not the method itself. Thus, the test is unnecessary.