Skip to content

mark password as a sensitive param for 8.2 #516

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

Merged
merged 3 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
11 changes: 7 additions & 4 deletions php_memcached.c
Original file line number Diff line number Diff line change
Expand Up @@ -3895,9 +3895,14 @@ PHP_METHOD(MemcachedServer, on)

#endif

#if PHP_VERSION_ID < 80200
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this should be defined only for 8.0/8.1, but needed for 7.x because of php/php-src#8842

#define zend_mark_function_parameter_as_sensitive(a,b,c)
#endif

#if PHP_VERSION_ID < 80000
#include "php_memcached_legacy_arginfo.h"
#else
#include "zend_attributes.h"
#include "php_memcached_arginfo.h"
#endif

Expand Down Expand Up @@ -4254,8 +4259,7 @@ PHP_MINIT_FUNCTION(memcached)

le_memc = zend_register_list_destructors_ex(NULL, php_memc_dtor, "Memcached persistent connection", module_number);

INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
memcached_ce = zend_register_internal_class(&ce);
memcached_ce = register_class_Memcached();
memcached_ce->create_object = php_memc_object_new;

#ifdef HAVE_MEMCACHED_PROTOCOL
Expand All @@ -4264,8 +4268,7 @@ PHP_MINIT_FUNCTION(memcached)
memcached_server_object_handlers.clone_obj = NULL;
memcached_server_object_handlers.free_obj = php_memc_server_free_storage;

INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
memcached_server_ce = zend_register_internal_class(&ce);
memcached_server_ce = register_class_MemcachedServer();
memcached_server_ce->create_object = php_memc_server_new;
#endif

Expand Down
4 changes: 3 additions & 1 deletion php_memcached.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* @generate-function-entries
* @generate-legacy-arginfo
* @generate-class-entries
*/


Expand Down Expand Up @@ -75,6 +76,7 @@ public function setOption(int $option, mixed $value): bool {}
public function setOptions(array $options): bool {}
public function setBucket(array $host_map, ?array $forward_map, int $replicas): bool {}
#ifdef HAVE_MEMCACHED_SASL
/** @sensitive-param $password **/
public function setSaslAuthData(string $username, string $password): bool {}
#endif

Expand All @@ -86,7 +88,7 @@ public function isPristine(): bool {}
public function checkKey(string $key): bool {}
}

#ifdef HAVE_MEMCACHED_PROTOCOL
#if defined(HAVE_MEMCACHED_PROTOCOL)
class MemcachedServer {

public function run(string $address): bool {}
Expand Down
34 changes: 29 additions & 5 deletions php_memcached_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3f4694d4e1f3d1647a832acd8539b056b2ab5e7a */
* Stub hash: cad7892c60b5b898fa5e20b4b0b0ca62149c1334 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Memcached___construct, 0, 0, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, persistent_id, IS_STRING, 1, "null")
Expand Down Expand Up @@ -406,12 +406,36 @@ static const zend_function_entry class_Memcached_methods[] = {
};


static const zend_function_entry class_MemcachedServer_methods[] = {
#if defined(HAVE_MEMCACHED_PROTOCOL)
static const zend_function_entry class_MemcachedServer_methods[] = {
ZEND_ME(MemcachedServer, run, arginfo_class_MemcachedServer_run, ZEND_ACC_PUBLIC)
#endif
#if defined(HAVE_MEMCACHED_PROTOCOL)
ZEND_ME(MemcachedServer, on, arginfo_class_MemcachedServer_on, ZEND_ACC_PUBLIC)
#endif
ZEND_FE_END
};
#endif

static zend_class_entry *register_class_Memcached(void)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

#if defined(HAVE_MEMCACHED_SASL)
zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setsaslauthdata", 1);
#endif

return class_entry;
}

#if defined(HAVE_MEMCACHED_PROTOCOL)
static zend_class_entry *register_class_MemcachedServer(void)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}
#endif
34 changes: 29 additions & 5 deletions php_memcached_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 3f4694d4e1f3d1647a832acd8539b056b2ab5e7a */
* Stub hash: cad7892c60b5b898fa5e20b4b0b0ca62149c1334 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Memcached___construct, 0, 0, 0)
ZEND_ARG_INFO(0, persistent_id)
Expand Down Expand Up @@ -402,12 +402,36 @@ static const zend_function_entry class_Memcached_methods[] = {
};


static const zend_function_entry class_MemcachedServer_methods[] = {
#if defined(HAVE_MEMCACHED_PROTOCOL)
static const zend_function_entry class_MemcachedServer_methods[] = {
ZEND_ME(MemcachedServer, run, arginfo_class_MemcachedServer_run, ZEND_ACC_PUBLIC)
#endif
#if defined(HAVE_MEMCACHED_PROTOCOL)
ZEND_ME(MemcachedServer, on, arginfo_class_MemcachedServer_on, ZEND_ACC_PUBLIC)
#endif
ZEND_FE_END
};
#endif

static zend_class_entry *register_class_Memcached(void)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "Memcached", class_Memcached_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

#if defined(HAVE_MEMCACHED_SASL)
zend_mark_function_parameter_as_sensitive(&class_entry->function_table, "setsaslauthdata", 1);
#endif

return class_entry;
}

#if defined(HAVE_MEMCACHED_PROTOCOL)
static zend_class_entry *register_class_MemcachedServer(void)
{
zend_class_entry ce, *class_entry;

INIT_CLASS_ENTRY(ce, "MemcachedServer", class_MemcachedServer_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);

return class_entry;
}
#endif