Skip to content

Commit c05908a

Browse files
committed
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 <[email protected]>
1 parent 9e94dc5 commit c05908a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/libartifact/store/store.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ func NewArtifactStore(storePath string, sc *types.SystemContext) (*ArtifactStore
4747
if storePath == "" {
4848
return nil, errors.New("store path cannot be empty")
4949
}
50+
if !filepath.IsAbs(storePath) {
51+
return nil, fmt.Errorf("store path %q must be absolute", storePath)
52+
}
53+
5054
logrus.Debugf("Using artifact store path: %s", storePath)
5155

5256
artifactStore := &ArtifactStore{

0 commit comments

Comments
 (0)