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

Add additional filesystem checks for OCI devices #4074

Merged
merged 3 commits into from
May 10, 2019

Conversation

dgerd
Copy link

@dgerd dgerd commented May 10, 2019

This adds checks for the default OCI devices to our conformance test for
filesystem validation. This test also refactors where the file paths to
check are located to reduce the number of transformations and simplify
adding additional paths.

Fixes #2973

This adds checks for the default OCI devices to our conformance test for
filesystem validation. This test also refactors where the file paths to
check are located to reduce the number of transformations and simplify
adding additional paths.

Fixes knative#2973
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 10, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 10, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@dgerd: 2 warnings.

In response to this:

This adds checks for the default OCI devices to our conformance test for
filesystem validation. This test also refactors where the file paths to
check are located to reduce the number of transformations and simplify
adding additional paths.

Fixes #2973

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

test/types/runtime.go Outdated Show resolved Hide resolved
test/types/runtime.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the area/test-and-release It flags unit/e2e/conformance/perf test issues for product features label May 10, 2019
@dgerd
Copy link
Author

dgerd commented May 10, 2019

/assign @mattmoor

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgerd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 10, 2019
test/conformance/envvars_test.go Outdated Show resolved Hide resolved
test/conformance/filesystem_test.go Outdated Show resolved Hide resolved
test/conformance/filesystem_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 10, 2019
@knative-prow-robot knative-prow-robot merged commit db2c534 into knative:master May 10, 2019
Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

(sorry for the late review; this open window got lost in other tabs)

You might want to ensure that this container is run as a random non-root user and test actual side-effects rather than mode bits -- other items like filesystem extended attributes or apparmor profiles can prevent actual file creation while still having "allowed" filesystem permissions.


// MustFiles specifies the file paths and expected permissions that MUST be set as specified in the runtime contract.
// See https://golang.org/pkg/os/#FileMode for "Mode" string meaning. '*' indicates no specification.
var MustFiles = map[string]FileInfo{
Copy link
Member

Choose a reason for hiding this comment

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

Are some (many) of these specified by OCI?

I'm also wondering about the required permissions of /tmp and /var/log -- would it make more sense to test writing a file to those locations, rather than reading unix permissions (which may not be sufficient to grant access in some cases)?

Copy link
Member

Choose a reason for hiding this comment

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

(Just meant here that a comment about where these are specified in OCI would help subsequent readers.)

Copy link
Author

Choose a reason for hiding this comment

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

The first set of files are the "Default Devices" specified here.

The second set of files are the "Dev symbolic links" which we had as "As specified by OCI."

In my PR to update the runtime contract I pull in the "Dev symbolic links" inline and make the "Default Devices" requirement more clear.

Copy link
Author

Choose a reason for hiding this comment

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

As for reading of files and running these tests with and without root user containers I think these are enhancements we definitely can make. I think those tests can be layers upon this rather than replacing this.

Copy link
Author

Choose a reason for hiding this comment

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

Created #4083

var ShouldFiles = map[string]FileInfo{
"/etc/resolv.conf": {
IsDir: ptr.Bool(false),
Mode: "*rw*r**r**",
Copy link
Member

Choose a reason for hiding this comment

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

Again, should this attempt reading the file, rather than checking permissions?

JRBANCEL pushed a commit to JRBANCEL/serving that referenced this pull request May 29, 2019
* Add additional filesystem checks for OCI devices

This adds checks for the default OCI devices to our conformance test for
filesystem validation. This test also refactors where the file paths to
check are located to reduce the number of transformations and simplify
adding additional paths.

Fixes knative#2973

* Fix comments

* Code review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test-and-release It flags unit/e2e/conformance/perf test issues for product features cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add conformance tests to validate OCI devices are disallowed
7 participants