libartifact: NewArtifactStore() reject relative paths

The oci layout code can handle a relative path find but all paths
returned by the code then will alos be relative, this can be bad and
result in bugs if something ever changes the cwd. The graphroot path we
pass should already be always absolute, so just add a sanity check here
given libartifact is planned to be moved as sperate lib and we cannot
assume anything about the path we will be given there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2025-02-27 15:14:55 +01:00
parent 9e94dc53b2
commit c05908a7f6

View File

@ -47,6 +47,10 @@ func NewArtifactStore(storePath string, sc *types.SystemContext) (*ArtifactStore
if storePath == "" {
return nil, errors.New("store path cannot be empty")
}
if !filepath.IsAbs(storePath) {
return nil, fmt.Errorf("store path %q must be absolute", storePath)
}
logrus.Debugf("Using artifact store path: %s", storePath)
artifactStore := &ArtifactStore{