Skip to content

Commit

Permalink
fix: escape dot in target path regex
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Oct 26, 2022
1 parent 658c421 commit bb1815a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/codeql.yaml
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 7 * * 1" # Mondays at 7:00 AM

Expand Down
2 changes: 1 addition & 1 deletion pkg/util/fileutil/filesystem.go
Expand Up @@ -25,7 +25,7 @@ import (
)

var (
targetPathRe = regexp.MustCompile(`[\\|\/]+pods[\\|\/]+(.+?)[\\|\/]+volumes[\\|\/]+kubernetes.io~csi[\\|\/]+(.+?)[\\|\/]+mount$`)
targetPathRe = regexp.MustCompile(`[\\|\/]+pods[\\|\/]+(.+?)[\\|\/]+volumes[\\|\/]+kubernetes\.io~csi[\\|\/]+(.+?)[\\|\/]+mount$`)
)

// GetMountedFiles returns all the mounted files mapping their path relative to
Expand Down
4 changes: 4 additions & 0 deletions pkg/util/fileutil/filesystem_test.go
Expand Up @@ -266,6 +266,10 @@ func TestGetVolumeNameFromTargetPath(t *testing.T) {
targetPath: "/var/lib/kubelet/pods/7e7686a1-56c4-4c67-a6fd-4656ac484f0a/volumes/kubernetes.io~pv/pvvol/mount",
want: "",
},
{
targetPath: "/var/lib/kubelet/pods/7e7686a1-56c4-4c67-a6fd-4656ac484f0a/volumes/kubernetesxio~csi/secrets-store-inline/mount",
want: "",
},
{
targetPath: "/var/lib/kubelet/pods/7e7686a1-56c4-4c67-a6fd-4656ac484f0a/volumes/kubernetes.io~csi/secrets-store-inline/mount",
want: "secrets-store-inline",
Expand Down

0 comments on commit bb1815a

Please sign in to comment.