Merge pull request #58864 from nextcloud/fix/cached_exporter_hardening

This commit is contained in:
Benjamin Gaussorgues 2026-03-11 18:30:22 +01:00 committed by GitHub
commit 3904da98e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,6 +13,8 @@ use Generator;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\OpenMetrics\IMetricFamily;
use OCP\OpenMetrics\Metric;
use OCP\OpenMetrics\MetricValue;
use Override;
/**
@ -43,7 +45,12 @@ abstract class Cached implements IMetricFamily {
public function metrics(): Generator {
$cacheKey = static::class;
if ($data = $this->cache->get($cacheKey)) {
yield from unserialize($data);
yield from unserialize(
$data,
[
'allowed_classes' => [Metric::class, MetricValue::class],
],
);
return;
}