Skip to content

Commit

Permalink
Modify push() to not copy-on-write (True by default) if it's a single…
Browse files Browse the repository at this point in the history
… flow
  • Loading branch information
ikotler committed Oct 12, 2013
1 parent 8a9ad47 commit 191689f
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions hackersh/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ def run(self, argv, context):

try:

return_value.append(context.push(entry_key, entry))
_log.debug('Appending with Copy-on-Write!')

return_value.append(context.push(entry_key, entry, True))

self.logger.debug('Pushed!')

Expand Down Expand Up @@ -203,7 +205,9 @@ def run(self, argv, context):

try:

return_value = context.push(base_keyname, entry_or_entries)
_log.debug('Appending without Copy-on-Write!!!')

return_value = context.push(base_keyname, entry_or_entries, False)

# i.e "127.0.0.1" | ipv4_address | nmap | print_all => AttributeError: 'list' object has no attribute 'push'

Expand Down Expand Up @@ -483,11 +487,17 @@ def _copy(self):

return copy.deepcopy(self)

def push(self, key, value):
def push(self, key, value, copy_on_write=True):

# Copy-on-Write
if copy_on_write:

new_ctx = self._copy()
# Copy-on-Write

new_ctx = self._copy()

else:

new_ctx = self

# Started from ENVP (i.e. IPV4_ADDRESS="127.0.0.1" | ./bin/hackersh -c "_ | nmap") ?

Expand All @@ -497,7 +507,9 @@ def push(self, key, value):

new_ctx._graph.add_node('envp', value)

new_ctx._graph = new_ctx._graph.copy()
if copy_on_write:

new_ctx._graph = new_ctx._graph.copy()

new_ctx._graph.add_node(new_ctx._graph.graph['prefix'] + key, value)

Expand Down

0 comments on commit 191689f

Please sign in to comment.