Refactor ResolveSignature to improve UUID validation by reintroducing validation for 'signature_uuid' and throwing an InvalidRpcArgumentException for invalid UUIDs.

https://github.com/nosial/Socialbox-PHP/issues/44
This commit is contained in:
netkas 2025-03-13 00:26:40 -04:00
parent df96d894a8
commit a11c8b463f
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 6 additions and 4 deletions

View file

@ -35,10 +35,6 @@
{
throw new MissingRpcArgumentException('signature_uuid');
}
elseif(!Validator::validateUuid($rpcRequest->getParameter('signature_uuid')))
{
throw new InvalidRpcArgumentException('signature_uuid', 'Invalid UUID V4');
}
return $rpcRequest->produceResponse(Socialbox::resolvePeerSignature(
$rpcRequest->getParameter('peer'), $rpcRequest->getParameter('signature_uuid')

View file

@ -27,6 +27,7 @@
use Socialbox\Exceptions\RequestException;
use Socialbox\Exceptions\ResolutionException;
use Socialbox\Exceptions\RpcException;
use Socialbox\Exceptions\Standard\InvalidRpcArgumentException;
use Socialbox\Exceptions\Standard\StandardRpcException;
use Socialbox\Managers\ContactManager;
use Socialbox\Managers\ExternalSessionManager;
@ -910,6 +911,11 @@
throw new StandardRpcException('Cannot resolve signature for a host peer', StandardError::FORBIDDEN);
}
if(!Validator::validateUuid($signatureUuid))
{
throw new InvalidRpcArgumentException('The given signature UUID is not a valid UUID V4');
}
// If the peer is registered within this server
if($peerAddress->getDomain() === Configuration::getInstanceConfiguration()->getDomain())
{