Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Tubes #63

Merged
merged 6 commits into from
Nov 8, 2017
Merged

Enhance Tubes #63

merged 6 commits into from
Nov 8, 2017

Conversation

hanhanW
Copy link
Collaborator

@hanhanW hanhanW commented Nov 1, 2017


This change is Reviewable

* Implement gets for Tubes
* Implement puts for Tubes
  * Fixed #59
  * Fixed #61
* Catch EOFError in the interative mode ( Fixed #60 )
s = ''
objs.map(&:to_s).each do |elem|
s << elem
s << context.newline if elem.empty? || !elem.end_with?(context.newline)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to check elem.empty??

@@ -236,6 +281,8 @@ def interact
$stdout.write(s)
end
end
rescue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only rescue EOFError.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: Use our own Exception class

@@ -9,10 +9,18 @@
module Pwnlib
module Tubes
# Things common to all tubes (sockets, tty, ...)
# @!macro [new] drop_definition
# @param [Boalean] drop
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean

# @!macro timeout_definition
#
# @return [String]
# The next "line".
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add examples to clarify its recvuntil-like functionality

@@ -236,6 +281,8 @@ def interact
$stdout.write(s)
end
end
rescue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future work: Use our own Exception class

@hanhanW
Copy link
Collaborator Author

hanhanW commented Nov 1, 2017

Review status: 0 of 2 files reviewed at latest revision, 4 unresolved discussions.


lib/pwnlib/tubes/tube.rb, line 13 at r1 (raw file):

Previously, david942j (david942j) wrote…

Boolean

Done.


lib/pwnlib/tubes/tube.rb, line 206 at r1 (raw file):

Previously, david942j (david942j) wrote…

add examples to clarify its recvuntil-like functionality

Done.


lib/pwnlib/tubes/tube.rb, line 263 at r1 (raw file):

Previously, ShikChen wrote…

Why need to check elem.empty??

Done.


lib/pwnlib/tubes/tube.rb, line 284 at r1 (raw file):

Previously, david942j (david942j) wrote…

Future work: Use our own Exception class

Done.


Comments from Reviewable

# The difference with IO#gets is using +context.newline+ as default newline.
#
# @param [Integer, String] sep
# The separator.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

describe the behavior when an integer is passed

alias gets recvline

# Receives the next "line" from the tube; lines are separated by +sep+.
# The difference with IO#gets is using +context.newline+ as default newline.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+IO#gets+

end

# Sends the given object(s) to the tube.
# The difference with IO#puts is using +context.newline+ as default newline.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+IO#puts+

@hanhanW
Copy link
Collaborator Author

hanhanW commented Nov 2, 2017

Review status: 0 of 2 files reviewed at latest revision, 7 unresolved discussions.


lib/pwnlib/tubes/tube.rb, line 198 at r2 (raw file):

Previously, david942j (david942j) wrote…

+IO#gets+

Done.


lib/pwnlib/tubes/tube.rb, line 201 at r2 (raw file):

Previously, david942j (david942j) wrote…

describe the behavior when an integer is passed

Done.


lib/pwnlib/tubes/tube.rb, line 274 at r2 (raw file):

Previously, david942j (david942j) wrote…

+IO#puts+

Done.


Comments from Reviewable

# s.puts
# puts client.recv
# #
#
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add #=> nil, otherwise it looks weird

# The difference with +IO#puts+ is using +context.newline+ as default newline.
#
# @param [Array<Object>] objs
# The objects to send.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be sent

@@ -169,12 +180,11 @@ def recvuntil(delims, drop: false, timeout: nil)
end
end

# Receive a single line from the tube.
# Receives a single line from the tube.
# A "line" is any sequence of bytes terminated by the byte sequence set in +context.newline+,
# which defaults to +"\n"+.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+"\n"+ broken in parsed doc

@hanhanW
Copy link
Collaborator Author

hanhanW commented Nov 2, 2017

Review status: 0 of 2 files reviewed at latest revision, 10 unresolved discussions.


lib/pwnlib/tubes/tube.rb, line 185 at r3 (raw file):

Previously, david942j (david942j) wrote…

+"\n"+ broken in parsed doc

Done.


lib/pwnlib/tubes/tube.rb, line 282 at r3 (raw file):

Previously, david942j (david942j) wrote…

to be sent

Done.


lib/pwnlib/tubes/tube.rb, line 290 at r3 (raw file):

Previously, david942j (david942j) wrote…

add #=> nil, otherwise it looks weird

Done.


Comments from Reviewable

@david942j
Copy link
Collaborator

@ShikChen

@david942j
Copy link
Collaborator

Reviewed 1 of 2 files at r3, 1 of 1 files at r4.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@david942j
Copy link
Collaborator

:lgtm:


Review status: all files reviewed at latest revision, 2 unresolved discussions.


Comments from Reviewable

@david942j david942j merged commit 8f31313 into master Nov 8, 2017
@david942j david942j deleted the feature/tube branch November 8, 2017 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants