-
Notifications
You must be signed in to change notification settings - Fork 160
validate: allow unset "type" fields in resource devices whitelist #491
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
Merged
hqhq
merged 3 commits into
opencontainers:master
from
cyphar:validate-fix-type-whitelist
Oct 24, 2017
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package validation | ||
|
|
||
| import ( | ||
| "io/ioutil" | ||
| "os" | ||
| "path/filepath" | ||
| "runtime" | ||
| "testing" | ||
|
|
||
| rfc2119 "github.com/opencontainers/runtime-tools/error" | ||
| "github.com/opencontainers/runtime-tools/generate" | ||
| "github.com/opencontainers/runtime-tools/specerror" | ||
| "github.com/opencontainers/runtime-tools/validate" | ||
| ) | ||
|
|
||
| // Smoke test to ensure that _at the very least_ our default configuration | ||
| // passes the validation tests. If this test fails, something is _very_ wrong | ||
| // and needs to be fixed immediately (as it will break downstreams that depend | ||
| // on us for a "sane default" and do compliance testing -- such as umoci). | ||
| func TestGenerateValid(t *testing.T) { | ||
| bundle, err := ioutil.TempDir("", "TestGenerateValid_bundle") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| defer os.RemoveAll(bundle) | ||
|
|
||
| // Create our toy bundle. | ||
| rootfsPath := filepath.Join(bundle, "rootfs") | ||
| if err := os.Mkdir(rootfsPath, 0755); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| configPath := filepath.Join(bundle, "config.json") | ||
| g := generate.New() | ||
| if err := (&g).SaveToFile(configPath, generate.ExportOptions{Seccomp: false}); err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| // Validate the bundle. | ||
| v, err := validate.NewValidatorFromPath(bundle, true, runtime.GOOS) | ||
| if err != nil { | ||
| t.Errorf("unexpected NewValidatorFromPath error: %+v", err) | ||
| } | ||
| if err := v.CheckAll(); err != nil { | ||
| levelErrors, err := specerror.SplitLevel(err, rfc2119.Must) | ||
| if err != nil { | ||
| t.Errorf("unexpected non-multierror: %+v", err) | ||
| return | ||
| } | ||
| for _, e := range levelErrors.Warnings { | ||
| t.Logf("unexpected warning: %v", e) | ||
| } | ||
| if err := levelErrors.Error; err != nil { | ||
| t.Errorf("unexpected MUST error(s): %+v", err) | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not excited about the asymmetry between unparmeterized generation and host-specific validation. This will cerainly die if
runtime.GOOSis not Linux. It may die even on Linux if the host system is sufficiently ancient or the stock config becomes sufficiently demanding. But I'm ok crossing those bridges later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want me to set the OS explicitly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine leaving it as it stands, as a reminder that
Newwill need similar options when we get our first non-Linux user and/or stabilize the API.