mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-17 14:54:21 +01:00
added in safe target
This commit is contained in:
@@ -113,12 +113,16 @@ class InputHelper(object):
|
||||
|
||||
@staticmethod
|
||||
def _replace_target_variables_in_commands(tasks, str_targets, ipset_targets):
|
||||
def starts_and_ends_with(string, character):
|
||||
return string[0] == character and string[-1] == character
|
||||
TARGET_VAR = "_target_"
|
||||
HOST_VAR = "_host_"
|
||||
CLEANTARGET_VAR = "_cleantarget_"
|
||||
SAFE_TARGET = "_safe-target_"
|
||||
for task in tasks:
|
||||
command = task.name()
|
||||
if TARGET_VAR in command or HOST_VAR in command:
|
||||
print(command)
|
||||
if TARGET_VAR in command or HOST_VAR in command or SAFE_TARGET in command:
|
||||
for dirty_target in itertools.chain(str_targets, ipset_targets):
|
||||
yielded_task = task.clone()
|
||||
dirty_target = str(dirty_target)
|
||||
@@ -129,6 +133,13 @@ class InputHelper(object):
|
||||
dirty_target.replace("http://", "").replace(
|
||||
"https://", "").rstrip("/").replace("/", "-"),
|
||||
)
|
||||
|
||||
if SAFE_TARGET in command:
|
||||
if (starts_and_ends_with(dirty_target, "'")) or (starts_and_ends_with(dirty_target, '"')):
|
||||
pass
|
||||
else:
|
||||
dirty_target = f"'{dirty_target}'"
|
||||
yielded_task.replace(SAFE_TARGET, dirty_target)
|
||||
yield yielded_task
|
||||
elif CLEANTARGET_VAR in command:
|
||||
for dirty_target in itertools.chain(str_targets, ipset_targets):
|
||||
|
||||
Reference in New Issue
Block a user