The Gatekeeper, or a project gating system
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.2 KiB

#!/usr/bin/env python3
# Copyright 2020 BMW Group
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import argparse
import os
import subprocess
def main():
pos_args = {
'--dir': 1,
'--tmpfs': 1,
'--ro-bind': 2,
'--bind': 2,
'--chdir': 1,
'--uid': 1,
'--gid': 1,
'--file': 2,
'--proc': 1,
'--dev': 1,
bool_args = [
parser = argparse.ArgumentParser()
for arg, nargs in pos_args.items():
parser.add_argument(arg, nargs=nargs, action='append')
for arg in bool_args:
parser.add_argument(arg, action='store_true')
parser.add_argument('args', metavar='args', nargs=argparse.REMAINDER,
args = parser.parse_args()
for fd, path in args.file:
fd = int(fd)
if path.startswith('/etc'):
# Ignore write requests to /etc
print('Writing file from %s to %s' % (fd, path))
count = 0
with open(path, 'wb') as output:
data =, 32000)
while data:
count += len(data)
data =, 32000)
print('Wrote file (%s bytes)' % count)
if args.chdir:
result =, shell=False, check=False)
if __name__ == '__main__':