From 88e4cf97b65fd4de81716cec4be76cdb955dcb09 Mon Sep 17 00:00:00 2001 From: chkp-ofirs Date: Tue, 11 Oct 2022 21:15:08 +0300 Subject: [PATCH] Revert "SmartConnector: Override character limitation of custom-fields" --- SmartMove/SmartConnector/smartconnector.py | 37 ++-------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/SmartMove/SmartConnector/smartconnector.py b/SmartMove/SmartConnector/smartconnector.py index 5100230..57f7b41 100644 --- a/SmartMove/SmartConnector/smartconnector.py +++ b/SmartMove/SmartConnector/smartconnector.py @@ -1029,25 +1029,8 @@ def addAccessRules(client, userRules, userLayerName, skipCleanUpRule, mergedNetw } if userRule['Action'] == 3: payload["inline-layer"] = userRule['SubPolicyName'] - - # Due to the custom-fields.field-[1-3] having a limit of 254 Characters, this is used as a workaround - # Rule comments will stil be imported if they exist in userRule['Comments'] - # The default value is False, so custom-fields will still be utilized. - # - # If the Conversion Comments is > 250, then we should trim it. - # This matches the behavior in CheckPointObjects/CLIScriptBuilder.cs (limit there is 150) - # - if isIgnoreConversionComments != True: - if userRule['ConversionComments'].strip() != "": - if len(userRule['ConversionComments']) > 250: - lenConversionComments=len(userRule['ConversionComments']) - newConversionComment = (userRule['ConversionComments'][:250] +'...') - payload["custom-fields"] = {"field-1": newConversionComment} - printStatus(None, "WARN: Conversion Comment truncated due to length (" + str(lenConversionComment) +")") - else: - payload["custom-fields"] = {"field-1": userRule['ConversionComments']} - # - + if userRule['ConversionComments'].strip() != "": + payload["custom-fields"] = {"field-1": userRule['ConversionComments']} addedRule = addUserObjectToServer(client, "add-access-rule", payload, changeName=False) if addedRule is not None: printStatus(None, "REPORT: access rule is added") @@ -1247,8 +1230,7 @@ def processNatRules(client, addedPackage, userNatRules, mergedNetworkObjectsMap, help="The name/uid of the domain you want to log into in an MDS environment.") args_parser.add_argument('--replace-from-global-first', default="false", help="The argument indicates that SmartConnector should use 'Global' objects at first, by default it uses 'Local' objects. [true, false]") -args_parser.add_argument('--ignore-conversion-comments', default="false", - help="The argument indicates that SmartConnector should not add conversion comments into custom-fields [true, false]") + args = args_parser.parse_args() file_name_log = "smartconnector" @@ -1285,23 +1267,11 @@ def processNatRules(client, addedPackage, userNatRules, mergedNetworkObjectsMap, "smartconnector.py: error: argument --replace-from-global-first: invalid boolean value: '" + args.replace_from_global_first + "'") print("") args_parser.print_help() -elif args.ignore_conversion_comments.lower() != "true" and args.ignore_conversion_comments.lower() != "false": - print("") - printStatus(None, None, - "smartconnector.py: error: argument '--ignore-conversion-comments: invalid boolean value: '" + args.ignore_conversion_comments + "'") - print("") - args_parser.print_help() - else: if args.replace_from_global_first.lower() == "true": isReplaceFromGlobalFirst = True elif args.replace_from_global_first.lower() == "false": isReplaceFromGlobalFirst = False - if args.ignore_conversion_comments.lower() == "true": - isIgnoreConversionComments = True - else: - isIgnoreConversionComments = False - printStatus(None, "Input arguments:") printStatus(None, "root flag is set" if args.root else "root flag is not set") printStatus(None, "management: " + args.management) @@ -1314,7 +1284,6 @@ def processNatRules(client, addedPackage, userNatRules, mergedNetworkObjectsMap, printStatus(None, "file: " + args.file) printStatus(None, "threshold: " + str(args.threshold)) printStatus(None, "replace-from-global-first: " + str(isReplaceFromGlobalFirst)) - printStatus(None, "ignore-conversion-comments: " + str(isIgnoreConversionComments)) printStatus(None, "===========================================") printStatus(None, "reading and parsing processes are started for JSON file: " + args.file) with open(args.file) as json_file: