Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 20 additions & 8 deletions src/confcom/azext_confcom/template_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import deepdiff
import yaml
import docker
import pydash
from azext_confcom.errors import (
eprint,
)
Expand Down Expand Up @@ -852,26 +851,39 @@ def print_existing_policy_from_arm_template(arm_template_path, parameter_data_pa


def process_seccomp_policy(policy2):

def defaults(obj, default):
for key in default:
obj.setdefault(key, default[key])
return obj

def pick(obj, *keys):
result = {}
for key in keys:
if key in obj:
result[key] = obj[key]
return result

policy = json.loads(policy2)
policy = pydash.defaults(policy, {'defaultAction': ""})
policy = pydash.pick(policy, 'defaultAction', 'defaultErrnoRet', 'architectures',
'flags', 'listenerPath', 'listenerMetadata', 'syscalls')
policy = defaults(policy, {'defaultAction': ""})
policy = pick(policy, 'defaultAction', 'defaultErrnoRet', 'architectures',
'flags', 'listenerPath', 'listenerMetadata', 'syscalls')
if 'syscalls' in policy:
syscalls = policy['syscalls']
temp_syscalls = []
for s in syscalls:
syscall = s
syscall = pydash.defaults(syscall, {'names': [], 'action': ""})
syscall = pydash.pick(syscall, 'names', 'action', 'errnoRet', 'args')
syscall = defaults(syscall, {'names': [], 'action': ""})
syscall = pick(syscall, 'names', 'action', 'errnoRet', 'args')

if 'args' in syscall:
temp_args = []
args = syscall['args']

for j in args:
arg = j
arg = pydash.defaults(arg, {'value': 0, 'op': "", 'index': 0})
arg = pydash.pick(arg, 'index', 'value', 'valueTwo', 'op')
arg = defaults(arg, {'value': 0, 'op': "", 'index': 0})
arg = pick(arg, 'index', 'value', 'valueTwo', 'op')
temp_args.append(arg)
syscall['args'] = temp_args
temp_syscalls.append(syscall)
Expand Down
3 changes: 1 addition & 2 deletions src/confcom/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
docker
tqdm
azure-devtools
deepdiff
pydash
deepdiff
2 changes: 1 addition & 1 deletion src/confcom/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"License :: OSI Approved :: MIT License",
]

DEPENDENCIES = ["docker", "tqdm", "deepdiff", "pydash"]
DEPENDENCIES = ["docker", "tqdm", "deepdiff"]

SecurityPolicyProxy.download_binaries()

Expand Down