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