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

Only allow enabling/disabling recovery alerts for modules of given Safe #1267

Merged
merged 5 commits into from
Mar 13, 2024

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Mar 6, 2024

Summary

We currently prevent the user from enabling/disabling recovery alerts unless they submit a valid signature. This does, not, however, mean that the module is tied to the specified Safe.

This includes a check that the specified moduleAddress is enabled on that safeAddress.

Changes

  • Add check that moduleAddress is enabled on safeAddress in EnableRecoveryAlertsGuard/DisableRecoveryAlertsGuard
  • Add test coverage

@iamacook iamacook self-assigned this Mar 6, 2024
@coveralls
Copy link

coveralls commented Mar 6, 2024

Pull Request Test Coverage Report for Build 8261483986

Details

  • 4 of 16 (25.0%) changed or added relevant lines in 2 files are covered.
  • 2312 unchanged lines in 239 files lost coverage.
  • Overall coverage decreased (-46.9%) to 46.482%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/recovery/guards/disable-recovery-alerts.guard.ts 2 8 25.0%
src/routes/recovery/guards/enable-recovery-alerts.guard.ts 2 8 25.0%
Files with Coverage Reduction New Missed Lines %
src/domain/alerts/contracts/decoders/delay-modifier-decoder.helper.ts 1 83.33%
src/routes/cache-hooks/cache-hooks.controller.ts 1 90.0%
src/datasources/network/entities/errors/limit-reached.error.ts 1 50.0%
src/logging/logging.service.ts 1 94.74%
src/domain/common/utils/utils.ts 1 50.0%
src/routes/transactions/mappers/transfers/transfer-details.mapper.ts 1 85.71%
src/domain/relay/errors/unofficial-proxy-factory.error.ts 1 66.67%
src/domain/chains/singleton.validator.ts 1 88.89%
src/domain/tokens/token.validator.ts 1 81.82%
src/routes/safe-apps/safe-apps.service.ts 1 89.47%
Totals Coverage Status
Change from base Build 8251308188: -46.9%
Covered Lines: 3459
Relevant Lines: 5972

💛 - Coveralls

@iamacook iamacook marked this pull request as ready for review March 6, 2024 16:43
@iamacook iamacook requested a review from a team as a code owner March 6, 2024 16:43
@fmrsabino fmrsabino added the in review Someone is reviewing this Pull Request label Mar 11, 2024
Comment on lines 73 to 83
try {
const { safes } = await this.safeRepository.getSafesByModule({
chainId,
moduleAddress,
});

return safes.some((safe) => getAddress(safe) === getAddress(safeAddress));
} catch (e) {
this.loggingService.debug(e);
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can merge the try/catch block with the one above. Alternatively you can extract this part to a new Guard in favour of composability (e.g.: SafeHasModuleGuard).

However for the context of this PR and since we only perform this check here I would say that we can merge the try/catch block first.

Copy link
Member Author

Choose a reason for hiding this comment

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

Merged in c3d6cff.

@fmrsabino fmrsabino removed the in review Someone is reviewing this Pull Request label Mar 11, 2024
@iamacook iamacook requested a review from fmrsabino March 11, 2024 10:46
Comment on lines 73 to 82
try {
const { safes } = await this.safeRepository.getSafesByModule({
chainId,
moduleAddress,
});

return safes.some((safe) => getAddress(safe) === getAddress(safeAddress));
} catch (e) {
this.loggingService.debug(e);
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here 🙏

#1267 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

Merged in db117f8.

@iamacook iamacook requested a review from fmrsabino March 13, 2024 08:18
@iamacook iamacook merged commit 1fb9f5c into main Mar 13, 2024
16 checks passed
@iamacook iamacook deleted the only-enable-disable-modules-of-safe branch March 13, 2024 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants