Skip to content

Commit

Permalink
Merge pull request #372 from privacybydesign/strip-storage-bug
Browse files Browse the repository at this point in the history
Fix: RemoveScheme function in irmaclient already stripping storage before checking whether scheme is in assets
  • Loading branch information
ivard authored Dec 18, 2023
2 parents ca6c60c + 42d5c9e commit 506fcd2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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 506fcd2

Please sign in to comment.