Skip to content

Commit ff60f19

Browse files
committed
Mark parameter in ext/pdo as sensitive
1 parent 8368db0 commit ff60f19

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

ext/pdo/pdo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ PHP_MINIT_FUNCTION(pdo)
252252

253253
pdo_exception_ce = register_class_PDOException(spl_ce_RuntimeException);
254254

255-
pdo_dbh_init();
255+
pdo_dbh_init(module_number);
256256
pdo_stmt_init();
257257

258258
return SUCCESS;

ext/pdo/pdo_dbh.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "php_pdo.h"
2929
#include "php_pdo_driver.h"
3030
#include "php_pdo_int.h"
31+
#include "zend_attributes.h"
3132
#include "zend_exceptions.h"
3233
#include "zend_object_handlers.h"
3334
#include "zend_hash.h"
@@ -1325,7 +1326,7 @@ static HashTable *dbh_get_gc(zend_object *object, zval **gc_data, int *gc_count)
13251326
static zend_object_handlers pdo_dbh_object_handlers;
13261327
static void pdo_dbh_free_storage(zend_object *std);
13271328

1328-
void pdo_dbh_init(void)
1329+
void pdo_dbh_init(int module_number)
13291330
{
13301331
pdo_dbh_ce = register_class_PDO();
13311332
pdo_dbh_ce->create_object = pdo_dbh_new;
@@ -1423,6 +1424,8 @@ void pdo_dbh_init(void)
14231424

14241425
REGISTER_PDO_CLASS_CONST_LONG("CURSOR_FWDONLY", (zend_long)PDO_CURSOR_FWDONLY);
14251426
REGISTER_PDO_CLASS_CONST_LONG("CURSOR_SCROLL", (zend_long)PDO_CURSOR_SCROLL);
1427+
1428+
register_pdo_dbh_symbols(module_number, pdo_dbh_ce);
14261429
}
14271430

14281431
static void dbh_free(pdo_dbh_t *dbh, bool free_persistent)

ext/pdo/pdo_dbh.stub.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/** @not-serializable */
66
class PDO
77
{
8+
/** @sensitive-param $password */
89
public function __construct(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null) {}
910

1011
/** @tentative-return-type */

ext/pdo/pdo_dbh_arginfo.h

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/pdo/php_pdo_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern HashTable pdo_driver_hash;
2525
extern zend_class_entry *pdo_exception_ce;
2626
int php_pdo_list_entry(void);
2727

28-
void pdo_dbh_init(void);
28+
void pdo_dbh_init(int module_number);
2929
void pdo_stmt_init(void);
3030

3131
extern zend_object *pdo_dbh_new(zend_class_entry *ce);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Test that sensitive parameters are marked sensitive.
3+
--EXTENSIONS--
4+
pdo
5+
--FILE--
6+
<?php
7+
try {
8+
new PDO('dsn', 'username', 'password');
9+
} catch (\Throwable $e) {
10+
echo $e, PHP_EOL;
11+
}
12+
?>
13+
--EXPECTF--
14+
PDOException: PDO::__construct(): Argument #1 ($dsn) must be a valid data source name in %s:%d
15+
Stack trace:
16+
#0 %s(%d): PDO->__construct('dsn', 'username', Object(SensitiveParameterValue))
17+
#1 {main}

0 commit comments

Comments
 (0)