VendorYaml.java

1
package com.jsql.model.injection.vendor.model;
2
3
import com.jsql.model.InjectionModel;
4
import com.jsql.model.bean.database.Database;
5
import com.jsql.model.bean.database.Table;
6
import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator;
7
import com.jsql.model.injection.vendor.model.yaml.Method;
8
import com.jsql.model.injection.vendor.model.yaml.ModelYaml;
9
import com.jsql.util.LogLevelUtil;
10
import com.jsql.util.StringUtil;
11
import org.apache.commons.codec.binary.Hex;
12
import org.apache.commons.lang3.RandomStringUtils;
13
import org.apache.commons.lang3.StringUtils;
14
import org.apache.logging.log4j.LogManager;
15
import org.apache.logging.log4j.Logger;
16
import org.yaml.snakeyaml.Yaml;
17
18
import java.net.URLEncoder;
19
import java.nio.charset.StandardCharsets;
20
import java.util.ArrayList;
21
import java.util.Collections;
22
import java.util.List;
23
import java.util.regex.Pattern;
24
25
import static com.jsql.model.accessible.DataAccess.*;
26
27
public class VendorYaml implements AbstractVendor {
28
    
29
    /**
30
     * Log4j logger sent to view.
31
     */
32
    private static final Logger LOGGER = LogManager.getRootLogger();
33
34
    /**
35
     * SQL characters marking the end of the result of an injection.
36
     * Process stops when this schema is encountered:
37
     * <pre>SqLix01x03x03x07
38
     */
39
    public static final String LEAD_HEX = "0x53714c69";
40
    public static final String LEAD_PIPE = "Sq'||'Li";
41
    public static final String TRAIL_SQL = "%01%03%03%07";
42
    public static final String TRAIL_HEX = "0x01030307";
43
44
    /**
45
     * SQL character used between each table cells.
46
     * Expected schema of multiple table cells :
47
     * <pre>
48
     * %04[table cell]%05[number of occurrences]%04%06%04[table cell]%05[number of occurrences]%04
49
     */
50
    public static final String SEPARATOR_CELL_SQL = "%06";
51
    public static final String SEPARATOR_CELL_HEX = "0x06";
52
53
    public static final String ENCLOSE_VALUE_HEX = "0x04";
54
55
    /**
56
     * SQL character used between the table cell and the number of occurrence of the cell text.
57
     * Expected schema of a table cell data is
58
     * <pre>%04[table cell]%05[number of occurrences]%04
59
     */
60
    public static final String SEPARATOR_QTE_SQL = "%05";
61
    public static final String SEPARATOR_QTE_HEX = "0x05";
62
63
    /**
64
     * SQL character enclosing a table cell returned by injection.
65
     * It allows to detect the correct end of a table cell data during parsing.
66
     * Expected schema of a table cell data is
67
     * <pre>%04[table cell]%05[number of occurrences]%04
68
     */
69
    public static final String ENCLOSE_VALUE_SQL = "%04";
70
71
    public static final String CALIBRATOR_SQL = "a";
72
    public static final String CALIBRATOR_HEX = "0x61";
73
    
74
    public static final String FORMAT_INDEX = "1337%s7331";
75
76
    private static final String BINARY_MODE = "${binary.mode}";
77
    public static final String LIMIT = "${limit}";
78
    private static final String LIMIT_VALUE = "${limit.value}";
79
    private static final String RESULT_RANGE = "${result_range}";
80
    private static final String INDICE_UNIQUE = "${indice_unique}";
81
    private static final String CALIBRATOR = "${calibrator}";
82
    private static final String INDICES = "${indices}";
83
    public static final String INDICE = "${indice}";
84
    public static final String WINDOW_CHAR = "${window.char}";
85
    public static final String BLOCK_MULTIBIT = "${multibit.block}";
86
    public static final String WINDOW = "${window}";
87
    public static final String CAPACITY = "${capacity}";
88
    public static final String DEFAULT_CAPACITY = "65565";
89
    private static final String SLEEP_TIME = "${sleep_time}";
90
    private static final String BIT = "${bit}";
91
    private static final String MID = "${mid}";
92
    public static final String INJECTION = "${injection}";
93
    public static final String TEST = "${test}";
94
    public static final String FILEPATH_HEX = "${filepath.hex}";
95
    private static final String FIELDS = "${fields}";
96
    private static final String FIELD = "${field.value}";
97
    private static final String TABLE = "${table}";
98
    private static final String DATABASE = "${database}";
99
    private static final String TABLE_HEX = "${table.hex}";
100
    private static final String DATABASE_HEX = "${database.hex}";
101
    
102
    private final ModelYaml modelYaml;
103
    private final InjectionModel injectionModel;
104
    
105
    public VendorYaml(String fileYaml, InjectionModel injectionModel) {
106
        this.injectionModel = injectionModel;
107
        var yaml = new Yaml();
108
        this.modelYaml = yaml.loadAs(
109
            VendorYaml.class.getClassLoader().getResourceAsStream("vendor/"+ fileYaml),
110
            ModelYaml.class
111
        );
112
    }
113
114
    @Override
115
    public String sqlDatabases() {
116
        String sqlQuery = this.modelYaml.getResource().getSchema().getDatabase();
117
        
118 1 1. sqlDatabases : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) {
119 1 1. sqlDatabases : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getDatabase())) {
120
                sqlQuery = this.modelYaml.getResource().getDios().getDatabase();
121
            } else {
122
                LOGGER.log(
123
                    LogLevelUtil.CONSOLE_INFORM,
124
                    "Strategy [Dios] activated but database query is undefined for [{}], fallback to default",
125 1 1. lambda$sqlDatabases$0 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$0 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
126
                );
127
            }
128 1 1. sqlDatabases : negated conditional → NO_COVERAGE
        } else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) {
129 1 1. sqlDatabases : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getDatabase())) {
130
                sqlQuery = this.modelYaml.getResource().getZip().getDatabase();
131
            } else {
132
                LOGGER.log(
133
                    LogLevelUtil.CONSOLE_INFORM,
134
                    "Strategy [Zip] activated but database query is undefined for [{}], fallback to default",
135 1 1. lambda$sqlDatabases$1 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$1 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
136
                );
137
            }
138
        }
139 1 1. sqlDatabases : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlDatabases → NO_COVERAGE
        return sqlQuery;
140
    }
141
    
142
    @Override
143
    public String sqlTables(Database database) {
144
        String sqlQuery = this.modelYaml.getResource().getSchema().getTable();
145
        
146 1 1. sqlTables : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) {
147 1 1. sqlTables : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getTable())) {
148
                sqlQuery = this.modelYaml.getResource().getDios().getTable();
149
            } else {
150
                LOGGER.log(
151
                    LogLevelUtil.CONSOLE_INFORM,
152
                    "Strategy [Dios] activated but table query is undefined for [{}], fallback to default",
153 1 1. lambda$sqlTables$2 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$2 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
154
                );
155
            }
156 1 1. sqlTables : negated conditional → NO_COVERAGE
        } else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) {
157 1 1. sqlTables : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getTable())) {
158
                sqlQuery = this.modelYaml.getResource().getZip().getTable();
159
            } else {
160
                LOGGER.log(
161
                    LogLevelUtil.CONSOLE_INFORM,
162
                    "Strategy [Zip] activated but table query is undefined for [{}], fallback to default",
163 1 1. lambda$sqlTables$3 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$3 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
164
                );
165
            }
166
        }
167
        
168
        String databaseUtf8 = Hex.encodeHexString(database.toString().getBytes(StandardCharsets.UTF_8));
169 1 1. sqlTables : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTables → NO_COVERAGE
        return sqlQuery
170
            .replace(VendorYaml.DATABASE_HEX, databaseUtf8)
171
            .replace(VendorYaml.DATABASE, database.toString());
172
    }
173
174
    @Override
175
    public String sqlColumns(Table table) {
176
        String sqlQuery = this.modelYaml.getResource().getSchema().getColumn();
177
        
178 1 1. sqlColumns : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) {
179 1 1. sqlColumns : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getColumn())) {
180
                sqlQuery = this.modelYaml.getResource().getDios().getColumn();
181
            } else {
182
                LOGGER.log(
183
                    LogLevelUtil.CONSOLE_INFORM,
184
                    "Strategy [Dios] activated but column query is undefined for [{}], fallback to default",
185 1 1. lambda$sqlColumns$4 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$4 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
186
                );
187
            }
188 1 1. sqlColumns : negated conditional → NO_COVERAGE
        } else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) {
189 1 1. sqlColumns : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getColumn())) {
190
                sqlQuery = this.modelYaml.getResource().getZip().getColumn();
191
            } else {
192
                LOGGER.log(
193
                    LogLevelUtil.CONSOLE_INFORM,
194
                    "Strategy [Zip] activated but column query is undefined for [{}], fallback to default",
195 1 1. lambda$sqlColumns$5 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$5 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
196
                );
197
            }
198
        }
199
        
200
        String databaseUtf8 = Hex.encodeHexString(table.getParent().toString().getBytes(StandardCharsets.UTF_8));
201
        String tableUtf8 = Hex.encodeHexString(table.toString().getBytes(StandardCharsets.UTF_8));
202
        
203 1 1. sqlColumns : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlColumns → NO_COVERAGE
        return sqlQuery
204
            .replace(VendorYaml.DATABASE_HEX, databaseUtf8)
205
            .replace(VendorYaml.TABLE_HEX, tableUtf8)
206
            .replace(VendorYaml.DATABASE, table.getParent().toString())
207
            .replace(VendorYaml.TABLE, table.toString());
208
    }
209
210
    @Override
211
    public String sqlRows(String[] namesColumns, Database database, Table table) {
212
        String sqlField = this.modelYaml.getResource().getSchema().getRow().getFields().getField();
213
        String sqlConcatFields = this.modelYaml.getResource().getSchema().getRow().getFields().getConcat();
214
        String sqlQuery = this.modelYaml.getResource().getSchema().getRow().getQuery();
215
        
216 1 1. sqlRows : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isDiosStrategy()) {
217 1 1. sqlRows : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getDios().getDatabase())) {
218
                sqlField = this.modelYaml.getResource().getDios().getRow().getFields().getField();
219
                sqlConcatFields = this.modelYaml.getResource().getDios().getRow().getFields().getConcat();
220
                sqlQuery = this.modelYaml.getResource().getDios().getRow().getQuery();
221
            } else {
222
                LOGGER.log(
223
                    LogLevelUtil.CONSOLE_INFORM,
224
                    "Strategy [Dios] activated but row query is undefined for [{}], fallback to default",
225 1 1. lambda$sqlRows$6 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$6 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
226
                );
227
            }
228 1 1. sqlRows : negated conditional → NO_COVERAGE
        } else if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isZipStrategy()) {
229 1 1. sqlRows : negated conditional → NO_COVERAGE
            if (StringUtils.isNotBlank(this.modelYaml.getResource().getZip().getDatabase())) {
230
                sqlField = this.modelYaml.getResource().getZip().getRow().getFields().getField();
231
                sqlConcatFields = this.modelYaml.getResource().getZip().getRow().getFields().getConcat();
232
                sqlQuery = this.modelYaml.getResource().getZip().getRow().getQuery();
233
            } else {
234
                LOGGER.log(
235
                    LogLevelUtil.CONSOLE_INFORM,
236
                    "Strategy [Zip] activated but row query is undefined for [{}], fallback to default",
237 1 1. lambda$sqlRows$7 : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$7 → NO_COVERAGE
                    () -> this.injectionModel.getMediatorVendor().getVendor()
238
                );
239
            }
240
        }
241
        
242
        var matcherSqlField = Pattern.compile("(?s)(.*)"+ Pattern.quote(VendorYaml.FIELD) +"(.*)").matcher(sqlField);
243
        String leadSqlField = StringUtils.EMPTY;
244
        String trailSqlField = StringUtils.EMPTY;
245
        
246 1 1. sqlRows : negated conditional → NO_COVERAGE
        if (matcherSqlField.find()) {
247
            leadSqlField = matcherSqlField.group(1);
248
            trailSqlField = matcherSqlField.group(2);
249
        }
250
        
251
        var namesColumnUtf8 = new String[namesColumns.length];
252 2 1. sqlRows : changed conditional boundary → NO_COVERAGE
2. sqlRows : negated conditional → NO_COVERAGE
        for (var i = 0 ; i < namesColumns.length ; i++) {
253
            namesColumnUtf8[i] = StringUtil.detectUtf8(namesColumns[i]);
254
            namesColumnUtf8[i] = URLEncoder.encode(namesColumnUtf8[i], StandardCharsets.UTF_8);
255
        }
256
        
257
        var nameDatabaseUtf8 = StringUtil.detectUtf8(database.toString());
258
        nameDatabaseUtf8 = URLEncoder.encode(nameDatabaseUtf8, StandardCharsets.UTF_8);
259
        
260
        var nameTableUtf8 = StringUtil.detectUtf8(table.toString());
261
        nameTableUtf8 = URLEncoder.encode(nameTableUtf8, StandardCharsets.UTF_8);
262
        
263 1 1. sqlRows : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlRows → NO_COVERAGE
        return sqlQuery.replace(
264
                VendorYaml.FIELDS,
265
                leadSqlField
266
                + String.join(
267
                    trailSqlField + sqlConcatFields + leadSqlField,
268
                    namesColumnUtf8
269
                )
270
                + trailSqlField
271
            )
272
            .replace(VendorYaml.DATABASE, nameDatabaseUtf8)
273
            .replace(VendorYaml.TABLE, nameTableUtf8);
274
    }
275
276
    @Override
277
    public String sqlTestBlindWithOperator(String check, BlindOperator blindMode) {
278
        String replacement = this.getMode(blindMode);
279 1 1. sqlTestBlindWithOperator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestBlindWithOperator → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getBlind()
280
            .replace(VendorYaml.BINARY_MODE, replacement)
281
            .replace(VendorYaml.TEST, check)
282
            .trim();  // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql()
283
    }
284
285
    @Override
286
    public String sqlBlindBit(String inj, int indexChar, int bit, BlindOperator blindMode) {
287
        String replacement = this.getMode(blindMode);
288 1 1. sqlBlindBit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBit → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getBlind()
289
            .replace(VendorYaml.BINARY_MODE, replacement)
290
            .replace(
291
                VendorYaml.TEST,
292
                this.modelYaml.getStrategy().getBinary().getTest().getBit()
293
                .replace(VendorYaml.INJECTION, inj)
294
                .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar))
295
                .replace(VendorYaml.BIT, Integer.toString(bit))
296
            )
297
            .trim();  // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql()
298
    }
299
300
    @Override
301
    public String sqlBlindBin(String inj, int indexChar, int mid, BlindOperator blindMode) {
302
        String replacement = this.getMode(blindMode);
303 1 1. sqlBlindBin : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBin → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getBlind()
304
            .replace(VendorYaml.BINARY_MODE, replacement)
305
            .replace(
306
                VendorYaml.TEST,
307
                this.modelYaml.getStrategy().getBinary().getTest().getBin()
308
                .replace(VendorYaml.INJECTION, inj)
309
                .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar))
310
                .replace(VendorYaml.MID, StringUtil.toUrl(Character.toString((char) mid)))
311
            )
312
            .trim();  // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql()
313
    }
314
315
    @Override
316
    public String sqlTestTimeWithOperator(String check, BlindOperator blindMode) {
317
        String replacement = this.getMode(blindMode);
318 1 1. sqlTestTimeWithOperator : negated conditional → NO_COVERAGE
        int countSleepTimeStrategy = this.injectionModel.getMediatorUtils().getPreferencesUtil().isLimitingSleepTimeStrategy()
319
            ? this.injectionModel.getMediatorUtils().getPreferencesUtil().countSleepTimeStrategy()
320
            : 5;
321 1 1. sqlTestTimeWithOperator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestTimeWithOperator → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTime()
322
            .replace(VendorYaml.BINARY_MODE, replacement)
323
            .replace(VendorYaml.TEST, check)
324
            .replace(VendorYaml.SLEEP_TIME, Long.toString(countSleepTimeStrategy))
325
            .trim();  // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql()
326
    }
327
328
    @Override
329
    public String sqlTimeBit(String inj, int indexChar, int bit, BlindOperator blindMode) {
330
        String replacement = this.getMode(blindMode);
331 1 1. sqlTimeBit : negated conditional → NO_COVERAGE
        int countSleepTimeStrategy = this.injectionModel.getMediatorUtils().getPreferencesUtil().isLimitingSleepTimeStrategy()
332
            ? this.injectionModel.getMediatorUtils().getPreferencesUtil().countSleepTimeStrategy()
333
            : 5;
334 1 1. sqlTimeBit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTimeBit → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTime()
335
            .replace(VendorYaml.BINARY_MODE, replacement)
336
            .replace(
337
                VendorYaml.TEST,
338
                this.modelYaml.getStrategy().getBinary().getTest()
339
                .getBit()
340
                .replace(VendorYaml.INJECTION, inj)
341
                .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar))
342
                .replace(VendorYaml.BIT, Integer.toString(bit))
343
            )
344
            .replace(VendorYaml.SLEEP_TIME, Long.toString(countSleepTimeStrategy))
345
            .trim();  // trim spaces in '${binary.mode} ${test}' when no mode, not covered by cleanSql()
346
    }
347
348
    private String getMode(BlindOperator blindMode) {
349
        String replacement;
350
        switch (blindMode) {
351
            case AND: replacement = this.modelYaml.getStrategy().getBinary().getModeAnd(); break;
352
            case OR: replacement = this.modelYaml.getStrategy().getBinary().getModeOr(); break;
353
            case STACK: replacement = this.modelYaml.getStrategy().getBinary().getModeStack(); break;
354
            case NO_MODE:
355
            default: replacement = StringUtils.EMPTY; break;
356
        }
357
        return replacement;
358
    }
359
360
    @Override
361
    public String sqlBlind(String sqlQuery, String startPosition, boolean isReport) {
362 1 1. sqlBlind : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlind → NO_COVERAGE
        return VendorYaml.replaceTags(
363
            this.getSlidingWindow(isReport)
364
            .replace(VendorYaml.INJECTION, sqlQuery)
365
            .replace(VendorYaml.WINDOW_CHAR, startPosition)
366
            .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY)
367
        );
368
    }
369
370
    @Override
371
    public String sqlTime(String sqlQuery, String startPosition, boolean isReport) {
372 1 1. sqlTime : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTime → NO_COVERAGE
        return VendorYaml.replaceTags(
373
            this.getSlidingWindow(isReport)
374
            .replace(VendorYaml.INJECTION, sqlQuery)
375
            .replace(VendorYaml.WINDOW_CHAR, startPosition)
376
            .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY)
377
        );
378
    }
379
380
    @Override
381
    public String sqlMultibit(String inj, int indexChar, int block){
382 1 1. sqlMultibit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlMultibit → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getMultibit()
383
            .replace(VendorYaml.INJECTION, inj)
384
            .replace(VendorYaml.WINDOW_CHAR, Integer.toString(indexChar))
385
            .replace(VendorYaml.BLOCK_MULTIBIT, Integer.toString(block));
386
    }
387
388
    @Override
389
    public String sqlErrorCalibrator(Method errorMethod) {
390 1 1. sqlErrorCalibrator : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorCalibrator → NO_COVERAGE
        return VendorYaml.replaceTags(
391
            errorMethod.getQuery()
392
            .replace(VendorYaml.WINDOW, this.modelYaml.getStrategy().getConfiguration().getSlidingWindow())
393
            .replace(VendorYaml.INJECTION, this.modelYaml.getStrategy().getConfiguration().getCalibrator())
394
            .replace(VendorYaml.WINDOW_CHAR, "1")
395
            .replace(VendorYaml.CAPACITY, Integer.toString(errorMethod.getCapacity()))
396
        );
397
    }
398
399
    @Override
400
    public String sqlErrorIndice(Method errorMethod) {
401
        var indexZeroToFind = "0";
402 1 1. sqlErrorIndice : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorIndice → NO_COVERAGE
        return VendorYaml.replaceTags(
403
            errorMethod.getQuery()
404
            .replace(VendorYaml.WINDOW, this.modelYaml.getStrategy().getConfiguration().getSlidingWindow())
405
            .replace(VendorYaml.INJECTION, this.modelYaml.getStrategy().getConfiguration().getFailsafe().replace(VendorYaml.INDICE, indexZeroToFind))
406
            .replace(VendorYaml.WINDOW_CHAR, "1")
407
            .replace(VendorYaml.CAPACITY, Integer.toString(errorMethod.getCapacity()))
408
        );
409
    }
410
411
    @Override
412
    public String sqlError(String sqlQuery, String startPosition, int indexMethodError, boolean isReport) {
413 1 1. sqlError : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlError → NO_COVERAGE
        return VendorYaml.replaceTags(
414
            this.modelYaml.getStrategy().getError().getMethod().get(indexMethodError).getQuery()
415
            .replace(VendorYaml.WINDOW, this.getSlidingWindow(isReport))
416
            .replace(VendorYaml.INJECTION, sqlQuery)
417
            .replace(VendorYaml.WINDOW_CHAR, startPosition)
418
            .replace(
419
                VendorYaml.CAPACITY,
420
                Integer.toString(
421
                    this.modelYaml.getStrategy().getError()
422
                    .getMethod()
423
                    .get(indexMethodError)
424
                    .getCapacity()
425
                )
426
            )
427
        );
428
    }
429
430
    @Override
431
    public String sqlUnion(String sqlQuery, String startPosition, boolean isReport) {
432 1 1. sqlUnion : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlUnion → NO_COVERAGE
        return VendorYaml.replaceTags(
433
            this.getSlidingWindow(isReport)
434
            .replace(VendorYaml.INJECTION, sqlQuery)
435
            .replace(VendorYaml.WINDOW_CHAR, startPosition)
436
            .replace(VendorYaml.CAPACITY, this.injectionModel.getMediatorStrategy().getUnion().getPerformanceLength())
437
        );
438
    }
439
440
    @Override
441
    public String sqlStack(String sqlQuery, String startPosition, boolean isReport) {
442 1 1. sqlStack : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlStack → NO_COVERAGE
        return this.modelYaml.getStrategy().getStack().replace(
443
            VendorYaml.WINDOW,
444
            VendorYaml.replaceTags(
445
                this.getSlidingWindow(isReport)
446
                .replace(VendorYaml.INJECTION, sqlQuery)
447
                .replace(VendorYaml.WINDOW_CHAR, startPosition)
448
                .replace(VendorYaml.CAPACITY, VendorYaml.DEFAULT_CAPACITY)
449
            )
450
        );
451
    }
452
453
    @Override
454
    public String sqlCapacity(String[] indexes) {
455
        String regexIndexes = String.join("|", indexes);
456
        String regexVisibleIndexesToFind = String.format(VendorYaml.FORMAT_INDEX, "(%s)");
457 1 1. sqlCapacity : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlCapacity → NO_COVERAGE
        return this.injectionModel.getIndexesInUrl().replaceAll(
458
            String.format(regexVisibleIndexesToFind, regexIndexes),
459
            VendorYaml.replaceTags(
460
                this.modelYaml.getStrategy().getUnion().getCapacity()
461
                .replace(VendorYaml.CALIBRATOR, this.modelYaml.getStrategy().getConfiguration().getCalibrator())
462
                .replace(VendorYaml.INDICE, "$1")
463
            )
464
        );
465
    }
466
467
    @Override
468
    public String sqlIndices(Integer nbFields) {
469
        String replaceTag = StringUtils.EMPTY;
470
        List<String> fields = new ArrayList<>();
471
        var indice = 1;
472 2 1. sqlIndices : changed conditional boundary → NO_COVERAGE
2. sqlIndices : negated conditional → NO_COVERAGE
        for ( ; indice <= nbFields ; indice++) {
473
            String field = this.modelYaml.getStrategy().getConfiguration().getFailsafe().replace(VendorYaml.INDICE, Integer.toString(indice));
474
            fields.add(field);
475
            replaceTag = field;
476
        }
477 1 1. sqlIndices : Changed increment from -1 to 1 → NO_COVERAGE
        indice--;
478 1 1. sqlIndices : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlIndices → NO_COVERAGE
        return this.modelYaml.getStrategy().getUnion()
479
            .getIndices()
480
            .replace(
481
                VendorYaml.INDICES,
482
                String.join(",", fields.toArray(new String[0]))
483
            )
484
            .replace(VendorYaml.INDICE_UNIQUE, replaceTag)
485
            .replace(
486
                VendorYaml.RESULT_RANGE,
487
                String.join(",", Collections.nCopies(indice, "r"))
488
            );
489
    }
490
491
    @Override
492
    public String sqlLimit(Integer limitSqlResult) {
493
        var limitBoundary = 0;
494
        try {
495
            limitBoundary = Integer.parseInt(this.modelYaml.getStrategy().getConfiguration().getLimitBoundary());
496
        } catch (NumberFormatException e) {
497
            LOGGER.log(LogLevelUtil.CONSOLE_ERROR, "Incorrect Limit start index, force to 0");
498
        }
499 1 1. sqlLimit : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlLimit → NO_COVERAGE
        return this.modelYaml.getStrategy().getConfiguration()
500
            .getLimit()
501 1 1. sqlLimit : Replaced integer addition with subtraction → NO_COVERAGE
            .replace(VendorYaml.LIMIT_VALUE, Integer.toString(limitSqlResult + limitBoundary));
502
    }
503
    
504
    @Override
505
    public String fingerprintErrorsAsRegex() {
506 1 1. fingerprintErrorsAsRegex : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::fingerprintErrorsAsRegex → NO_COVERAGE
        return "(?si)"+ StringUtils.join(
507
            this.modelYaml.getStrategy().getConfiguration().getFingerprint()
508
            .getErrorMessage()
509
            .stream()
510 1 1. lambda$fingerprintErrorsAsRegex$8 : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::lambda$fingerprintErrorsAsRegex$8 → NO_COVERAGE
            .map(m -> ".*"+ m +".*")
511
            .toArray(),
512
            "|"
513
        );
514
    }
515
    
516
    public static String replaceTags(String sqlRequest) {
517 1 1. replaceTags : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::replaceTags → NO_COVERAGE
        return sqlRequest
518
            .replace("${enclose_value_sql}", VendorYaml.ENCLOSE_VALUE_SQL)
519
            .replace("${enclose_value_hex}", VendorYaml.ENCLOSE_VALUE_HEX)
520
            .replace("${separator_qte_sql}", VendorYaml.SEPARATOR_QTE_SQL)
521
            .replace("${separator_qte_hex}", VendorYaml.SEPARATOR_QTE_HEX)
522
            .replace("${separator_cell_sql}", VendorYaml.SEPARATOR_CELL_SQL)
523
            .replace("${separator_cell_hex}", VendorYaml.SEPARATOR_CELL_HEX)
524
            .replace("${calibrator_sql}", VendorYaml.CALIBRATOR_SQL)
525
            .replace("${calibrator_raw}", VendorYaml.CALIBRATOR_SQL.repeat(100))
526
            .replace("${calibrator_hex}", VendorYaml.CALIBRATOR_HEX)
527
            .replace("${trail_sql}", VendorYaml.TRAIL_SQL)
528
            .replace("${trail_hex}", VendorYaml.TRAIL_HEX)
529
            .replace("${lead}", LEAD)
530
            .replace("${lead_hex}", VendorYaml.LEAD_HEX)
531
            .replace("${lead_pipe}", VendorYaml.LEAD_PIPE);
532
    }
533
534
    /**
535
     * Get payload with sliding window except for vulnerability report
536
     */
537
    private String getSlidingWindow(boolean isReport) {
538 2 1. getSlidingWindow : negated conditional → NO_COVERAGE
2. getSlidingWindow : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::getSlidingWindow → NO_COVERAGE
        return isReport
539
            ? "(" + VendorYaml.INJECTION + ")"
540
            : this.modelYaml.getStrategy().getConfiguration().getSlidingWindow();
541
    }
542
    
543
    
544
    // Getter and setter
545
546
    @Override
547
    public String sqlInfos() {
548 1 1. sqlInfos : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlInfos → NO_COVERAGE
        return this.modelYaml.getResource().getInfo();
549
    }
550
551
    @Override
552
    public List<String> getFalsyBit() {
553 1 1. getFalsyBit : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBit → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTest().getFalsyBit();
554
    }
555
556
    @Override
557
    public List<String> getTruthyBit() {
558 1 1. getTruthyBit : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBit → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTest().getTruthyBit();
559
    }
560
561
    @Override
562
    public List<String> getFalsyBin() {
563 1 1. getFalsyBin : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBin → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTest().getFalsyBin();
564
    }
565
566
    @Override
567
    public List<String> getTruthyBin() {
568 1 1. getTruthyBin : replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBin → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTest().getTruthyBin();
569
    }
570
571
    @Override
572
    public String sqlBlindConfirm() {
573 1 1. sqlBlindConfirm : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindConfirm → NO_COVERAGE
        return this.modelYaml.getStrategy().getBinary().getTest().getInit();
574
    }
575
576
    @Override
577
    public String sqlOrderBy() {
578 1 1. sqlOrderBy : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlOrderBy → NO_COVERAGE
        return this.modelYaml.getStrategy().getUnion().getOrderBy();
579
    }
580
    
581
    @Override
582
    public String endingComment() {
583 1 1. endingComment : negated conditional → NO_COVERAGE
        if (this.injectionModel.getMediatorUtils().getPreferencesUtil().isUrlRandomSuffixDisabled()) {
584 1 1. endingComment : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE
            return this.modelYaml.getStrategy().getConfiguration().getEndingComment();
585
        } else {
586 1 1. endingComment : replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE
            return this.modelYaml.getStrategy().getConfiguration().getEndingComment()
587
                + RandomStringUtils.secure().nextAlphanumeric(4);  // Allows binary match fingerprinting on host errors
588
        }
589
    }
590
591
    @Override
592
    public ModelYaml getModelYaml() {
593 1 1. getModelYaml : replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::getModelYaml → KILLED
        return this.modelYaml;
594
    }
595
}

Mutations

118

1.1
Location : sqlDatabases
Killed by : none
negated conditional → NO_COVERAGE

119

1.1
Location : sqlDatabases
Killed by : none
negated conditional → NO_COVERAGE

125

1.1
Location : lambda$sqlDatabases$0
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$0 → NO_COVERAGE

128

1.1
Location : sqlDatabases
Killed by : none
negated conditional → NO_COVERAGE

129

1.1
Location : sqlDatabases
Killed by : none
negated conditional → NO_COVERAGE

135

1.1
Location : lambda$sqlDatabases$1
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlDatabases$1 → NO_COVERAGE

139

1.1
Location : sqlDatabases
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlDatabases → NO_COVERAGE

146

1.1
Location : sqlTables
Killed by : none
negated conditional → NO_COVERAGE

147

1.1
Location : sqlTables
Killed by : none
negated conditional → NO_COVERAGE

153

1.1
Location : lambda$sqlTables$2
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$2 → NO_COVERAGE

156

1.1
Location : sqlTables
Killed by : none
negated conditional → NO_COVERAGE

157

1.1
Location : sqlTables
Killed by : none
negated conditional → NO_COVERAGE

163

1.1
Location : lambda$sqlTables$3
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlTables$3 → NO_COVERAGE

169

1.1
Location : sqlTables
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTables → NO_COVERAGE

178

1.1
Location : sqlColumns
Killed by : none
negated conditional → NO_COVERAGE

179

1.1
Location : sqlColumns
Killed by : none
negated conditional → NO_COVERAGE

185

1.1
Location : lambda$sqlColumns$4
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$4 → NO_COVERAGE

188

1.1
Location : sqlColumns
Killed by : none
negated conditional → NO_COVERAGE

189

1.1
Location : sqlColumns
Killed by : none
negated conditional → NO_COVERAGE

195

1.1
Location : lambda$sqlColumns$5
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlColumns$5 → NO_COVERAGE

203

1.1
Location : sqlColumns
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlColumns → NO_COVERAGE

216

1.1
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

217

1.1
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

225

1.1
Location : lambda$sqlRows$6
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$6 → NO_COVERAGE

228

1.1
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

229

1.1
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

237

1.1
Location : lambda$sqlRows$7
Killed by : none
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::lambda$sqlRows$7 → NO_COVERAGE

246

1.1
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

252

1.1
Location : sqlRows
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : sqlRows
Killed by : none
negated conditional → NO_COVERAGE

263

1.1
Location : sqlRows
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlRows → NO_COVERAGE

279

1.1
Location : sqlTestBlindWithOperator
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestBlindWithOperator → NO_COVERAGE

288

1.1
Location : sqlBlindBit
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBit → NO_COVERAGE

303

1.1
Location : sqlBlindBin
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindBin → NO_COVERAGE

318

1.1
Location : sqlTestTimeWithOperator
Killed by : none
negated conditional → NO_COVERAGE

321

1.1
Location : sqlTestTimeWithOperator
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTestTimeWithOperator → NO_COVERAGE

331

1.1
Location : sqlTimeBit
Killed by : none
negated conditional → NO_COVERAGE

334

1.1
Location : sqlTimeBit
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTimeBit → NO_COVERAGE

362

1.1
Location : sqlBlind
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlind → NO_COVERAGE

372

1.1
Location : sqlTime
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlTime → NO_COVERAGE

382

1.1
Location : sqlMultibit
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlMultibit → NO_COVERAGE

390

1.1
Location : sqlErrorCalibrator
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorCalibrator → NO_COVERAGE

402

1.1
Location : sqlErrorIndice
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlErrorIndice → NO_COVERAGE

413

1.1
Location : sqlError
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlError → NO_COVERAGE

432

1.1
Location : sqlUnion
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlUnion → NO_COVERAGE

442

1.1
Location : sqlStack
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlStack → NO_COVERAGE

457

1.1
Location : sqlCapacity
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlCapacity → NO_COVERAGE

472

1.1
Location : sqlIndices
Killed by : none
changed conditional boundary → NO_COVERAGE

2.2
Location : sqlIndices
Killed by : none
negated conditional → NO_COVERAGE

477

1.1
Location : sqlIndices
Killed by : none
Changed increment from -1 to 1 → NO_COVERAGE

478

1.1
Location : sqlIndices
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlIndices → NO_COVERAGE

499

1.1
Location : sqlLimit
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlLimit → NO_COVERAGE

501

1.1
Location : sqlLimit
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

506

1.1
Location : fingerprintErrorsAsRegex
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::fingerprintErrorsAsRegex → NO_COVERAGE

510

1.1
Location : lambda$fingerprintErrorsAsRegex$8
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::lambda$fingerprintErrorsAsRegex$8 → NO_COVERAGE

517

1.1
Location : replaceTags
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::replaceTags → NO_COVERAGE

538

1.1
Location : getSlidingWindow
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : getSlidingWindow
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::getSlidingWindow → NO_COVERAGE

548

1.1
Location : sqlInfos
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlInfos → NO_COVERAGE

553

1.1
Location : getFalsyBit
Killed by : none
replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBit → NO_COVERAGE

558

1.1
Location : getTruthyBit
Killed by : none
replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBit → NO_COVERAGE

563

1.1
Location : getFalsyBin
Killed by : none
replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getFalsyBin → NO_COVERAGE

568

1.1
Location : getTruthyBin
Killed by : none
replaced return value with Collections.emptyList for com/jsql/model/injection/vendor/model/VendorYaml::getTruthyBin → NO_COVERAGE

573

1.1
Location : sqlBlindConfirm
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlBlindConfirm → NO_COVERAGE

578

1.1
Location : sqlOrderBy
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::sqlOrderBy → NO_COVERAGE

583

1.1
Location : endingComment
Killed by : none
negated conditional → NO_COVERAGE

584

1.1
Location : endingComment
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE

586

1.1
Location : endingComment
Killed by : none
replaced return value with "" for com/jsql/model/injection/vendor/model/VendorYaml::endingComment → NO_COVERAGE

593

1.1
Location : getModelYaml
Killed by : ParameterUtilSpock.[engine:spock]/[spec:ParameterUtilSpock]/[feature:$spock_feature_0_2]
replaced return value with null for com/jsql/model/injection/vendor/model/VendorYaml::getModelYaml → KILLED

Active mutators

Tests examined


Report generated by PIT 1.19.1