Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
ce730d96
Unverified
Commit
ce730d96
authored
May 31, 2018
by
Tim Allclair
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitRepo command hardening
parent
d5e05ca2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
git_repo.go
pkg/volume/git_repo/git_repo.go
+3
-2
git_repo_test.go
pkg/volume/git_repo/git_repo_test.go
+33
-5
No files found.
pkg/volume/git_repo/git_repo.go
View file @
ce730d96
...
...
@@ -20,6 +20,7 @@ import (
"fmt"
"io/ioutil"
"path"
"path/filepath"
"strings"
"k8s.io/api/core/v1"
...
...
@@ -194,7 +195,7 @@ func (b *gitRepoVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
return
err
}
args
:=
[]
string
{
"clone"
,
b
.
source
}
args
:=
[]
string
{
"clone"
,
"--"
,
b
.
source
}
if
len
(
b
.
target
)
!=
0
{
args
=
append
(
args
,
b
.
target
)
...
...
@@ -218,7 +219,7 @@ func (b *gitRepoVolumeMounter) SetUpAt(dir string, fsGroup *int64) error {
var
subdir
string
switch
{
case
b
.
target
==
"."
:
case
len
(
b
.
target
)
!=
0
&&
filepath
.
Clean
(
b
.
target
)
==
"."
:
// if target dir is '.', use the current dir
subdir
=
path
.
Join
(
dir
)
case
len
(
files
)
==
1
:
...
...
pkg/volume/git_repo/git_repo_test.go
View file @
ce730d96
...
...
@@ -93,7 +93,7 @@ func TestPlugin(t *testing.T) {
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
gitUrl
,
"target_dir"
},
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
,
"target_dir"
},
dir
:
""
,
},
{
...
...
@@ -120,7 +120,7 @@ func TestPlugin(t *testing.T) {
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
gitUrl
,
"target_dir"
},
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
,
"target_dir"
},
dir
:
""
,
},
},
...
...
@@ -138,7 +138,7 @@ func TestPlugin(t *testing.T) {
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
gitUrl
},
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
},
dir
:
""
,
},
},
...
...
@@ -158,7 +158,7 @@ func TestPlugin(t *testing.T) {
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
gitUrl
},
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
},
dir
:
""
,
},
{
...
...
@@ -186,7 +186,35 @@ func TestPlugin(t *testing.T) {
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
gitUrl
,
"."
},
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
,
"."
},
dir
:
""
,
},
{
cmd
:
[]
string
{
"git"
,
"checkout"
,
revision
},
dir
:
""
,
},
{
cmd
:
[]
string
{
"git"
,
"reset"
,
"--hard"
},
dir
:
""
,
},
},
isExpectedFailure
:
false
,
},
{
name
:
"current-dir-mess"
,
vol
:
&
v1
.
Volume
{
Name
:
"vol1"
,
VolumeSource
:
v1
.
VolumeSource
{
GitRepo
:
&
v1
.
GitRepoVolumeSource
{
Repository
:
gitUrl
,
Revision
:
revision
,
Directory
:
"./."
,
},
},
},
expecteds
:
[]
expectedCommand
{
{
cmd
:
[]
string
{
"git"
,
"clone"
,
"--"
,
gitUrl
,
"./."
},
dir
:
""
,
},
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment