Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def sros_keystore_delete(args):
# todo: parameterize keystore location, if we expand to multiple keyrings
keystore_path = rospkg.get_sros_keystore_path()
# do a tiny bit of sanity check...
if keystore_path.count('/') <= 1:
print("woah. I probably shouldn't delete this path: [%s]" % keystore_path)
sys.exit(1)
print("deleting keystore directory: [%s]" % keystore_path)
shutil.rmtree(keystore_path)
print("done.")
return 0
def __init__(self, caller_id):
super(TLSSecurity, self).__init__(caller_id)
_logger.info("rospy.security.TLSSecurity init")
self.keystore_path = rospkg.get_sros_keystore_path()
self.capath = os.path.join(self.keystore_path, 'capath')
self.nodestore_path = os.path.join(self.keystore_path, 'nodes', self.node_stem.lstrip('/'))
self.nodestore_paths = self.get_nodestore_paths()
if not self.nodestore_present():
self.init_nodestore()
if not self.ca_present():
self.init_ca()
self.init_context()
print('all startup certificates are present')
"""Setup parser for sroscore"""
self.add_argument(
'-c', '--keyserver_config',
action='store',
default=os.path.join(rospkg.get_sros_config_dir(), 'keyserver_config.yaml'),
help='path to custom config file')
self.add_argument(
'-m', '--keyserver_mode',
action='store',
default=sros_consts.VerifyModes.CERT_OPTIONAL,
help='verify mode *on* keyserver (CERT_NONE|[CERT_OPTIONAL]|CERT_REQUIRED)')
self.add_argument(
'-k', '--keystore_path',
action='store',
default=rospkg.get_sros_keystore_path(),
help='path to custom keystore path')
self.add_argument(
'-p', '--port',
action='store',
default=0,
help='keyserver port')
self.add_argument(
'-v', '--keyserver_verify',
action='store',
help='verify mode *of* keyserver (CERT_NONE|CERT_OPTIONAL|[CERT_REQUIRED])')
self.add_argument(
'--version',
action='version',
version='%(prog)s 0.0')
def sroscore_main(argv = sys.argv):
sroscore_parser = SroscoreParser(
prog='sroscore',
description='secure roscore')
sroscore_parser.set()
args, roscore_argv = sroscore_parser.parse_known_args(argv)
check_set_environ(
'SROS_KEYSTORE_PATH',
args.keystore_path,
rospkg.get_sros_keystore_path())
check_set_environ(
'SROS_KEYSERVER_VERIFY',
args.keyserver_verify,
sros_consts.VerifyModes.CERT_REQUIRED)
check_set_environ(
'SROS_POLICY_CONFIG',
args.policy_config,
os.path.join(rospkg.get_sros_config_dir(), 'policy_config.yaml'))
check_set_environ(
'SROS_POLICY_MODE',
args.policy_mode,
sros_consts.GraphModes.enforce)
def sroslaunch_main(argv = sys.argv):
check_environ(
'SROS_KEYSTORE_PATH',
rospkg.get_sros_keystore_path())
check_environ(
'SROS_KEYSERVER_VERIFY',
sros_consts.VerifyModes.CERT_REQUIRED)
check_environ(
'SROS_SECURITY',
sros_consts.SecuityModes.TLSv1_2)
check_environ(
'SROS_POLICY',
sros_consts.PolicyModes.NAMESPACE)
import roslaunch
roslaunch.main(argv)