Skip to content
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

fix(Wopi): Mark sensitive parameter as such #3042

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCA\Files_Sharing\Event\ShareLinkAccessedEvent;
use OCA\Richdocuments\AppConfig;
use OCA\Richdocuments\Capabilities;
use OCA\Richdocuments\Db\WopiMapper;
use OCA\Richdocuments\Listener\BeforeFetchPreviewListener;
use OCA\Richdocuments\Listener\CSPListener;
use OCA\Richdocuments\Listener\FileCreatedFromTemplateListener;
Expand Down Expand Up @@ -80,6 +81,10 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(BeforePreviewFetchedEvent::class, BeforeFetchPreviewListener::class);
$context->registerEventListener(RenderReferenceEvent::class, ReferenceListener::class);
$context->registerReferenceProvider(OfficeTargetReferenceProvider::class);
$context->registerSensitiveMethods(WopiMapper::class, [
'getPathForToken',
'getWopiForToken',
]);
}

public function boot(IBootContext $context): void {
Expand Down
10 changes: 8 additions & 2 deletions lib/Db/WopiMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ public function generateInitiatorToken($uid, $remoteServer) {
* @throws ExpiredTokenException
* @throws UnknownTokenException
*/
public function getPathForToken($token) {
public function getPathForToken(
#[\SensitiveParameter]
$token
): Wopi {
return $this->getWopiForToken($token);
}

Expand All @@ -136,7 +139,10 @@ public function getPathForToken($token) {
* @throws UnknownTokenException
* @throws ExpiredTokenException
*/
public function getWopiForToken($token) {
public function getWopiForToken(
#[\SensitiveParameter]
string $token
): Wopi {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from('richdocuments_wopi')
Expand Down
4 changes: 4 additions & 0 deletions tests/stub.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,7 @@ namespace Symfony\Component\HttpFoundation {
public static function checkIp(?string $requestIp, $ips) {}
}
}

#[\Attribute(Attribute::TARGET_PARAMETER)]
class SensitiveParameter {
}