Skip to content

Commit 71a7724

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 ceaf889 commit 71a7724

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
@@ -46,6 +46,10 @@ func NewArtifactStore(storePath string, sc *types.SystemContext) (*ArtifactStore
4646
if storePath == "" {
4747
return nil, errors.New("store path cannot be empty")
4848
}
49+
if !filepath.IsAbs(storePath) {
50+
return nil, fmt.Errorf("store path %q must be absolute", storePath)
51+
}
52+
4953
logrus.Debugf("Using artifact store path: %s", storePath)
5054

5155
artifactStore := &ArtifactStore{

0 commit comments

Comments
 (0)