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

validate: increase OS validation for special cases #350

Merged
merged 1 commit into from
Apr 11, 2017

Conversation

zhouhao3
Copy link

For some of the linux system under the special value of the verification, should increase the decision on the os.

Signed-off-by: zhouhao zhouhao@cn.fujitsu.com

if err := CapValid(capability, v.HostSpecific); err != nil {
msgs = append(msgs, fmt.Sprintf("capability %q is not valid, man capabilities(7)", capability))
if v.spec.Platform.OS == "linux" {
for _, capability := range process.Capabilities {
Copy link
Contributor

Choose a reason for hiding this comment

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

process.capabilities is no longer Linux-specific since opencontainers/runtime-spec#673 (which removed this line). I'm not clear on how the capabilities check is supposed to work on other OSes, but unless the spec changes I don't think we can have a Linux-only check here.

Copy link
Author

Choose a reason for hiding this comment

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

But the validation of capabilities is compared with CAPABILITIES (7), CAPABILITIES(7) is the value under linux.

Copy link
Contributor

Choose a reason for hiding this comment

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

So we should add checks for capabilities on other OSes. Or move the Linux-specific cap validation into a CheckLinuxCapabilities and raise not-implemented-yet errors if someone tries to validate a non-Linux config. But silently ignoring process.capabilities in non-Linux configs will give users a false sense of security.

Copy link
Author

Choose a reason for hiding this comment

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

But it is not clear the value of other systems, it can not be verified.
My idea is to verify the linux system under the capabilities of the special value, not the entire capabilities field validation, so is not the integration of these tests into a function will be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

But it is not clear the value of other systems, it can not be verified.

I agree, and think somebody with more weight than me should bring this up among the runtime-spec maintainers before they cut 1.0 (I tried, but didn't have much success).

My idea is to verify the linux system under the capabilities of the special value, not the entire capabilities field validation…

That's fine, but I don't think we should be silently passing on non-Linux OSes. Does moving the Linux-specific cap validation into CheckLinuxCapabilities and raising not-implemented-yet errors for non-Linux configs sound like a bad idea to you?

Copy link
Contributor

@wking wking left a comment

Choose a reason for hiding this comment

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

Moving the process.ApparmorProfile bit into a Linux-specific section looks good to me, but unless the spec changes, I think the process.Capabilities and process.Rlimits sections need to be handled somehow on all of our platforms.

for i := index + 1; i < len(process.Rlimits); i++ {
if process.Rlimits[index].Type == process.Rlimits[i].Type {
msgs = append(msgs, fmt.Sprintf("rlimit can not contain the same type %q.", process.Rlimits[index].Type))
for index, rlimit := range process.Rlimits {
Copy link
Contributor

Choose a reason for hiding this comment

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

process.rlimits is also no longer Linux-specific since opencontainers/runtie-spec#673, so this shouldn't get moved into a Linux-specific section.

@zhouhao3
Copy link
Author

@wking What do you think of 1580403?

Copy link
Contributor

@wking wking left a comment

Choose a reason for hiding this comment

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

I like 1580403, and just have a minor rewording suggestion for the warnings. The process.capabilities and process.rlimits warnings should both follow whatever pattern gets used for the not-yet-implemented warnings.

}
}
} else {
logrus.Warnf("OS %q has not yet have a special value for capabilities", v.spec.Platform.OS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe reword to:

process.capabilities validation not yet implemented for OS %q

@zhouhao3
Copy link
Author

@mrunalp @liangchenye @Mashimiao PTAL

for i := index + 1; i < len(process.Rlimits); i++ {
if process.Rlimits[index].Type == process.Rlimits[i].Type {
msgs = append(msgs, fmt.Sprintf("rlimit can not contain the same type %q.", process.Rlimits[index].Type))
}

Choose a reason for hiding this comment

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

duplicate rlimits check should work for all OSs, not just Linux

Copy link
Author

Choose a reason for hiding this comment

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

updated, PTAL.

Signed-off-by: zhouhao <zhouhao@cn.fujitsu.com>
@Mashimiao
Copy link

Mashimiao commented Apr 11, 2017

LGTM

Approved with PullApprove

@Mashimiao Mashimiao modified the milestone: 0.6 Apr 11, 2017
@liangchenye
Copy link
Member

liangchenye commented Apr 11, 2017

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit 2f0b832 into opencontainers:master Apr 11, 2017
@zhouhao3 zhouhao3 deleted the linux-check branch April 12, 2017 01:18
@Mashimiao Mashimiao removed this from the v0.6.0 milestone Sep 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants