-
Notifications
You must be signed in to change notification settings - Fork 286
MappedDirectory enforcement and misc fixes #2727
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,3 +327,83 @@ func TestModifySettings_PolicyFragment_TypeAssertionFailure(t *testing.T) { | |
| t.Fatal("expected error for empty fragment, got nil") | ||
| } | ||
| } | ||
|
|
||
| // Tests for environment variable filtering helpers (envlist persistence) | ||
|
|
||
| func TestOciEnvToProcessParamEnv_Basic(t *testing.T) { | ||
| input := []string{"FOO=bar", "PATH=/usr/bin", "EMPTY="} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. /usr/bin might not be the most obvious choice for a Windows test.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but the test is just validating the key, value parsing logic here (i.e. is it converting them properly from OCI-format), so it doesn't have an impact on the test itself. |
||
| result := ociEnvToProcessParamEnv(input) | ||
|
|
||
| if result["FOO"] != "bar" { | ||
| t.Errorf("FOO = %q, want %q", result["FOO"], "bar") | ||
| } | ||
| if result["PATH"] != "/usr/bin" { | ||
| t.Errorf("PATH = %q, want %q", result["PATH"], "/usr/bin") | ||
| } | ||
| if result["EMPTY"] != "" { | ||
| t.Errorf("EMPTY = %q, want %q", result["EMPTY"], "") | ||
| } | ||
| if len(result) != 3 { | ||
| t.Errorf("len = %d, want 3", len(result)) | ||
| } | ||
| } | ||
|
|
||
| func TestOciEnvToProcessParamEnv_ValueWithEquals(t *testing.T) { | ||
| input := []string{"CONN=host=db;port=5432"} | ||
| result := ociEnvToProcessParamEnv(input) | ||
|
|
||
| if result["CONN"] != "host=db;port=5432" { | ||
| t.Errorf("CONN = %q, want %q", result["CONN"], "host=db;port=5432") | ||
| } | ||
| } | ||
|
|
||
| func TestOciEnvToProcessParamEnv_MalformedSkipped(t *testing.T) { | ||
| input := []string{"GOOD=value", "NOEQUALS", "ALSO_GOOD=yes"} | ||
| result := ociEnvToProcessParamEnv(input) | ||
|
|
||
| if len(result) != 2 { | ||
| t.Errorf("len = %d, want 2 (malformed entry should be skipped)", len(result)) | ||
| } | ||
| if result["GOOD"] != "value" { | ||
| t.Errorf("GOOD = %q, want %q", result["GOOD"], "value") | ||
| } | ||
| if result["ALSO_GOOD"] != "yes" { | ||
| t.Errorf("ALSO_GOOD = %q, want %q", result["ALSO_GOOD"], "yes") | ||
| } | ||
| } | ||
|
|
||
| func TestOciEnvToProcessParamEnv_Empty(t *testing.T) { | ||
| result := ociEnvToProcessParamEnv([]string{}) | ||
| if len(result) != 0 { | ||
| t.Errorf("len = %d, want 0", len(result)) | ||
| } | ||
| } | ||
|
|
||
| func TestOciEnvToProcessParamEnv_Nil(t *testing.T) { | ||
| result := ociEnvToProcessParamEnv(nil) | ||
| if result == nil { | ||
| t.Error("result should be non-nil empty map, got nil") | ||
| } | ||
| if len(result) != 0 { | ||
| t.Errorf("len = %d, want 0", len(result)) | ||
| } | ||
| } | ||
|
|
||
| func TestProcessParamEnvToOCIEnv_Roundtrip(t *testing.T) { | ||
| original := map[string]string{ | ||
| "FOO": "bar", | ||
| "PATH": "/usr/bin", | ||
| } | ||
|
|
||
| ociEnv := processParamEnvToOCIEnv(original) | ||
| roundtripped := ociEnvToProcessParamEnv(ociEnv) | ||
|
|
||
| if len(roundtripped) != len(original) { | ||
| t.Fatalf("roundtrip len = %d, want %d", len(roundtripped), len(original)) | ||
| } | ||
| for k, v := range original { | ||
| if roundtripped[k] != v { | ||
| t.Errorf("roundtrip[%q] = %q, want %q", k, roundtripped[k], v) | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,6 @@ runtime_logging := data.framework.runtime_logging | |
| load_fragment := data.framework.load_fragment | ||
| scratch_mount := data.framework.scratch_mount | ||
| scratch_unmount := data.framework.scratch_unmount | ||
| mapped_directory_mount := data.framework.mapped_directory_mount | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the tooling need to be updated to match?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the tooling needs to account for this and the logging enforcement as well. |
||
| mapped_directory_unmount := data.framework.mapped_directory_unmount | ||
| reason := data.framework.reason | ||
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.
Is there no enforcement on stdout in WCOW yet?
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.
No enforcement on
allowStdio, partly because pipes are set by inbox-gcs (in Linux case, we're able to redirect it to/dev/null. But I have a workaround to block the pipe creation itself, MahatiC@d0de0ca - I did not test this myself though.