watobo 0.9.8.677
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/watobo_gui.rb +39 -0
- data/certificates/cert.pem +19 -0
- data/certificates/privkey.pem +15 -0
- data/certificates/watobo_dh.key +5 -0
- data/config/datastore.yml +5 -0
- data/config/forwarding_proxy.yml +12 -0
- data/config/general.yml +4 -0
- data/config/gui.yml +23 -0
- data/config/interceptor.yml +16 -0
- data/config/scan_policy.yml +13 -0
- data/config/scanner.yml +34 -0
- data/icons/Add.ico +0 -0
- data/icons/Add_24x24.ico +0 -0
- data/icons/Bandwidth.ico +0 -0
- data/icons/Bandwidth_24x24.ico +0 -0
- data/icons/Mr. Bomb.ico +0 -0
- data/icons/Mr. Bomb_16x16.ico +0 -0
- data/icons/Mr. Bomb_24x24.ico +0 -0
- data/icons/Orange Ball.ico +0 -0
- data/icons/Orange Ball_16x16.ico +0 -0
- data/icons/Orange Ball_24x24.ico +0 -0
- data/icons/Pause.ico +0 -0
- data/icons/Play.ico +0 -0
- data/icons/Play_24x24.ico +0 -0
- data/icons/Red Ball.ico +0 -0
- data/icons/Red Ball_16x16.ico +0 -0
- data/icons/Red Ball_24x24.ico +0 -0
- data/icons/Run.ico +0 -0
- data/icons/Stop.ico +0 -0
- data/icons/Stop_24x24.ico +0 -0
- data/icons/Terminal.ico +0 -0
- data/icons/Transfer.ico +0 -0
- data/icons/Transfer_16x16.ico +0 -0
- data/icons/User.ico +0 -0
- data/icons/User_16x16.ico +0 -0
- data/icons/User_24x24.ico +0 -0
- data/icons/Web Browser.ico +0 -0
- data/icons/Web Browser_16x16.ico +0 -0
- data/icons/Write Document.ico +0 -0
- data/icons/Yellow Ball.ico +0 -0
- data/icons/Yellow Ball_16x16.ico +0 -0
- data/icons/Yellow Ball_24x24.ico +0 -0
- data/icons/advanced.ico +0 -0
- data/icons/advanced_16x16.ico +0 -0
- data/icons/advanced_24x24.ico +0 -0
- data/icons/applications.ico +0 -0
- data/icons/applications_16x16.ico +0 -0
- data/icons/applications_24x24.ico +0 -0
- data/icons/browser_16x16.ico +0 -0
- data/icons/browser_24x24.ico +0 -0
- data/icons/burn.ico +0 -0
- data/icons/burn_16x16.ico +0 -0
- data/icons/burn_24x24.ico +0 -0
- data/icons/calculator.ico +0 -0
- data/icons/calculator_24x24.ico +0 -0
- data/icons/cb_checked.ico +0 -0
- data/icons/cb_checked_orange.ico +0 -0
- data/icons/cb_unchecked.ico +0 -0
- data/icons/coin_24x24.ico +0 -0
- data/icons/conversation.ico +0 -0
- data/icons/conversation_24x24.ico +0 -0
- data/icons/engine.ico +0 -0
- data/icons/filter.ico +0 -0
- data/icons/folder.ico +0 -0
- data/icons/folder_16x16.ico +0 -0
- data/icons/fuzzer_16x16.ico +0 -0
- data/icons/fuzzer_24x24.ico +0 -0
- data/icons/go-down_16x16.png +0 -0
- data/icons/go-up_16x16.png +0 -0
- data/icons/help.ico +0 -0
- data/icons/help_16x16.ico +0 -0
- data/icons/help_24x24.ico +0 -0
- data/icons/iChat.ico +0 -0
- data/icons/iChat_16x16.ico +0 -0
- data/icons/iChat_24x24.ico +0 -0
- data/icons/icons.txt +3 -0
- data/icons/info.ico +0 -0
- data/icons/info_16x16.ico +0 -0
- data/icons/info_24x24.ico +0 -0
- data/icons/interceptor_24x24.ico +0 -0
- data/icons/lock.ico +0 -0
- data/icons/lock_12x12.ico +0 -0
- data/icons/lock_16x16.ico +0 -0
- data/icons/monitor.ico +0 -0
- data/icons/plugin.ico +0 -0
- data/icons/plugin_24x24.ico +0 -0
- data/icons/scan_16x16.png +0 -0
- data/icons/send.ico +0 -0
- data/icons/server.ico +0 -0
- data/icons/server_16x16.ico +0 -0
- data/icons/siberas_logo_x24.gif +0 -0
- data/icons/tag_blue_32x32.ico +0 -0
- data/icons/watobo-48x48.png +0 -0
- data/icons/watobo-logo.png +0 -0
- data/icons/watobo.ico +0 -0
- data/lib/watobo/adapters/data_store.rb +38 -0
- data/lib/watobo/adapters/file/file_store.rb +211 -0
- data/lib/watobo/adapters/session_store.rb +27 -0
- data/lib/watobo/adapters.rb +26 -0
- data/lib/watobo/config.rb +143 -0
- data/lib/watobo/constants.rb +92 -0
- data/lib/watobo/core/active_check.rb +404 -0
- data/lib/watobo/core/cookie.rb +69 -0
- data/lib/watobo/core/fuzz_gen.rb +160 -0
- data/lib/watobo/core/http_socket.rb +142 -0
- data/lib/watobo/core/interceptor.rb +729 -0
- data/lib/watobo/core/passive_check.rb +141 -0
- data/lib/watobo/core/project.rb +1058 -0
- data/lib/watobo/core/scanner.rb +396 -0
- data/lib/watobo/core/session.rb +1320 -0
- data/lib/watobo/core/simple_ca.rb +393 -0
- data/lib/watobo/core.rb +34 -0
- data/lib/watobo/defaults.rb +40 -0
- data/lib/watobo/external/diff/lcs/array.rb +42 -0
- data/lib/watobo/external/diff/lcs/block.rb +72 -0
- data/lib/watobo/external/diff/lcs/callbacks.rb +343 -0
- data/lib/watobo/external/diff/lcs/change.rb +190 -0
- data/lib/watobo/external/diff/lcs/hunk.rb +279 -0
- data/lib/watobo/external/diff/lcs/ldiff.rb +247 -0
- data/lib/watobo/external/diff/lcs/string.rb +40 -0
- data/lib/watobo/external/diff/lcs.rb +1124 -0
- data/lib/watobo/external/ntlm/ntlm.rb +797 -0
- data/lib/watobo/externals.rb +28 -0
- data/lib/watobo/framework/create_project.rb +55 -0
- data/lib/watobo/framework/init.rb +149 -0
- data/lib/watobo/framework/init_modules.rb +116 -0
- data/lib/watobo/framework/license_text.rb +50 -0
- data/lib/watobo/framework.rb +26 -0
- data/lib/watobo/gui/about_watobo.rb +68 -0
- data/lib/watobo/gui/browser_preview.rb +460 -0
- data/lib/watobo/gui/certificate_dialog.rb +132 -0
- data/lib/watobo/gui/chat_diff.rb +415 -0
- data/lib/watobo/gui/chatviewer_frame.rb +427 -0
- data/lib/watobo/gui/checkboxtree.rb +221 -0
- data/lib/watobo/gui/checks_policy_frame.rb +123 -0
- data/lib/watobo/gui/client_cert_dialog.rb +227 -0
- data/lib/watobo/gui/confirm_scan_dialog.rb +67 -0
- data/lib/watobo/gui/conversation_table.rb +386 -0
- data/lib/watobo/gui/conversation_table_ctrl.rb +175 -0
- data/lib/watobo/gui/csrf_token_dialog.rb +446 -0
- data/lib/watobo/gui/dashboard.rb +341 -0
- data/lib/watobo/gui/define_scope_frame.rb +380 -0
- data/lib/watobo/gui/edit_comment.rb +70 -0
- data/lib/watobo/gui/edit_scope_dialog.rb +69 -0
- data/lib/watobo/gui/finding_info.rb +212 -0
- data/lib/watobo/gui/findings_tree.rb +459 -0
- data/lib/watobo/gui/full_scan_dialog.rb +269 -0
- data/lib/watobo/gui/fuzzer_gui.rb +1522 -0
- data/lib/watobo/gui/hex_viewer.rb +106 -0
- data/lib/watobo/gui/interceptor_gui.rb +994 -0
- data/lib/watobo/gui/interceptor_settings_dialog.rb +201 -0
- data/lib/watobo/gui/log_viewer.rb +97 -0
- data/lib/watobo/gui/login_wizzard.rb +301 -0
- data/lib/watobo/gui/main_window.rb +1815 -0
- data/lib/watobo/gui/manual_request_editor.rb +1105 -0
- data/lib/watobo/gui/master_pw_dialog.rb +142 -0
- data/lib/watobo/gui/password_policy_dialog.rb +98 -0
- data/lib/watobo/gui/plugin/base.rb +82 -0
- data/lib/watobo/gui/plugin_board.rb +95 -0
- data/lib/watobo/gui/preferences_dialog.rb +116 -0
- data/lib/watobo/gui/progress_window.rb +102 -0
- data/lib/watobo/gui/project_wizzard.rb +369 -0
- data/lib/watobo/gui/proxy_dialog.rb +550 -0
- data/lib/watobo/gui/quick_scan_dialog.rb +242 -0
- data/lib/watobo/gui/request_editor.rb +480 -0
- data/lib/watobo/gui/save_chat_dialog.rb +158 -0
- data/lib/watobo/gui/scanner_settings_dialog.rb +360 -0
- data/lib/watobo/gui/select_chat_dialog.rb +169 -0
- data/lib/watobo/gui/session_management_dialog.rb +688 -0
- data/lib/watobo/gui/sites_tree.rb +347 -0
- data/lib/watobo/gui/status_bar.rb +88 -0
- data/lib/watobo/gui/table_editor.rb +445 -0
- data/lib/watobo/gui/tagless_viewer.rb +62 -0
- data/lib/watobo/gui/templates/plugin.rb +80 -0
- data/lib/watobo/gui/templates/plugin2.rb +103 -0
- data/lib/watobo/gui/text_viewer.rb +247 -0
- data/lib/watobo/gui/transcoder_window.rb +215 -0
- data/lib/watobo/gui/utils/gui_utils.rb +129 -0
- data/lib/watobo/gui/utils/init_icons.rb +106 -0
- data/lib/watobo/gui/utils/load_icons.rb +54 -0
- data/lib/watobo/gui/utils/load_plugins.rb +94 -0
- data/lib/watobo/gui/utils/master_password.rb +90 -0
- data/lib/watobo/gui/utils/save_default_settings.rb +99 -0
- data/lib/watobo/gui/utils/save_project_settings.rb +21 -0
- data/lib/watobo/gui/utils/save_proxy_settings.rb +45 -0
- data/lib/watobo/gui/utils/save_session_settings.rb +21 -0
- data/lib/watobo/gui/utils/session_history.rb +134 -0
- data/lib/watobo/gui/workspace_dialog.rb +89 -0
- data/lib/watobo/gui/www_auth_dialog.rb +348 -0
- data/lib/watobo/gui/xml_viewer_frame.rb +114 -0
- data/lib/watobo/gui.rb +139 -0
- data/lib/watobo/mixins/httpparser.rb +664 -0
- data/lib/watobo/mixins/request_parser.rb +210 -0
- data/lib/watobo/mixins/shapers.rb +345 -0
- data/lib/watobo/mixins/transcoders.rb +88 -0
- data/lib/watobo/mixins.rb +32 -0
- data/lib/watobo/utils/check_regex.rb +36 -0
- data/lib/watobo/utils/copy_object.rb +29 -0
- data/lib/watobo/utils/crypto.rb +74 -0
- data/lib/watobo/utils/expand_range.rb +45 -0
- data/lib/watobo/utils/file_management.rb +73 -0
- data/lib/watobo/utils/load_chat.rb +219 -0
- data/lib/watobo/utils/load_icon.rb +47 -0
- data/lib/watobo/utils/print_debug.rb +34 -0
- data/lib/watobo/utils/response_hash.rb +143 -0
- data/lib/watobo/utils/secure_eval.rb +57 -0
- data/lib/watobo/utils/text2request.rb +96 -0
- data/lib/watobo/utils.rb +32 -0
- data/lib/watobo.rb +76 -0
- data/modules/active/Apache/mod_status.rb +123 -0
- data/modules/active/Flash/crossdomain.rb +102 -0
- data/modules/active/directories/dirwalker.rb +89 -0
- data/modules/active/discovery/fileextensions.rb +151 -0
- data/modules/active/discovery/http_methods.rb +135 -0
- data/modules/active/domino/domino_db.lst +164 -0
- data/modules/active/domino/domino_db.rb +128 -0
- data/modules/active/fileinclusion/lfi_simple.rb +134 -0
- data/modules/active/jboss/jboss_basic.rb +119 -0
- data/modules/active/sap/business_objects.rb +73 -0
- data/modules/active/sap/its_commands.rb +101 -0
- data/modules/active/sap/its_service_parameter.rb +105 -0
- data/modules/active/sap/its_services.rb +103 -0
- data/modules/active/sap/its_xss.rb +98 -0
- data/modules/active/sqlinjection/sql_boolean.rb +262 -0
- data/modules/active/sqlinjection/sqli_simple.rb +205 -0
- data/modules/active/xss/xss_simple.rb +179 -0
- data/modules/passive/cookie_options.rb +97 -0
- data/modules/passive/cookie_xss.rb +85 -0
- data/modules/passive/detect_code.rb +89 -0
- data/modules/passive/detect_fileupload.rb +80 -0
- data/modules/passive/detect_infrastructure.rb +98 -0
- data/modules/passive/detect_one_time_tokens.rb +86 -0
- data/modules/passive/dirindexing.rb +81 -0
- data/modules/passive/disclosure_emails.rb +82 -0
- data/modules/passive/disclosure_ipaddr.rb +87 -0
- data/modules/passive/filename_as_parameter.rb +85 -0
- data/modules/passive/form_spotter.rb +75 -0
- data/modules/passive/hotspots.rb +86 -0
- data/modules/passive/in_script_parameter.rb +92 -0
- data/modules/passive/multiple_server_headers.rb +98 -0
- data/modules/passive/possible_login.rb +134 -0
- data/modules/passive/redirect_url.rb +88 -0
- data/modules/passive/redirectionz.rb +96 -0
- data/modules/passive/xss_dom.rb +91 -0
- data/plugins/catalog/catalog.ico +0 -0
- data/plugins/catalog/catalog.rb +726 -0
- data/plugins/catalog/db_tests +6483 -0
- data/plugins/catalog/db_variables +29 -0
- data/plugins/filefinder/dbs/hbci.db +12 -0
- data/plugins/filefinder/filefinder.rb +602 -0
- data/plugins/sslchecker/cli/sslchecker_cli.rb +21 -0
- data/plugins/sslchecker/gui/cipher_table.rb +260 -0
- data/plugins/sslchecker/gui/gui.rb +245 -0
- data/plugins/sslchecker/gui/sslchecker.rb +26 -0
- data/plugins/sslchecker/icons/green_16x16.ico +0 -0
- data/plugins/sslchecker/icons/grey_16x16.ico +0 -0
- data/plugins/sslchecker/icons/red_16x16.ico +0 -0
- data/plugins/sslchecker/icons/sslchecker.ico +0 -0
- data/plugins/sslchecker/lib/check.rb +117 -0
- metadata +317 -0
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
# .
|
|
2
|
+
# chat_diff.rb
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2012 by siberas, http://www.siberas.de
|
|
5
|
+
#
|
|
6
|
+
# This file is part of WATOBO (Web Application Tool Box)
|
|
7
|
+
# http://watobo.sourceforge.com
|
|
8
|
+
#
|
|
9
|
+
# WATOBO is free software; you can redistribute it and/or modify
|
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
|
11
|
+
# the Free Software Foundation version 2 of the License.
|
|
12
|
+
#
|
|
13
|
+
# WATOBO is distributed in the hope that it will be useful,
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16
|
+
# GNU General Public License for more details.
|
|
17
|
+
#
|
|
18
|
+
# You should have received a copy of the GNU General Public License
|
|
19
|
+
# along with WATOBO; if not, write to the Free Software
|
|
20
|
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
21
|
+
# .
|
|
22
|
+
module Watobo
|
|
23
|
+
module Gui
|
|
24
|
+
DIFF_TYPE_ORIG = 0
|
|
25
|
+
DIFF_TYPE_NEW = 1
|
|
26
|
+
|
|
27
|
+
include Diff::LCS
|
|
28
|
+
|
|
29
|
+
class ChatDiffFrame < FXVerticalFrame
|
|
30
|
+
|
|
31
|
+
def textWidth=(cols)
|
|
32
|
+
@textWidth = cols
|
|
33
|
+
@dataText.wrapColumns = cols
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def textWidth
|
|
38
|
+
@textWidth
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def highlightChanges(textWidget, text, diff_blocks)
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def makeRowVisible(row)
|
|
47
|
+
data_rows = @dataText.to_s.split("\n")
|
|
48
|
+
if row > 0 then
|
|
49
|
+
pos = data_rows.slice(0..row-1).join("\n").length+1
|
|
50
|
+
else
|
|
51
|
+
pos = 0
|
|
52
|
+
end
|
|
53
|
+
@dataText.makePositionVisible(@dataText.to_s.length)
|
|
54
|
+
@dataText.makePositionVisible(pos)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def showDiff(data, diff_blocks)
|
|
58
|
+
data_pos = 0
|
|
59
|
+
diff_pos = 0
|
|
60
|
+
@dataText.setText('')
|
|
61
|
+
|
|
62
|
+
begin
|
|
63
|
+
if diff_blocks.length > 0 then
|
|
64
|
+
data.each do |d|
|
|
65
|
+
if diff_blocks[diff_pos].position == data_pos then
|
|
66
|
+
@dataText.appendStyledText(data[data_pos]+"\n", @style)
|
|
67
|
+
diff_pos += 1
|
|
68
|
+
else
|
|
69
|
+
@dataText.appendText(data[data_pos]+"\n")
|
|
70
|
+
end
|
|
71
|
+
data_pos += 1
|
|
72
|
+
break if diff_pos >= diff_blocks.length
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
while data_pos < data.length
|
|
77
|
+
@dataText.appendText(data[data_pos]+"\n")
|
|
78
|
+
data_pos += 1
|
|
79
|
+
end
|
|
80
|
+
rescue => bang
|
|
81
|
+
puts bang
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def initialize(owner, opts)
|
|
87
|
+
@textWidth = 80
|
|
88
|
+
@diffType = DIFF_TYPE_ORIG
|
|
89
|
+
@style = 1
|
|
90
|
+
|
|
91
|
+
super(owner, :opts => opts[:opts])
|
|
92
|
+
|
|
93
|
+
@textWidth = opts[:textWidth] if opts[:textWidth]
|
|
94
|
+
@diffType = opts[:diffType] if opts[:diffType]
|
|
95
|
+
@style = 2 if @diffType == DIFF_TYPE_NEW
|
|
96
|
+
#text_opts = LAYOUT_FILL_X|LAYOUT_FILL_Y|TEXT_FIXEDWRAP|TEXT_WORDWRAP|FRAME_SUNKEN
|
|
97
|
+
text_opts = LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN
|
|
98
|
+
|
|
99
|
+
hs_green = FXHiliteStyle.new
|
|
100
|
+
hs_green.normalForeColor = FXRGBA(255,255,255,255)
|
|
101
|
+
hs_green.normalBackColor = FXRGBA(0,255,0,1)
|
|
102
|
+
hs_green.style = FXText::STYLE_BOLD
|
|
103
|
+
|
|
104
|
+
hs_red = FXHiliteStyle.new
|
|
105
|
+
hs_red.normalForeColor = FXRGBA(255,255,255,255)
|
|
106
|
+
hs_red.normalBackColor = FXRGBA(255,0,0,1)
|
|
107
|
+
hs_red.style = FXText::STYLE_BOLD
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
frame = FXVerticalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK, :padding => 0)
|
|
111
|
+
data_frame = FXVerticalFrame.new(frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
|
|
112
|
+
@dataText = FXText.new(data_frame, :opts => text_opts)
|
|
113
|
+
@dataText.styled = true
|
|
114
|
+
@dataText.hiliteStyles = [ hs_red, hs_green]
|
|
115
|
+
@dataText.wrapColumns = @textWidth
|
|
116
|
+
@dataText.visibleColumns = @textWidth
|
|
117
|
+
@dataText.editable = false
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
class ChatDiffViewer < FXDialogBox
|
|
124
|
+
|
|
125
|
+
include Watobo::Gui::Icons
|
|
126
|
+
|
|
127
|
+
def onTableClick(sender,sel,item)
|
|
128
|
+
row = item.row
|
|
129
|
+
action = sender.getItem(row, 0).text.to_s
|
|
130
|
+
pos = sender.getItem(row, 1).text.to_i
|
|
131
|
+
|
|
132
|
+
sender.killSelection()
|
|
133
|
+
if action == "+" then
|
|
134
|
+
@diff_new.makeRowVisible(pos)
|
|
135
|
+
else
|
|
136
|
+
@diff_orig.makeRowVisible(pos)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def adjustLine(line)
|
|
141
|
+
result = []
|
|
142
|
+
line.strip!
|
|
143
|
+
if line.length > 0 then
|
|
144
|
+
pos = 0
|
|
145
|
+
while pos < line.length
|
|
146
|
+
result.push line[pos..pos+@max_line_length-1]
|
|
147
|
+
pos += @max_line_length
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
return result
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def updateBlocks(data_old, data_new, blocks, diffs)
|
|
154
|
+
ib = []
|
|
155
|
+
rb = []
|
|
156
|
+
context_lines = 3
|
|
157
|
+
file_length_difference = 0
|
|
158
|
+
|
|
159
|
+
diffs.each do |piece|
|
|
160
|
+
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, context_lines, file_length_difference)
|
|
161
|
+
hunk.blocks.each do |b|
|
|
162
|
+
ib.concat b.insert
|
|
163
|
+
rb.concat b.remove
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
blocks[:remove] = rb
|
|
167
|
+
blocks[:insert] = ib
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def normalizeData(data)
|
|
172
|
+
dummy = []
|
|
173
|
+
begin
|
|
174
|
+
unless data.headers.nil?
|
|
175
|
+
data.headers.each do |h|
|
|
176
|
+
dummy.concat adjustLine(h)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
dummy.push ""
|
|
180
|
+
end
|
|
181
|
+
unless data.body.nil?
|
|
182
|
+
data.body.split("\n").each do |l|
|
|
183
|
+
dummy.concat adjustLine(l)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
rescue => bang
|
|
187
|
+
puts bang
|
|
188
|
+
dummy = data
|
|
189
|
+
end
|
|
190
|
+
# puts dummy.join("\n")
|
|
191
|
+
#return dummy.join("\n")
|
|
192
|
+
return dummy
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def getInserts(data_old, data_new)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
return nil if diffs.empty?
|
|
200
|
+
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def showRequestDiff()
|
|
204
|
+
@diff_orig.showDiff(@normRequestOrig, @requestBlocks[:remove])
|
|
205
|
+
@diff_new.showDiff(@normRequestNew, @requestBlocks[:insert])
|
|
206
|
+
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def showResponseDiff()
|
|
210
|
+
@diff_orig.showDiff(@normResponseOrig, @responseBlocks[:remove])
|
|
211
|
+
@diff_new.showDiff(@normResponseNew, @responseBlocks[:insert])
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def initNavTable(table)
|
|
215
|
+
table.clearItems()
|
|
216
|
+
table.setTableSize(0, 3)
|
|
217
|
+
|
|
218
|
+
table.setColumnText( 0, "Type" )
|
|
219
|
+
table.setColumnText( 1, "Pos" )
|
|
220
|
+
table.setColumnText( 2, "Count" )
|
|
221
|
+
|
|
222
|
+
table.rowHeader.width = 0
|
|
223
|
+
table.setColumnWidth(0, 50)
|
|
224
|
+
table.setColumnWidth(1, 50)
|
|
225
|
+
table.setColumnWidth(2, 50)
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def updateNavTables()
|
|
229
|
+
req_collection = diffCollections(@normRequestOrig, @normRequestNew, @requestDiffs)
|
|
230
|
+
res_collection = diffCollections(@normResponseOrig, @normResponseNew, @responseDiffs)
|
|
231
|
+
initNavTable(@navRequestTable)
|
|
232
|
+
initNavTable(@navResponseTable)
|
|
233
|
+
|
|
234
|
+
req_collection.each do |action, pos, count|
|
|
235
|
+
lastRowIndex = @navRequestTable.getNumRows
|
|
236
|
+
@navRequestTable.appendRows(1)
|
|
237
|
+
|
|
238
|
+
@navRequestTable.setItemText(lastRowIndex, 0, action)
|
|
239
|
+
@navRequestTable.setItemText(lastRowIndex, 1, pos.to_s)
|
|
240
|
+
@navRequestTable.setItemText(lastRowIndex, 2, count.to_s)
|
|
241
|
+
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
res_collection.each do |action, pos, count|
|
|
245
|
+
lastRowIndex = @navResponseTable.getNumRows
|
|
246
|
+
@navResponseTable.appendRows(1)
|
|
247
|
+
|
|
248
|
+
@navResponseTable.setItemText(lastRowIndex, 0, action)
|
|
249
|
+
@navResponseTable.setItemText(lastRowIndex, 1, pos.to_s)
|
|
250
|
+
@navResponseTable.setItemText(lastRowIndex, 2, count.to_s)
|
|
251
|
+
#@navRequestTable.getItem(lastRowIndex, index).justify = FXTableItem::LEFT
|
|
252
|
+
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def diffCollections(data_old, data_new, diffs)
|
|
257
|
+
file_length_difference = 0
|
|
258
|
+
context_lines = 3
|
|
259
|
+
raw_chunks = []
|
|
260
|
+
collections = []
|
|
261
|
+
return collections if diffs.empty?
|
|
262
|
+
oldhunk = hunk = nil
|
|
263
|
+
file_length_difference = 0
|
|
264
|
+
diffs.each do |piece|
|
|
265
|
+
begin
|
|
266
|
+
hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, context_lines, file_length_difference)
|
|
267
|
+
file_length_difference = hunk.file_length_difference
|
|
268
|
+
next unless oldhunk
|
|
269
|
+
if (context_lines > 0 ) and hunk.overlaps?(oldhunk)
|
|
270
|
+
hunk.unshift(oldhunk)
|
|
271
|
+
else
|
|
272
|
+
raw_chunks.concat oldhunk.blocks
|
|
273
|
+
end
|
|
274
|
+
ensure
|
|
275
|
+
oldhunk = hunk
|
|
276
|
+
end
|
|
277
|
+
end
|
|
278
|
+
raw_chunks.concat oldhunk.blocks
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
raw_chunks.each do |block|
|
|
282
|
+
begin
|
|
283
|
+
|
|
284
|
+
last_pos = -1
|
|
285
|
+
last_action = '+'
|
|
286
|
+
count = 0
|
|
287
|
+
block.insert.each do |b|
|
|
288
|
+
if last_pos < 0 then
|
|
289
|
+
last_pos = b.position
|
|
290
|
+
count = 0
|
|
291
|
+
elsif b.position-1 == (last_pos + count) then
|
|
292
|
+
count +=1
|
|
293
|
+
else
|
|
294
|
+
collections.push [last_action, last_pos, count+1 ]
|
|
295
|
+
last_pos = b.position
|
|
296
|
+
count = 0
|
|
297
|
+
end
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
collections.push [ last_action, last_pos, count+1 ] if block.insert.length > 0
|
|
301
|
+
|
|
302
|
+
rescue => bang
|
|
303
|
+
puts bang
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
raw_chunks.each do |block|
|
|
308
|
+
begin
|
|
309
|
+
|
|
310
|
+
last_pos = -1
|
|
311
|
+
last_action = '-'
|
|
312
|
+
count = 0
|
|
313
|
+
|
|
314
|
+
block.remove.each do |b|
|
|
315
|
+
if last_pos < 0 then
|
|
316
|
+
last_pos = b.position
|
|
317
|
+
count = 0
|
|
318
|
+
elsif b.position-1 == (last_pos + count) then
|
|
319
|
+
count +=1
|
|
320
|
+
else
|
|
321
|
+
collections.push [last_action, last_pos, count+1 ]
|
|
322
|
+
last_pos = b.position
|
|
323
|
+
count = 0
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
collections.push [ last_action, last_pos, count+1 ] if block.remove.length > 0
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
rescue => bang
|
|
331
|
+
puts bang
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
return collections.sort_by{ |e| e[1]}
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def initialize(owner, project, chat_orig, chat_new)
|
|
340
|
+
# Invoke base class initialize function first
|
|
341
|
+
super(owner, "Chat Differ", :opts => DECOR_ALL,:width=>800, :height=>600)
|
|
342
|
+
self.icon = ICON_DIFFER
|
|
343
|
+
@project = project
|
|
344
|
+
@chat_orig = chat_orig
|
|
345
|
+
@chat_new = chat_new
|
|
346
|
+
@max_line_length = 80
|
|
347
|
+
|
|
348
|
+
@requestBlocks = Hash.new
|
|
349
|
+
@responseBlocks = Hash.new
|
|
350
|
+
|
|
351
|
+
main = FXHorizontalFrame.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
|
|
352
|
+
left = FXVerticalFrame.new(main, :opts => LAYOUT_FILL_Y|LAYOUT_FIX_WIDTH, :width => 200, :padding => 0)
|
|
353
|
+
|
|
354
|
+
@tabBook = FXTabBook.new(left, nil, 0, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)
|
|
355
|
+
res_tab = FXTabItem.new(@tabBook, "Response", nil)
|
|
356
|
+
res_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK)
|
|
357
|
+
sunken = FXVerticalFrame.new(res_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
|
|
358
|
+
@navResponseTable = FXTable.new(sunken, :opts => TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2)
|
|
359
|
+
@navResponseTable.connect(SEL_COMMAND, method(:onTableClick))
|
|
360
|
+
|
|
361
|
+
req_tab = FXTabItem.new(@tabBook, "Request", nil)
|
|
362
|
+
req_frame = FXVerticalFrame.new(@tabBook, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0)
|
|
363
|
+
sunken = FXVerticalFrame.new(req_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_THICK, :padding => 0)
|
|
364
|
+
@navRequestTable = FXTable.new(sunken, :opts => FRAME_SUNKEN|TABLE_COL_SIZABLE|TABLE_ROW_SIZABLE|LAYOUT_FILL_X|LAYOUT_FILL_Y|TABLE_READONLY|LAYOUT_SIDE_TOP, :padding => 2)
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
orig_frame = FXVerticalFrame.new(main, :opts => LAYOUT_FILL_Y|LAYOUT_FILL_X, :padding => 0)
|
|
368
|
+
frame = FXVerticalFrame.new(orig_frame, :opts => LAYOUT_FILL_X)
|
|
369
|
+
FXLabel.new(frame, "Original")
|
|
370
|
+
|
|
371
|
+
@diff_orig = ChatDiffFrame.new(orig_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :diffType => DIFF_TYPE_ORIG)
|
|
372
|
+
|
|
373
|
+
new_frame = FXVerticalFrame.new(main, :opts => LAYOUT_FILL_Y|LAYOUT_FILL_X, :padding => 0)
|
|
374
|
+
frame = FXVerticalFrame.new(new_frame, :opts => LAYOUT_FILL_X)
|
|
375
|
+
FXLabel.new(frame, "New")
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
@diff_new = ChatDiffFrame.new(new_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :diffType => DIFF_TYPE_NEW)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
@tabBook.connect(SEL_COMMAND) {
|
|
383
|
+
if @tabBook.current == 0 then
|
|
384
|
+
showResponseDiff()
|
|
385
|
+
else
|
|
386
|
+
showRequestDiff()
|
|
387
|
+
end
|
|
388
|
+
}
|
|
389
|
+
# normalize data before processing
|
|
390
|
+
# * remove empty lines, binary data
|
|
391
|
+
# * wrap lines after @max_line_length
|
|
392
|
+
@normRequestOrig = normalizeData(chat_orig.request)
|
|
393
|
+
@normResponseOrig = normalizeData(chat_orig.response)
|
|
394
|
+
|
|
395
|
+
@normRequestNew = normalizeData(chat_new.request)
|
|
396
|
+
@normResponseNew = normalizeData(chat_new.response)
|
|
397
|
+
|
|
398
|
+
# diff normalized data
|
|
399
|
+
@requestDiffs = Diff::LCS.diff( @normRequestOrig, @normRequestNew )
|
|
400
|
+
@responseDiffs = Diff::LCS.diff( @normResponseOrig, @normResponseNew )
|
|
401
|
+
|
|
402
|
+
# set diff blocks
|
|
403
|
+
updateBlocks(@normRequestOrig, @normRequestNew, @requestBlocks, @requestDiffs)
|
|
404
|
+
updateBlocks(@normResponseOrig, @normResponseNew, @responseBlocks, @responseDiffs)
|
|
405
|
+
|
|
406
|
+
updateNavTables()
|
|
407
|
+
|
|
408
|
+
showResponseDiff()
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
end
|
|
415
|
+
end
|