Added logging statements
This commit is contained in:
parent
093dfd04df
commit
9544c0bf53
|
|
@ -27,6 +27,8 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var whitelist = []string{"/work-dir", "/dockerfile"}
|
||||||
|
|
||||||
// ExtractFileSystemFromImage pulls an image and unpacks it to a file system at root
|
// ExtractFileSystemFromImage pulls an image and unpacks it to a file system at root
|
||||||
func ExtractFileSystemFromImage(img string) error {
|
func ExtractFileSystemFromImage(img string) error {
|
||||||
ref, err := docker.ParseReference("//" + img)
|
ref, err := docker.ParseReference("//" + img)
|
||||||
|
|
@ -52,7 +54,6 @@ func ExtractFileSystemFromImage(img string) error {
|
||||||
// Where (5) is the mount point relative to the process's root
|
// Where (5) is the mount point relative to the process's root
|
||||||
// From: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
// From: https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
||||||
func fileSystemWhitelist(path string) ([]string, error) {
|
func fileSystemWhitelist(path string) ([]string, error) {
|
||||||
whitelist := []string{"/work-dir", "/dockerfile"}
|
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -61,20 +62,24 @@ func fileSystemWhitelist(path string) ([]string, error) {
|
||||||
reader := bufio.NewReader(f)
|
reader := bufio.NewReader(f)
|
||||||
for {
|
for {
|
||||||
line, err := reader.ReadString('\n')
|
line, err := reader.ReadString('\n')
|
||||||
|
logrus.Debugf("Read the following line from %s: %s", path, line)
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && err != io.EOF {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
lineArr := strings.Split(line, " ")
|
lineArr := strings.Split(line, " ")
|
||||||
if len(lineArr) < 5 {
|
if len(lineArr) < 5 {
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
logrus.Debugf("Reached end of file %s", path)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if lineArr[4] != constants.RootDir {
|
if lineArr[4] != constants.RootDir {
|
||||||
|
logrus.Debugf("Appending %s from line: %s", lineArr[4], line)
|
||||||
whitelist = append(whitelist, lineArr[4])
|
whitelist = append(whitelist, lineArr[4])
|
||||||
}
|
}
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
|
logrus.Debugf("Reached end of file %s", path)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue