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

Feature/security context #18

Merged
merged 51 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
532af61
bug fixes and adding a new flag for approving wildcards for headless …
SethHollandsworth Feb 28, 2023
62df83e
Merge pull request #15 from SethHollandsworth/feature/approve_wildcards
SethHollandsworth Mar 6, 2023
694fb41
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions
hgarvison Mar 8, 2023
57fea59
updating method to get hcsshim files and updating cli version number
hgarvison Mar 8, 2023
f3d1646
making layer caching work across multiple container groups
SethHollandsworth Mar 8, 2023
0a11154
Merge pull request #16 from SethHollandsworth/bugfix/caching-template…
SethHollandsworth Mar 8, 2023
2142e36
securityContext: allowElevatedPrivilege
hgarvison Mar 8, 2023
df075de
Merge branch 'main' of https://github.com/SethHollandsworth/azure-cli…
hgarvison Mar 8, 2023
1bc55cb
runas temp
hgarvison Mar 9, 2023
a29d957
securityContext: user field
hgarvison Mar 10, 2023
eabccbd
securityContext: seccomp_profile
hgarvison Mar 10, 2023
12aa158
adding capabilities array for ARM input
SethHollandsworth Mar 10, 2023
1b56c47
Merge branch 'feature/security_context' into feature/capabilities
SethHollandsworth Mar 10, 2023
2c814d1
making capabilities its own function
SethHollandsworth Mar 10, 2023
905a314
fixing merge conflict
SethHollandsworth Mar 10, 2023
d829010
updating default value
SethHollandsworth Mar 10, 2023
0b9bd74
updating default capabilities and comments about priv escalation
SethHollandsworth Mar 10, 2023
231098a
Merge pull request #17 from SethHollandsworth/feature/capabilities
SethHollandsworth Mar 10, 2023
e21a744
temp
hgarvison Mar 10, 2023
9427d83
Merge branch 'feature/security_context' of https://github.com/SethHol…
hgarvison Mar 10, 2023
8d16134
adding tests for capabilities
SethHollandsworth Mar 10, 2023
200dda4
adding tests and fixing merge conflict
SethHollandsworth Mar 10, 2023
003185a
user/group tests
hgarvison Mar 10, 2023
6ccd646
merge conflicts
hgarvison Mar 10, 2023
f90d828
updated tests
hgarvison Mar 10, 2023
e4465e9
adding a couple bug fixes for using sha hashes
SethHollandsworth Mar 13, 2023
a62dc32
Merge pull request #19 from SethHollandsworth/bugfix/sha_hash_bug
SethHollandsworth Mar 13, 2023
369ed61
Merge branch 'main' of https://github.com/Azure/azure-cli-extensions
SethHollandsworth Mar 14, 2023
5b9f8a7
updating version number
SethHollandsworth Mar 14, 2023
2b9d4b4
style fixes
hgarvison Mar 14, 2023
96e38c1
Merge branch 'main' into feature/security_context
hgarvison Mar 14, 2023
df66d96
updating comment
hgarvison Mar 14, 2023
9054637
update to capabilities
hgarvison Mar 20, 2023
64c5cd9
resolving comments
hgarvison Mar 20, 2023
f4e9e70
fixing infra_svn bug and updating capabilities, adding tests
SethHollandsworth Mar 21, 2023
b97adae
fixing some tests and changing default values
SethHollandsworth Mar 22, 2023
88a8ef5
updating drop capabilities functionality and adding tests
hgarvison Mar 22, 2023
b168f14
resolving comments
hgarvison Mar 22, 2023
e30c749
removing print statement
hgarvison Mar 22, 2023
07b0755
updating version number
SethHollandsworth Mar 22, 2023
21dee19
updating method to check for 32-bit windows and pause container
hgarvison Mar 23, 2023
87f463e
updating logic for excluding win32
hgarvison Mar 23, 2023
f559d44
style checks
hgarvison Mar 23, 2023
fc6582c
bug fix for default value of no_new_privileges in some situations
SethHollandsworth Mar 23, 2023
351920d
removing framework_svn code
hgarvison Mar 29, 2023
96092b2
updating seccomp profile processing
hgarvison Mar 31, 2023
d4f4501
merge conflicts with main
hgarvison Mar 31, 2023
c9e63d4
adding tests and fixing syscall bug
hgarvison Apr 4, 2023
0b41182
Merge branch 'main' into feature/security_context
hgarvison Apr 25, 2023
5c88fd9
allow_elevated logic fixed
hgarvison Apr 26, 2023
91f5f5d
resolving comments
hgarvison Apr 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updating method to get hcsshim files and updating cli version number
  • Loading branch information
hgarvison committed Mar 8, 2023
commit 57fea59ea86e03ab1ef1fee6055031c8573ee8ad
5 changes: 5 additions & 0 deletions src/confcom/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Release History
===============
0.2.13
* adding parsing of container security context field in ARM template
* changing hardcoded API_SVN and FRAMEWORK_SVN to get values from HCSSHIM repo
* bumping HCSSHIM version

0.2.12
* adding ability for mixed-mode OCI image pulling, e.g. using tar files and remote registries in the same template
* adding option to use allow-all regex for environment variables
Expand Down
8 changes: 8 additions & 0 deletions src/confcom/azext_confcom/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,13 @@
SIDECAR_REGO_FILE = "./data/sidecar_rego_policy.txt"
SIDECAR_REGO_FILE_PATH = f"{script_directory}/{SIDECAR_REGO_FILE}"
SIDECAR_REGO_POLICY = os_util.load_str_from_file(SIDECAR_REGO_FILE_PATH)
# framework svn file
SVN_FRAMEWORK_FILE = "./data/svn_framework"
SVN_FRAMEWORK_PATH = f"{script_directory}/{SVN_FRAMEWORK_FILE}"
SVN_FRAMEWORK_VERSION = os_util.load_str_from_file(SVN_FRAMEWORK_PATH)
# api svn file
SVN_API_FILE = "./data/svn_api"
SVN_API_PATH = f"{script_directory}/{SVN_API_FILE}"
SVN_API_VERSION = os_util.load_str_from_file(SVN_API_PATH)
# default containers to be added to all container groups
DEFAULT_CONTAINERS = _config["default_containers"]
4 changes: 2 additions & 2 deletions src/confcom/azext_confcom/data/customer_rego_policy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package policy
import future.keywords.every
import future.keywords.in

api_svn := "0.10.0"
framework_svn := "0.1.0"
api_svn := %s
framework_svn := %s

fragments := %s

Expand Down
2 changes: 1 addition & 1 deletion src/confcom/azext_confcom/data/internal_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.12",
"version": "0.2.13",
"hcsshim_config": {
"maxVersion": "1.0.0",
"minVersion": "0.0.1"
Expand Down
4 changes: 2 additions & 2 deletions src/confcom/azext_confcom/data/sidecar_rego_policy.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package microsoftcontainerinstance

svn := "1.0.0"
api_svn := "0.10.0"
framework_svn := "0.1.0"
api_svn := %s
framework_svn := %s

containers := %s
10 changes: 9 additions & 1 deletion src/confcom/azext_confcom/security_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(
self._disable_stdio = disable_stdio
self._fragments = rego_fragments
self._existing_fragments = existing_rego_fragments
self._svn_api = config.SVN_API_VERSION
self._svn_framework = config.SVN_FRAMEWORK_VERSION
hgarvison marked this conversation as resolved.
Show resolved Hide resolved
if debug_mode:
self._allow_properties_access = config.DEBUG_MODE_SETTINGS.get(
"allowPropertiesAccess"
Expand Down Expand Up @@ -175,8 +177,14 @@ def _add_rego_boilerplate(self, output: str) -> str:

# determine if we're outputting for a sidecar or not
if self._images[0].get_id() and is_sidecar(self._images[0].get_id()):
return config.SIDECAR_REGO_POLICY % (output)
return config.SIDECAR_REGO_POLICY % (
pretty_print_func(self._svn_api),
pretty_print_func(self._svn_framework),
output
)
return config.CUSTOMER_REGO_POLICY % (
pretty_print_func(self._svn_api),
pretty_print_func(self._svn_framework),
pretty_print_func(self._fragments),
output,
pretty_print_func(self._allow_properties_access),
Expand Down
63 changes: 49 additions & 14 deletions src/confcom/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

logger.warn("Wheel is not available, disabling bdist_wheel hook")

# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.
VERSION = "0.2.12"
VERSION = "0.2.13"

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand All @@ -43,21 +41,58 @@

dir_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "azext_confcom")

bin_folder = dir_path + "/bin"
bin_folder = dir_path + "/bin/"
if not os.path.exists(bin_folder):
os.makedirs(bin_folder)

exe_path = dir_path + "/bin/dmverity-vhd.exe"
if not os.path.exists(exe_path):
r = requests.get("https://github.com/microsoft/hcsshim/releases/download/v0.10.0-rc.6/dmverity-vhd.exe")
with open(exe_path, "wb") as f:
f.write(r.content)
data_folder = dir_path + "/data/"
if not os.path.exists(data_folder):
os.makedirs(data_folder)

bin_path = dir_path + "/bin/dmverity-vhd"
if not os.path.exists(bin_path):
r = requests.get("https://github.com/microsoft/hcsshim/releases/download/v0.10.0-rc.6/dmverity-vhd")
with open(bin_path, "wb") as f:
f.write(r.content)
# get the most recent release artifacts from github
r = requests.get("https://api.github.com/repos/microsoft/hcsshim/releases")
# list the artifacts from each release
bin_flag = False
exe_flag = False
svn_flag = False
for release in r.json():
# these should be newest to oldest
for asset in release["assets"]:
# download the file if it contains dmverity-vhd
if "dmverity-vhd" in asset["name"]:
if "exe" in asset["name"]:
exe_flag = True
else:
bin_flag = True
# get the download url for the dmverity-vhd file
exe_url = asset["browser_download_url"]
# download the file
r = requests.get(exe_url)
# save the file to the bin folder
with open(bin_folder + asset["name"], "wb") as f:
f.write(r.content)
elif bin_flag and exe_flag and "tar.gz" in asset["name"]:
svn_flag = True
# get the download url for the dmverity-vhd file
exe_url = asset["browser_download_url"]
# update the url to get framework svn file
exe_url.replace(".tar.gz", "pkg/securitypolicy/svn_framework")
# download the file
r = requests.get(exe_url)
# save the file to the data folder
with open(data_folder + "svn_framework", "w") as f:
f.write(r.content)
# update the url to get api svn file
exe_url.replace("framework", "api")
# download the file
r = requests.get(exe_url)
# save the file to the data folder
with open(data_folder + "svn_api", "w") as f:
f.write(r.content)

# break out of the loop if we have both files
if bin_flag and exe_flag and svn_flag:
break

with open("README.md", "r", encoding="utf-8") as f:
README = f.read()
Expand Down