-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[confcom] Add a --with-containers flag to policy and fragment gen
#9409
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
08a57f2
Add a --with-containers flag to policy and fragment gen
DomAyre dcdfeff
Style fixes
DomAyre cb2499f
Update HISTORY.rst
DomAyre c8d3ed6
Merge branch 'main' into with-containers
DomAyre 912fd6f
Bump confcom version
DomAyre 68e9aee
Support more kinds of container defs
DomAyre b81b718
Update version
DomAyre feb5e55
Cleanup
DomAyre 0f2e156
Remove unused array
DomAyre ab47ad5
Fix existing tests
DomAyre ec31662
Add new basic tests
DomAyre b7bd7bd
Fix running without --with-containers
DomAyre 3e99378
Fix acifragmentgen with no containers
DomAyre 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,3 +36,5 @@ azext_confcom/bin/* | |
| **/.coverage | ||
|
|
||
| **/htmlcov | ||
|
|
||
| !lib/ | ||
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
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,118 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from dataclasses import dataclass, field, is_dataclass | ||
| import inspect | ||
| import sys | ||
| from typing import Literal, Optional | ||
|
|
||
|
|
||
| def get_default_capabilities(): | ||
| return [ | ||
| "CAP_AUDIT_WRITE", | ||
| "CAP_CHOWN", | ||
| "CAP_DAC_OVERRIDE", | ||
| "CAP_FOWNER", | ||
| "CAP_FSETID", | ||
| "CAP_KILL", | ||
| "CAP_MKNOD", | ||
| "CAP_NET_BIND_SERVICE", | ||
| "CAP_NET_RAW", | ||
| "CAP_SETFCAP", | ||
| "CAP_SETGID", | ||
| "CAP_SETPCAP", | ||
| "CAP_SETUID", | ||
| "CAP_SYS_CHROOT" | ||
| ] | ||
|
|
||
|
|
||
| @dataclass | ||
| class ContainerCapabilities: | ||
| ambient: list[str] = field(default_factory=list) | ||
| bounding: list[str] = field(default_factory=get_default_capabilities) | ||
| effective: list[str] = field(default_factory=get_default_capabilities) | ||
| inheritable: list[str] = field(default_factory=list) | ||
| permitted: list[str] = field(default_factory=get_default_capabilities) | ||
|
|
||
|
|
||
| @dataclass | ||
| class ContainerRule: | ||
| pattern: str | ||
| strategy: str | ||
| required: Optional[bool] = False | ||
|
|
||
|
|
||
| @dataclass | ||
| class ContainerExecProcesses: | ||
| command: list[str] | ||
| signals: Optional[list[str]] = None | ||
| allow_stdio_access: bool = True | ||
|
|
||
|
|
||
| @dataclass | ||
| class ContainerMount: | ||
| destination: str | ||
| source: str | ||
| type: str | ||
| options: list[str] = field(default_factory=list) | ||
|
|
||
|
|
||
| @dataclass | ||
| class ContainerUser: | ||
| group_idnames: list[ContainerRule] = field(default_factory=lambda: [ContainerRule(pattern="", strategy="any")]) | ||
| umask: str = "0022" | ||
| user_idname: ContainerRule = field(default_factory=lambda: ContainerRule(pattern="", strategy="any")) | ||
|
|
||
|
|
||
| @dataclass | ||
| class FragmentReference: | ||
| feed: str | ||
| issuer: str | ||
| minimum_svn: str | ||
| includes: list[Literal["containers", "fragments", "namespace", "external_processes"]] | ||
| path: Optional[str] = None | ||
|
|
||
|
|
||
| @dataclass | ||
| class Container: | ||
| allow_elevated: bool = False | ||
| allow_stdio_access: bool = True | ||
| capabilities: ContainerCapabilities = field(default_factory=ContainerCapabilities) | ||
| command: Optional[list[str]] = None | ||
| env_rules: list[ContainerRule] = field(default_factory=list) | ||
| exec_processes: list[ContainerExecProcesses] = field(default_factory=list) | ||
| id: Optional[str] = None | ||
| layers: list[str] = field(default_factory=list) | ||
| mounts: list[ContainerMount] = field(default_factory=list) | ||
| name: Optional[str] = None | ||
| no_new_privileges: bool = False | ||
| seccomp_profile_sha256: str = "" | ||
| signals: list[str] = field(default_factory=list) | ||
| user: ContainerUser = field(default_factory=ContainerUser) | ||
| working_dir: str = "/" | ||
|
|
||
|
|
||
| @dataclass | ||
| class Policy: | ||
| package: str = "policy" | ||
| api_version: str = "0.10.0" | ||
| framework_version: str = "0.2.3" | ||
| fragments: list[FragmentReference] = field(default_factory=list) | ||
| containers: list[Container] = field(default_factory=list) | ||
| allow_properties_access: bool = True | ||
| allow_dump_stacks: bool = False | ||
| allow_runtime_logging: bool = False | ||
| allow_environment_variable_dropping: bool = True | ||
| allow_unencrypted_scratch: bool = False | ||
| allow_capability_dropping: bool = True | ||
|
|
||
|
|
||
| @dataclass | ||
| class Fragment: | ||
| package: str = "fragment" | ||
| svn: str = "0" | ||
| framework_version: str = "0.2.3" | ||
| fragments: list[FragmentReference] = field(default_factory=list) | ||
| containers: list[Container] = field(default_factory=list) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.