[GH-ISSUE #1] No output from the script #1

Open
opened 2026-02-26 01:32:43 +03:00 by kerem · 0 comments
Owner

Originally created by @richardstrnad on GitHub (Oct 31, 2018).
Original GitHub issue: https://github.com/jh00nbr/Sophos-firewall-tools/issues/1

Hi jh00nbr,

Thanks for the script!
We faced the issue that there is simple no output from the script, after some troubleshooting we found that the function import_objects doesn't return anything.

We added x = x[0].split(':') to the function, now the script works for us:

def import_objects(file):
	read_file = [re.split(r' \s+', x.strip()) for x in open(file, "r").readlines()]
	OBJECT_EXCEPTION = []
	OBJECTS = []

	for x in read_file:
	    REGEX_IP = re.findall(r'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',x[0]) # Regex to Verify if exist ip address in object name
	    if REGEX_IP:
	            OBJECT_EXCEPTION.append(x)
            x = x[0].split(':')
	    try:
	            OBJECT_NAME = x[0]
	            OBJECT_VALUE = x[1]                
	            OBJECTS.append({ OBJECT_NAME : OBJECT_VALUE })
	    except:
	            pass
	return OBJECTS

Cheers
Richard

Originally created by @richardstrnad on GitHub (Oct 31, 2018). Original GitHub issue: https://github.com/jh00nbr/Sophos-firewall-tools/issues/1 Hi jh00nbr, Thanks for the script! We faced the issue that there is simple no output from the script, after some troubleshooting we found that the function `import_objects` doesn't return anything. We added `x = x[0].split(':')` to the function, now the script works for us: ```python def import_objects(file): read_file = [re.split(r' \s+', x.strip()) for x in open(file, "r").readlines()] OBJECT_EXCEPTION = [] OBJECTS = [] for x in read_file: REGEX_IP = re.findall(r'[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}',x[0]) # Regex to Verify if exist ip address in object name if REGEX_IP: OBJECT_EXCEPTION.append(x) x = x[0].split(':') try: OBJECT_NAME = x[0] OBJECT_VALUE = x[1] OBJECTS.append({ OBJECT_NAME : OBJECT_VALUE }) except: pass return OBJECTS ``` Cheers Richard
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Sophos-firewall-tools-jh00nbr#1
No description provided.