Skip to content

Commit

Permalink
Fix: RemoveScheme function in irmaclient already stripping storage be…
Browse files Browse the repository at this point in the history
…fore checking whether scheme is in assets
  • Loading branch information
ivard committed Dec 15, 2023
1 parent ca6c60c commit 6d492a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion irmaclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
10 changes: 9 additions & 1 deletion schemes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 6d492a1

Please sign in to comment.