Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Main for profile-to-xslt.py
parser = _get_arg_parser()
args = parser.parse_args()
try:
# Assume valid XML, prep profile for conversion
options = scripts.ValidationOptions()
options.in_profile = args.profile
# Convert the profile
_convert_profile(options)
# If no exception was thrown, then conversion was successful.
sys.exit(codes.EXIT_SUCCESS)
except scripts.ArgumentError as ex:
if ex.show_help:
parser.print_help()
scripts.error(ex)
except Exception:
logging.exception("Fatal error occurred")
sys.exit(codes.EXIT_FAILURE)
the application.
Args:
args (argparse.Namespace): The arguments parsed and returned from
ArgumentParser.parse_args().
Raises:
ArgumentError: If invalid or incompatible command line arguments were
passed into the application.
"""
schema_validate = True
profile_validate = False
if schema_validate and args.profile:
profile_validate = True
if all((args.lang_version, args.use_schemaloc)):
raise scripts.ArgumentError(
"Cannot set both --stix-version and --use-schemalocs"
)
if args.profile and not profile_validate:
raise scripts.ArgumentError(
"Profile specified but no validation options specified."
)
if len(sys.argv) == 1:
raise scripts.ArgumentError("Invalid arguments", show_help=True)
if (args.files):
schema_validate = True
if schema_validate and args.profile:
profile_validate = True
if all((args.lang_version, args.use_schemaloc)):
raise scripts.ArgumentError(
"Cannot set both --stix-version and --use-schemalocs"
)
if args.profile and not profile_validate:
raise scripts.ArgumentError(
"Profile specified but no validation options specified."
)
def _validate_args(args):
"""Checks that valid and compatible command line arguments were passed into
the application.
Args:
args (argparse.Namespace): The arguments parsed and returned from
ArgumentParser.parse_args().
Raises:
ArgumentError: If invalid or incompatible command line arguments were
passed into the application.
"""
if len(sys.argv) == 1:
raise scripts.ArgumentError("Invalid arguments", show_help=True)
if args.lang_version and args.use_schemaloc:
raise scripts.ArgumentError(
"Cannot set both --cybox-version and --use-schemalocs"
)
the application.
Args:
args (argparse.Namespace): The arguments parsed and returned from
ArgumentParser.parse_args().
Raises:
ArgumentError: If invalid or incompatible command line arguments were
passed into the application.
"""
if len(sys.argv) == 1:
raise scripts.ArgumentError("Invalid arguments", show_help=True)
if args.lang_version and args.use_schemaloc:
raise scripts.ArgumentError(
"Cannot set both --cybox-version and --use-schemalocs"
)
"""
schema_validate = False
profile_validate = False
if len(sys.argv) == 1:
raise scripts.ArgumentError("Invalid arguments", show_help=True)
if (args.files):
schema_validate = True
if schema_validate and args.profile:
profile_validate = True
if all((args.lang_version, args.use_schemaloc)):
raise scripts.ArgumentError(
"Cannot set both --stix-version and --use-schemalocs"
)
if args.profile and not profile_validate:
raise scripts.ArgumentError(
"Profile specified but no validation options specified."
)