Skip to content

Commit

Permalink
Merge pull request #2185 from Luap99/fips-mount-secure
Browse files Browse the repository at this point in the history
pkg/subscriptions: use securejoin for the container path
  • Loading branch information
openshift-merge-bot[bot] authored Oct 1, 2024
2 parents 757ba7e + 5a550b6 commit c3edf18
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/subscriptions/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/containers/common/pkg/umask"
"github.com/containers/storage/pkg/fileutils"
"github.com/containers/storage/pkg/idtools"
securejoin "github.com/cyphar/filepath-securejoin"
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -346,7 +347,10 @@ func addFIPSModeSubscription(mounts *[]rspec.Mount, containerRunDir, mountPoint,

srcBackendDir := "/usr/share/crypto-policies/back-ends/FIPS"
destDir := "/etc/crypto-policies/back-ends"
srcOnHost := filepath.Join(mountPoint, srcBackendDir)
srcOnHost, err := securejoin.SecureJoin(mountPoint, srcBackendDir)
if err != nil {
return fmt.Errorf("resolve %s in the container: %w", srcBackendDir, err)
}
if err := fileutils.Exists(srcOnHost); err != nil {
if errors.Is(err, os.ErrNotExist) {
return nil
Expand Down

0 comments on commit c3edf18

Please sign in to comment.