1 | package com.jsql.view.swing.panel.preferences; | |
2 | ||
3 | import com.jsql.util.tampering.TamperingType; | |
4 | import com.jsql.view.swing.panel.PanelPreferences; | |
5 | import com.jsql.view.swing.panel.preferences.listener.TamperingMouseAdapter; | |
6 | import com.jsql.view.swing.popupmenu.JPopupMenuComponent; | |
7 | import com.jsql.view.swing.text.SyntaxTextArea; | |
8 | import com.jsql.view.swing.text.listener.DocumentListenerEditing; | |
9 | import com.jsql.view.swing.util.MediatorHelper; | |
10 | import com.jsql.view.swing.util.UiUtil; | |
11 | import org.apache.commons.lang3.StringUtils; | |
12 | import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; | |
13 | import org.fife.ui.rsyntaxtextarea.SyntaxConstants; | |
14 | import org.fife.ui.rtextarea.RTextScrollPane; | |
15 | ||
16 | import javax.swing.*; | |
17 | import java.util.AbstractMap.SimpleEntry; | |
18 | import java.util.Arrays; | |
19 | import java.util.stream.Stream; | |
20 | ||
21 | public class PanelTampering extends JPanel { | |
22 | ||
23 | // no preferences init | |
24 | private final JCheckBox checkboxIsTamperingBase64 = new JCheckBox(TamperingType.BASE64.instance().getDescription()); | |
25 | private final JCheckBox checkboxIsTamperingVersionComment = new JCheckBox(TamperingType.VERSIONED_COMMENT_TO_METHOD_SIGNATURE.instance().getDescription()); | |
26 | private final JCheckBox checkboxIsTamperingFunctionComment = new JCheckBox(TamperingType.COMMENT_TO_METHOD_SIGNATURE.instance().getDescription()); | |
27 | private final JCheckBox checkboxIsTamperingEqualToLike = new JCheckBox(TamperingType.EQUAL_TO_LIKE.instance().getDescription()); | |
28 | private final JCheckBox checkboxIsTamperingRandomCase = new JCheckBox(TamperingType.RANDOM_CASE.instance().getDescription()); | |
29 | private final JCheckBox checkboxIsTamperingEval = new JCheckBox("Enable user tamper script:"); | |
30 | private final JCheckBox checkboxIsTamperingHexToChar = new JCheckBox(TamperingType.HEX_TO_CHAR.instance().getDescription()); | |
31 | private final JCheckBox checkboxIsTamperingStringToChar = new JCheckBox(TamperingType.STRING_TO_CHAR.instance().getDescription()); | |
32 | private final JCheckBox checkboxIsTamperingQuoteToUtf8 = new JCheckBox(TamperingType.QUOTE_TO_UTF8.instance().getDescription()); | |
33 | private final JRadioButton radioIsTamperingSpaceToMultilineComment = new JRadioButton(TamperingType.SPACE_TO_MULTILINE_COMMENT.instance().getDescription()); | |
34 | private final JRadioButton radioIsTamperingSpaceToDashComment = new JRadioButton(TamperingType.SPACE_TO_DASH_COMMENT.instance().getDescription()); | |
35 | private final JRadioButton radioIsTamperingSpaceToSharpComment = new JRadioButton(TamperingType.SPACE_TO_SHARP_COMMENT.instance().getDescription()); | |
36 | ||
37 | private static final RSyntaxTextArea textPaneEval = new SyntaxTextArea("Click on a tamper to paste source and edit custom script"); | |
38 | ||
39 | public PanelTampering(PanelPreferences panelPreferences) { | |
40 |
1
1. <init> : removed call to javax/swing/JCheckBox::setToolTipText → NO_COVERAGE |
this.checkboxIsTamperingEval.setToolTipText("Custom tamper in JavaScript and Java, e.g. sql.replace(/\\+/gm,'/**/')"); |
41 | ||
42 |
1
1. <init> : removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::setText → NO_COVERAGE |
PanelTampering.textPaneEval.setText(StringUtils.EMPTY); |
43 |
1
1. <init> : removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::setSyntaxEditingStyle → NO_COVERAGE |
PanelTampering.textPaneEval.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT); |
44 |
1
1. <init> : removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::setPopupMenu → NO_COVERAGE |
PanelTampering.textPaneEval.setPopupMenu(new JPopupMenuComponent(PanelTampering.textPaneEval)); |
45 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelTampering::applyTheme → NO_COVERAGE |
PanelTampering.applyTheme(); |
46 | ||
47 | var textAreaIsTamperingEval = new RTextScrollPane(PanelTampering.textPaneEval, false); | |
48 | ||
49 |
1
1. <init> : removed call to javax/swing/text/Document::addDocumentListener → NO_COVERAGE |
PanelTampering.textPaneEval.getDocument().addDocumentListener(new DocumentListenerEditing() { |
50 | @Override | |
51 | public void process() { | |
52 |
1
1. process : removed call to com/jsql/util/TamperingUtil::setCustomTamper → NO_COVERAGE |
MediatorHelper.model().getMediatorUtils().getTamperingUtil().setCustomTamper(PanelTampering.textPaneEval.getText()); |
53 | } | |
54 | }); | |
55 |
1
1. <init> : removed call to org/fife/ui/rsyntaxtextarea/RSyntaxTextArea::setText → NO_COVERAGE |
PanelTampering.textPaneEval.setText(MediatorHelper.model().getMediatorUtils().getTamperingUtil().getCustomTamper()); |
56 |
1
1. <init> : removed call to javax/swing/JCheckBox::addActionListener → NO_COVERAGE |
this.checkboxIsTamperingEval.addActionListener(panelPreferences.getActionListenerSave()); |
57 | ||
58 | Stream.of( | |
59 | new SimpleEntry<>(this.checkboxIsTamperingBase64, TamperingType.BASE64), | |
60 | new SimpleEntry<>(this.checkboxIsTamperingFunctionComment, TamperingType.COMMENT_TO_METHOD_SIGNATURE), | |
61 | new SimpleEntry<>(this.checkboxIsTamperingVersionComment, TamperingType.VERSIONED_COMMENT_TO_METHOD_SIGNATURE), | |
62 | new SimpleEntry<>(this.checkboxIsTamperingEqualToLike, TamperingType.EQUAL_TO_LIKE), | |
63 | new SimpleEntry<>(this.checkboxIsTamperingRandomCase, TamperingType.RANDOM_CASE), | |
64 | new SimpleEntry<>(this.checkboxIsTamperingHexToChar, TamperingType.HEX_TO_CHAR), | |
65 | new SimpleEntry<>(this.checkboxIsTamperingStringToChar, TamperingType.STRING_TO_CHAR), | |
66 | new SimpleEntry<>(this.checkboxIsTamperingQuoteToUtf8, TamperingType.QUOTE_TO_UTF8), | |
67 | new SimpleEntry<>(this.radioIsTamperingSpaceToMultilineComment, TamperingType.SPACE_TO_MULTILINE_COMMENT), | |
68 | new SimpleEntry<>(this.radioIsTamperingSpaceToDashComment, TamperingType.SPACE_TO_DASH_COMMENT), | |
69 | new SimpleEntry<>(this.radioIsTamperingSpaceToSharpComment, TamperingType.SPACE_TO_SHARP_COMMENT) | |
70 | ) | |
71 |
1
1. <init> : removed call to java/util/stream/Stream::forEach → NO_COVERAGE |
.forEach(entry -> { |
72 |
1
1. lambda$new$0 : removed call to javax/swing/JToggleButton::setToolTipText → NO_COVERAGE |
entry.getKey().setToolTipText(entry.getValue().instance().getTooltip()); |
73 |
1
1. lambda$new$0 : removed call to javax/swing/JToggleButton::addMouseListener → NO_COVERAGE |
entry.getKey().addMouseListener(new TamperingMouseAdapter(entry.getValue(), PanelTampering.textPaneEval)); |
74 |
1
1. lambda$new$0 : removed call to javax/swing/JToggleButton::addActionListener → NO_COVERAGE |
entry.getKey().addActionListener(panelPreferences.getActionListenerSave()); |
75 | }); | |
76 | ||
77 | var groupSpaceToComment = new ButtonGroup() { | |
78 | @Override | |
79 | public void setSelected(ButtonModel buttonModel, boolean b) { | |
80 | // Click a 2nd time to uncheck | |
81 |
1
1. setSelected : negated conditional → NO_COVERAGE |
if (!b) { |
82 |
1
1. setSelected : removed call to com/jsql/view/swing/panel/preferences/PanelTampering$2::clearSelection → NO_COVERAGE |
this.clearSelection(); |
83 | } else { | |
84 |
1
1. setSelected : removed call to javax/swing/ButtonGroup::setSelected → NO_COVERAGE |
super.setSelected(buttonModel, true); |
85 | } | |
86 | } | |
87 | }; | |
88 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelTampering$2::add → NO_COVERAGE |
groupSpaceToComment.add(this.radioIsTamperingSpaceToDashComment); |
89 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelTampering$2::add → NO_COVERAGE |
groupSpaceToComment.add(this.radioIsTamperingSpaceToMultilineComment); |
90 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelTampering$2::add → NO_COVERAGE |
groupSpaceToComment.add(this.radioIsTamperingSpaceToSharpComment); |
91 | ||
92 | var labelCommonConversion = new JLabel("<html><b>Common tamper</b></html>"); | |
93 | var labelSpaceTamper = new JLabel("<html><br /><b>Space tamper (click again to uncheck)</b></html>"); | |
94 | var labelCustomConversion = new JLabel("<html><br /><b>Custom tamper (hover tamper to show implementation, click to paste)</b></html>"); | |
95 |
2
1. lambda$new$1 : removed call to javax/swing/JLabel::setBorder → NO_COVERAGE 2. <init> : removed call to java/util/List::forEach → NO_COVERAGE |
Arrays.asList(labelCommonConversion, labelSpaceTamper, labelCustomConversion).forEach(label -> label.setBorder(PanelGeneral.MARGIN)); |
96 | ||
97 | var groupLayout = new GroupLayout(this); | |
98 |
1
1. <init> : removed call to com/jsql/view/swing/panel/preferences/PanelTampering::setLayout → NO_COVERAGE |
this.setLayout(groupLayout); |
99 | | |
100 |
1
1. <init> : removed call to javax/swing/GroupLayout::setHorizontalGroup → NO_COVERAGE |
groupLayout.setHorizontalGroup( |
101 | groupLayout | |
102 | .createSequentialGroup() | |
103 | .addGroup( | |
104 | groupLayout | |
105 | .createParallelGroup(GroupLayout.Alignment.LEADING) | |
106 | .addComponent(labelCommonConversion) | |
107 | .addComponent(this.checkboxIsTamperingBase64) | |
108 | .addComponent(this.checkboxIsTamperingFunctionComment) | |
109 | .addComponent(this.checkboxIsTamperingVersionComment) | |
110 | .addComponent(this.checkboxIsTamperingEqualToLike) | |
111 | .addComponent(this.checkboxIsTamperingRandomCase) | |
112 | .addComponent(this.checkboxIsTamperingStringToChar) | |
113 | .addComponent(this.checkboxIsTamperingHexToChar) | |
114 | .addComponent(this.checkboxIsTamperingQuoteToUtf8) | |
115 | .addComponent(labelSpaceTamper) | |
116 | .addComponent(this.radioIsTamperingSpaceToMultilineComment) | |
117 | .addComponent(this.radioIsTamperingSpaceToDashComment) | |
118 | .addComponent(this.radioIsTamperingSpaceToSharpComment) | |
119 | .addComponent(labelCustomConversion) | |
120 | .addComponent(this.checkboxIsTamperingEval) | |
121 | .addComponent(textAreaIsTamperingEval) | |
122 | ) | |
123 | ); | |
124 | | |
125 |
1
1. <init> : removed call to javax/swing/GroupLayout::setVerticalGroup → NO_COVERAGE |
groupLayout.setVerticalGroup( |
126 | groupLayout | |
127 | .createSequentialGroup() | |
128 | .addGroup( | |
129 | groupLayout | |
130 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
131 | .addComponent(labelCommonConversion) | |
132 | ) | |
133 | .addGroup( | |
134 | groupLayout | |
135 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
136 | .addComponent(this.checkboxIsTamperingBase64) | |
137 | ) | |
138 | .addGroup( | |
139 | groupLayout | |
140 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
141 | .addComponent(this.checkboxIsTamperingFunctionComment) | |
142 | ) | |
143 | .addGroup( | |
144 | groupLayout | |
145 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
146 | .addComponent(this.checkboxIsTamperingVersionComment) | |
147 | ) | |
148 | .addGroup( | |
149 | groupLayout | |
150 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
151 | .addComponent(this.checkboxIsTamperingEqualToLike) | |
152 | ) | |
153 | .addGroup( | |
154 | groupLayout | |
155 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
156 | .addComponent(this.checkboxIsTamperingRandomCase) | |
157 | ) | |
158 | .addGroup( | |
159 | groupLayout | |
160 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
161 | .addComponent(this.checkboxIsTamperingStringToChar) | |
162 | ) | |
163 | .addGroup( | |
164 | groupLayout | |
165 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
166 | .addComponent(this.checkboxIsTamperingHexToChar) | |
167 | ) | |
168 | .addGroup( | |
169 | groupLayout | |
170 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
171 | .addComponent(this.checkboxIsTamperingQuoteToUtf8) | |
172 | ) | |
173 | .addGroup( | |
174 | groupLayout | |
175 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
176 | .addComponent(labelSpaceTamper) | |
177 | ) | |
178 | .addGroup( | |
179 | groupLayout | |
180 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
181 | .addComponent(this.radioIsTamperingSpaceToMultilineComment) | |
182 | ) | |
183 | .addGroup( | |
184 | groupLayout | |
185 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
186 | .addComponent(this.radioIsTamperingSpaceToDashComment) | |
187 | ) | |
188 | .addGroup( | |
189 | groupLayout | |
190 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
191 | .addComponent(this.radioIsTamperingSpaceToSharpComment) | |
192 | ) | |
193 | .addGroup( | |
194 | groupLayout | |
195 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
196 | .addComponent(labelCustomConversion) | |
197 | ) | |
198 | .addGroup( | |
199 | groupLayout | |
200 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
201 | .addComponent(this.checkboxIsTamperingEval) | |
202 | ) | |
203 | .addGroup( | |
204 | groupLayout | |
205 | .createParallelGroup(GroupLayout.Alignment.BASELINE) | |
206 | .addComponent(textAreaIsTamperingEval) | |
207 | ) | |
208 | ); | |
209 | } | |
210 | ||
211 | public static void applyTheme() { | |
212 |
1
1. applyTheme : removed call to com/jsql/view/swing/util/UiUtil::applySyntaxTheme → NO_COVERAGE |
UiUtil.applySyntaxTheme(PanelTampering.textPaneEval); |
213 | } | |
214 | | |
215 | | |
216 | // Getter and setter | |
217 | ||
218 | public JCheckBox getCheckboxIsTamperingBase64() { | |
219 |
1
1. getCheckboxIsTamperingBase64 : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingBase64 → NO_COVERAGE |
return this.checkboxIsTamperingBase64; |
220 | } | |
221 | | |
222 | public JCheckBox getCheckboxIsTamperingEqualToLike() { | |
223 |
1
1. getCheckboxIsTamperingEqualToLike : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingEqualToLike → NO_COVERAGE |
return this.checkboxIsTamperingEqualToLike; |
224 | } | |
225 | | |
226 | public JCheckBox getCheckboxIsTamperingFunctionComment() { | |
227 |
1
1. getCheckboxIsTamperingFunctionComment : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingFunctionComment → NO_COVERAGE |
return this.checkboxIsTamperingFunctionComment; |
228 | } | |
229 | | |
230 | public JCheckBox getCheckboxIsTamperingVersionComment() { | |
231 |
1
1. getCheckboxIsTamperingVersionComment : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingVersionComment → NO_COVERAGE |
return this.checkboxIsTamperingVersionComment; |
232 | } | |
233 | | |
234 | public JCheckBox getCheckboxIsTamperingRandomCase() { | |
235 |
1
1. getCheckboxIsTamperingRandomCase : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingRandomCase → NO_COVERAGE |
return this.checkboxIsTamperingRandomCase; |
236 | } | |
237 | | |
238 | public JCheckBox getCheckboxIsTamperingEval() { | |
239 |
1
1. getCheckboxIsTamperingEval : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingEval → NO_COVERAGE |
return this.checkboxIsTamperingEval; |
240 | } | |
241 | | |
242 | public JRadioButton getRadioIsTamperingSpaceToDashComment() { | |
243 |
1
1. getRadioIsTamperingSpaceToDashComment : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getRadioIsTamperingSpaceToDashComment → NO_COVERAGE |
return this.radioIsTamperingSpaceToDashComment; |
244 | } | |
245 | | |
246 | public JRadioButton getRadioIsTamperingSpaceToMultilineComment() { | |
247 |
1
1. getRadioIsTamperingSpaceToMultilineComment : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getRadioIsTamperingSpaceToMultilineComment → NO_COVERAGE |
return this.radioIsTamperingSpaceToMultilineComment; |
248 | } | |
249 | | |
250 | public JRadioButton getRadioIsTamperingSpaceToSharpComment() { | |
251 |
1
1. getRadioIsTamperingSpaceToSharpComment : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getRadioIsTamperingSpaceToSharpComment → NO_COVERAGE |
return this.radioIsTamperingSpaceToSharpComment; |
252 | } | |
253 | | |
254 | public JCheckBox getCheckboxIsTamperingHexToChar() { | |
255 |
1
1. getCheckboxIsTamperingHexToChar : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingHexToChar → NO_COVERAGE |
return this.checkboxIsTamperingHexToChar; |
256 | } | |
257 | | |
258 | public JCheckBox getCheckboxIsTamperingQuoteToUtf8() { | |
259 |
1
1. getCheckboxIsTamperingQuoteToUtf8 : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingQuoteToUtf8 → NO_COVERAGE |
return this.checkboxIsTamperingQuoteToUtf8; |
260 | } | |
261 | ||
262 | public JCheckBox getCheckboxIsTamperingStringToChar() { | |
263 |
1
1. getCheckboxIsTamperingStringToChar : replaced return value with null for com/jsql/view/swing/panel/preferences/PanelTampering::getCheckboxIsTamperingStringToChar → NO_COVERAGE |
return this.checkboxIsTamperingStringToChar; |
264 | } | |
265 | } | |
Mutations | ||
40 |
1.1 |
|
42 |
1.1 |
|
43 |
1.1 |
|
44 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 |
|
52 |
1.1 |
|
55 |
1.1 |
|
56 |
1.1 |
|
71 |
1.1 |
|
72 |
1.1 |
|
73 |
1.1 |
|
74 |
1.1 |
|
81 |
1.1 |
|
82 |
1.1 |
|
84 |
1.1 |
|
88 |
1.1 |
|
89 |
1.1 |
|
90 |
1.1 |
|
95 |
1.1 2.2 |
|
98 |
1.1 |
|
100 |
1.1 |
|
125 |
1.1 |
|
212 |
1.1 |
|
219 |
1.1 |
|
223 |
1.1 |
|
227 |
1.1 |
|
231 |
1.1 |
|
235 |
1.1 |
|
239 |
1.1 |
|
243 |
1.1 |
|
247 |
1.1 |
|
251 |
1.1 |
|
255 |
1.1 |
|
259 |
1.1 |
|
263 |
1.1 |