From 6d492a1579cbf136fd6e242a2c3dca03b7c4396a Mon Sep 17 00:00:00 2001 From: Ivar Derksen Date: Fri, 15 Dec 2023 14:37:32 +0100 Subject: [PATCH 1/2] Fix: RemoveScheme function in irmaclient already stripping storage before checking whether scheme is in assets --- irmaclient/client.go | 10 +++++++++- schemes.go | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/irmaclient/client.go b/irmaclient/client.go index e3a9b213..8825c5d4 100644 --- a/irmaclient/client.go +++ b/irmaclient/client.go @@ -1547,7 +1547,15 @@ func (client *Client) RemoveScheme(schemeID irma.SchemeManagerIdentifier) error return errors.New("unknown scheme manager") } - err := client.stripStorage([]irma.SchemeManagerIdentifier{schemeID}, true) + isInAssets, err := client.Configuration.IsInAssets(scheme) + if err != nil { + return err + } + if isInAssets { + return errors.New("cannot remove scheme manager that is in assets") + } + + err = client.stripStorage([]irma.SchemeManagerIdentifier{schemeID}, true) if err != nil { return err } diff --git a/schemes.go b/schemes.go index 007c4606..22e8d3b1 100644 --- a/schemes.go +++ b/schemes.go @@ -258,10 +258,18 @@ func (conf *Configuration) UpdateScheme(scheme Scheme, downloaded *IrmaIdentifie return nil } +func (conf *Configuration) IsInAssets(scheme Scheme) (bool, error) { + if conf.assets == "" { + return false, nil + } + _, exists, err := common.Stat(path.Join(conf.assets, scheme.id())) + return exists, err +} + // DangerousDeleteScheme deletes the given scheme from the configuration. // Be aware: this action is dangerous when the scheme is still in use. func (conf *Configuration) DangerousDeleteScheme(scheme Scheme) error { - _, exists, err := common.Stat(path.Join(conf.assets, scheme.id())) + exists, err := conf.IsInAssets(scheme) if err != nil { return err } From 42d5c9ee1ceb78ae8d11995887c3cce7af503a64 Mon Sep 17 00:00:00 2001 From: Ivar Derksen Date: Fri, 15 Dec 2023 15:08:09 +0100 Subject: [PATCH 2/2] Docs: update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fea84fab..75ce03c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Fixed +- `RemoveScheme` function in `irmaclient` already stripping storage before checking whether the scheme is in assets ## [0.15.0] - 2023-12-11 ### Added