From e8de7d2a4dbe91a80bb23642eaf07342503f691a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 12 Jul 2022 14:37:51 +0200 Subject: [PATCH 1/3] Support the actual `#[\SensitiveParameter]` attribute in stubs (for upcoming 8.2.0beta1) --- php81/php_zip.c | 3 --- php81/php_zip.stub.php | 9 +++------ php81/php_zip_arginfo.h | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/php81/php_zip.c b/php81/php_zip.c index 0de9189..29a067d 100644 --- a/php81/php_zip.c +++ b/php81/php_zip.c @@ -29,9 +29,6 @@ #include "zend_attributes.h" #include "zend_interfaces.h" #include "php_zip.h" -#if PHP_VERSION_ID < 80200 -#define zend_mark_function_parameter_as_sensitive(a,b,c) -#endif #include "php_zip_arginfo.h" #ifdef HAVE_GLOB diff --git a/php81/php_zip.stub.php b/php81/php_zip.stub.php index a0866e1..aa7d783 100644 --- a/php81/php_zip.stub.php +++ b/php81/php_zip.stub.php @@ -83,10 +83,9 @@ class ZipArchive implements Countable public function open(string $filename, int $flags = 0): bool|int {} /** - * @sensitive-param $password * @tentative-return-type */ - public function setPassword(string $password): bool {} + public function setPassword(#[\SensitiveParameter] string $password): bool {} /** @tentative-return-type */ public function close(): bool {} @@ -227,16 +226,14 @@ class ZipArchive implements Countable #ifdef HAVE_ENCRYPTION /** - * @sensitive-param $password * @tentative-return-type */ - public function setEncryptionName(string $name, int $method, ?string $password = null): bool {} + public function setEncryptionName(string $name, int $method, #[\SensitiveParameter] ?string $password = null): bool {} /** - * @sensitive-param $password * @tentative-return-type */ - public function setEncryptionIndex(int $index, int $method, ?string $password = null): bool {} + public function setEncryptionIndex(int $index, int $method, #[\SensitiveParameter] ?string $password = null): bool {} #endif #ifdef HAVE_PROGRESS_CALLBACK diff --git a/php81/php_zip_arginfo.h b/php81/php_zip_arginfo.h index 6f00051..a3ec214 100644 --- a/php81/php_zip_arginfo.h +++ b/php81/php_zip_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: f8ec36ea62bfbdb74cfa6472227e08d9282413a2 */ + * Stub hash: 9c44d8bcf6b97804d539a9dd566d5faca60074ba */ ZEND_BEGIN_ARG_INFO_EX(arginfo_zip_open, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -530,12 +530,21 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry zend_declare_typed_property(class_entry, property_comment_name, &property_comment_default_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_STRING)); zend_string_release(property_comment_name); - zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setpassword", 0); + + zend_string *attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0, 0); + zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0); #if defined(HAVE_ENCRYPTION) - zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setencryptionname", 2); + + zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2, 0); + zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2); #endif #if defined(HAVE_ENCRYPTION) - zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setencryptionindex", 2); + + zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2, 0); + zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2); #endif return class_entry; -- 2.35.3 From f94c6772a49e5d9860b0abffc32a56a0a33a6216 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 18 Jul 2022 12:32:56 +0200 Subject: [PATCH 2/3] add SensitiveParameter as known string and use it in arginfo --- php81/php_zip_arginfo.h | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/php81/php_zip_arginfo.h b/php81/php_zip_arginfo.h index a3ec214..8fb3bb9 100644 --- a/php81/php_zip_arginfo.h +++ b/php81/php_zip_arginfo.h @@ -531,20 +531,14 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry zend_string_release(property_comment_name); - zend_string *attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); - zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0, 0); - zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setPassword_arg0); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); #if defined(HAVE_ENCRYPTION) - zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); - zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2, 0); - zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionName_arg2); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionname", sizeof("setencryptionname") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); #endif #if defined(HAVE_ENCRYPTION) - zend_string *attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2 = zend_string_init("SensitiveParameter", sizeof("SensitiveParameter") - 1, 1); - zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2, 0); - zend_string_release(attribute_name_SensitiveParameter_ZipArchive_setEncryptionIndex_arg2); + zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); #endif return class_entry; -- 2.35.3 From cbaf00ce8f6f5165399d81ff345cc6cc6f8a75d7 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 20 Jul 2022 07:29:36 +0200 Subject: [PATCH 3/3] compat for 8.1 --- php81/php_zip.stub.php | 5 ++++- php81/php_zip_arginfo.h | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/php81/php_zip.stub.php b/php81/php_zip.stub.php index aa7d783..bab802c 100644 --- a/php81/php_zip.stub.php +++ b/php81/php_zip.stub.php @@ -1,6 +1,9 @@ = 80200) zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setpassword", sizeof("setpassword") - 1), 0, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); @@ -539,6 +540,7 @@ static zend_class_entry *register_class_ZipArchive(zend_class_entry *class_entry #if defined(HAVE_ENCRYPTION) zend_add_parameter_attribute(zend_hash_str_find_ptr(&class_entry->function_table, "setencryptionindex", sizeof("setencryptionindex") - 1), 2, ZSTR_KNOWN(ZEND_STR_SENSITIVEPARAMETER), 0); +#endif #endif return class_entry; -- 2.35.3