Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor security spec #2271

Merged
merged 3 commits into from
Nov 1, 2018
Merged

refactor: refactor security spec #2271

merged 3 commits into from
Nov 1, 2018

Conversation

Ace-Tang
Copy link
Contributor

@Ace-Tang Ace-Tang commented Sep 21, 2018

Ⅰ. Describe what this PR did

Split #2115 PR into 3 independent PR, here is the first, still need 2 more PRs in the TODO List.

  1. add opencontainers/runc/libcontainer/apparmor vendor
  2. security parameter include seccomp, apparmor and no-new-privileges
    are not implement good, refactor these part when create new spec.

TODO List

  1. use pouchd default spec.
  2. remove containerd default spec.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

no.

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Sep 21, 2018

Codecov Report

Merging #2271 into master will increase coverage by 4.37%.
The diff coverage is 58.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2271      +/-   ##
==========================================
+ Coverage   64.09%   68.47%   +4.37%     
==========================================
  Files         271      275       +4     
  Lines       18269    18278       +9     
==========================================
+ Hits        11710    12515     +805     
+ Misses       5285     4339     -946     
- Partials     1274     1424     +150
Flag Coverage Δ
#criv1alpha1test 31.86% <53.06%> (?)
#criv1alpha2test 35.71% <53.06%> (-0.08%) ⬇️
#integrationtest 39.79% <57.69%> (+0.01%) ⬆️
#nodee2etest 33.28% <50%> (+0.09%) ⬆️
#unittest 25.53% <0%> (+0.03%) ⬆️
Impacted Files Coverage Δ
daemon/mgr/container_utils.go 86.7% <ø> (+2.65%) ⬆️
daemon/mgr/spec_linux.go 74.51% <ø> (-0.26%) ⬇️
daemon/mgr/spec_process.go 80% <ø> (+12.98%) ⬆️
daemon/mgr/container_types.go 83.33% <ø> (ø) ⬆️
daemon/mgr/spec_apparmor_linux_unsupported.go 100% <100%> (ø)
daemon/mgr/spec_apparmor_linux.go 20% <20%> (ø)
daemon/mgr/spec_seccomp_unsupported.go 50% <50%> (ø)
pkg/system/system.go 68.11% <54.54%> (-2.58%) ⬇️
daemon/mgr/container_validation.go 45% <55.55%> (+0.62%) ⬆️
daemon/mgr/spec_seccomp_linux.go 78.94% <78.94%> (ø)
... and 19 more

)

// SysInfo defines system info on current machine
type SysInfo struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the built-in package, Sysinfo refers to http://docs.studygolang.com/pkg/syscall/#Sysinfo_t :

type Sysinfo_t struct {
    Uptime    int64
    Loads     [3]uint64
    Totalram  uint64
    Freeram   uint64
    Sharedram uint64
    Bufferram uint64
    Totalswap uint64
    Freeswap  uint64
    Procs     uint16
    Pad       uint16
    Pad_cgo_0 [4]byte
    Totalhigh uint64
    Freehigh  uint64
    Unit      uint32
    X_f       [0]byte
    Pad_cgo_1 [4]byte
}

So, I am wondering if it is proper to change the definition of SysInfo. @Ace-Tang

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not proper, also I recognize the file name is also not proper, it should be system.go, and change the Sysinfo to Info. That will make sense. @allencloud , WDYT.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline. And @Ace-Tang would do some update.

@fuweid fuweid added this to the v1.1 milestone Oct 11, 2018
Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rebase the commit and I will merge it

"checksumSHA1": "gVVY8k2G3ws+V1czsfxfuRs8log=",
"path": "github.com/opencontainers/runc/libcontainer/apparmor",
"revision": "ab4a8191679806893207d9c1e507a77ff46dafaa",
"revisionTime": "2018-01-12T20:11:04Z"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we align this package with other existing /runc/libcontainer package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it add by govender, different directory will be a log.

add package opencontainers/runc/libcontainer/apparmor for
apparmor used.

Signed-off-by: Ace-Tang <aceapril@126.com>
@Ace-Tang
Copy link
Contributor Author

Ace-Tang commented Nov 1, 2018

ping @allencloud @fuweid , already updated.

Makefile Outdated
@@ -74,7 +76,7 @@ build: build-daemon build-cli ## build PouchContainer both daemon and cli binari
build-daemon: modules plugin ## build PouchContainer daemon binary
@echo "$@: bin/${DAEMON_BINARY_NAME}"
@mkdir -p bin
@GOOS=linux go build -ldflags ${DEFAULT_LDFLAGS} -o bin/${DAEMON_BINARY_NAME} -tags 'selinux'
@GOOS=linux go build -ldflags ${DEFAULT_LDFLAGS} ${GOBUILD_TAGS}-o bin/${DAEMON_BINARY_NAME}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space before -o

I'm just curious about the CI. In my local, make job will fail.

$ BUILDTAGS="selinux seccomp apparmor" make
build volume modules
build plugin
build-daemon: bin/pouchd
GOOS=linux go build -ldflags "-X github.com/alibaba/pouch/version.GitCommit=1.0.0-230-gb292535-dirty -X github.com/alibaba/pouch/version.Version="1.0.0" -X github.com/alibaba/pouch/version.ApiVersion="1.24" -X github.com/alibaba/pouch/version.BuildTime=2018-11-01T14:05:11+08:00" -tags "selinux seccomp apparmor"-o bin/pouchd
can't load package: package bin/pouchd: cannot find package "bin/pouchd" in any of:
        /usr/local/go/src/bin/pouchd (from $GOROOT)
        /home/vagrant/go/src/bin/pouchd (from $GOPATH)
Makefile:77: recipe for target 'build-daemon' failed
make: *** [build-daemon] Error 1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the CI passed because it doesn't use make build-daemon. So please update it @Ace-Tang

security parameter include seccomp, apparmor and no-new-privileges
are not implement good, refactor these part when create new spec.

Signed-off-by: Ace-Tang <aceapril@126.com>
Signed-off-by: Ace-Tang <aceapril@126.com>
@Ace-Tang
Copy link
Contributor Author

Ace-Tang commented Nov 1, 2018

• Failure [0.966 seconds]
[k8s.io] PodSandbox
/home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/framework/framework.go:72
  runtime should support sysctls
  /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:84
    should support safe sysctls [It]
    /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:95
    Expected
        <string>: 
    to equal
        <string>: 1
    /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:253

cri tests seems not stable ?

Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fuweid fuweid merged commit 825128d into AliyunContainerService:master Nov 1, 2018
@fuweid
Copy link
Contributor

fuweid commented Nov 1, 2018

• Failure [0.966 seconds]
[k8s.io] PodSandbox
/home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/framework/framework.go:72
  runtime should support sysctls
  /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:84
    should support safe sysctls [It]
    /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:95
    Expected
        <string>: 
    to equal
        <string>: 1
    /home/travis/gopath/src/github.com/kubernetes-incubator/cri-tools/pkg/validate/pod.go:253
cri tests seems not stable ?

we will fix in the redesign IO.

@starnop
Copy link
Contributor

starnop commented Nov 1, 2018

@Ace-Tang Please revert it. Something is wrong. In fact, the CI test has failed except the IO problem.

@allencloud
Copy link
Collaborator

We will discuss this tomorrow. @alibaba/pouch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants