CallableBlindBin.java

1
package com.jsql.model.injection.strategy.blind.callable;
2
3
import com.jsql.model.InjectionModel;
4
import com.jsql.model.injection.strategy.blind.AbstractInjectionBit.BlindOperator;
5
import com.jsql.model.injection.strategy.blind.InjectionBlindBin;
6
import name.fraser.neil.plaintext.diff_match_patch;
7
import static name.fraser.neil.plaintext.diff_match_patch.Diff;
8
9
import java.util.LinkedList;
10
import java.util.List;
11
import java.util.concurrent.CopyOnWriteArrayList;
12
13
/**
14
 * Define a call HTTP to the server, require the associated url, character
15
 * position and bit. Diffs represent the differences between
16
 * the reference page, and the current page.
17
 */
18
public class CallableBlindBin extends AbstractCallableBit<CallableBlindBin> {
19
20
    private final int low;
21
    private final int mid;
22
    private final int high;
23
24
    private LinkedList<Diff> diffsWithReference = new LinkedList<>();  // List of differences found between the reference page, and the current page
25
    private static final diff_match_patch DIFF_MATCH_PATCH = new diff_match_patch();
26
    private final InjectionBlindBin injectionBlind;
27
28
    private final InjectionModel injectionModel;
29
    private final String metadataInjectionProcess;
30
31
    /**
32
     * Constructor for preparation and blind confirmation.
33
     */
34
    public CallableBlindBin(
35
        String sqlQuery,
36
        InjectionModel injectionModel,
37
        InjectionBlindBin injectionBlind,
38
        BlindOperator blindMode,
39
        int low, int mid, int high,
40
        String metadataInjectionProcess
41
    ) {
42
        this.isBinary = true;
43
        this.low = low;
44
        this.mid = mid;
45
        this.high = high;
46
        this.injectionModel = injectionModel;
47
        this.injectionBlind = injectionBlind;
48
        this.metadataInjectionProcess = metadataInjectionProcess;
49
        this.booleanUrl = this.injectionModel.getMediatorVendor().getVendor().instance().sqlTestBlindWithOperator(sqlQuery, blindMode);
50
    }
51
52
    /**
53
     * Constructor for bits test.
54
     */
55
    public CallableBlindBin(
56
        String sqlQuery,
57
        int indexChar,
58
        InjectionModel injectionModel,
59
        InjectionBlindBin injectionBlind,
60
        BlindOperator blindMode,
61
        int low, int mid, int high,
62
        String metadataInjectionProcess
63
    ) {
64
        this(sqlQuery, injectionModel, injectionBlind, blindMode, low, mid, high, metadataInjectionProcess);
65
        this.booleanUrl = this.injectionModel.getMediatorVendor().getVendor().instance().sqlBlindBin(sqlQuery, indexChar, mid, blindMode);
66
        this.currentIndex = indexChar;
67
    }
68
69
    /**
70
     * Check if a result page means the SQL query is true,
71
     * confirm that nothing in the resulting page is also defined
72
     * in the pages from every FALSE SQL queries.
73
     * @return true if the current SQL query is true
74
     */
75
    @Override
76
    public boolean isTrue() {
77
        // Fix #95426: ConcurrentModificationException on iterator.next()
78
        List<Diff> falseDiffs = new CopyOnWriteArrayList<>(this.injectionBlind.getFalseDiffs());
79
        for (Diff falseDiff: falseDiffs) {
80
            // Fix #4386: NullPointerException on contains()
81
            // diffsWithReference is initialized to an empty new LinkedList<>()
82 1 1. isTrue : negated conditional → NO_COVERAGE
            if (this.diffsWithReference.contains(falseDiff)) {
83 1 1. isTrue : replaced boolean return with true for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::isTrue → NO_COVERAGE
                return false;
84
            }
85
        }
86 1 1. isTrue : replaced boolean return with false for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::isTrue → NO_COVERAGE
        return true;
87
    }
88
89
    /**
90
     * Process the URL HTTP call, use function inject() from the model.
91
     * Build the list of differences found between TRUE and the current page.
92
     * @return Functional Blind Callable
93
     */
94
    @Override
95
    public CallableBlindBin call() {
96
        String result = this.injectionBlind.callUrl(this.booleanUrl, this.metadataInjectionProcess, this);
97
        this.diffsWithReference = CallableBlindBin.DIFF_MATCH_PATCH.diff_main(this.injectionBlind.getSourceReferencePage(), result, true);
98 1 1. call : removed call to name/fraser/neil/plaintext/diff_match_patch::diff_cleanupEfficiency → NO_COVERAGE
        CallableBlindBin.DIFF_MATCH_PATCH.diff_cleanupEfficiency(this.diffsWithReference);
99 1 1. call : replaced return value with null for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::call → NO_COVERAGE
        return this;
100
    }
101
    
102
    public List<Diff> getDiffsWithReference() {
103 1 1. getDiffsWithReference : replaced return value with Collections.emptyList for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getDiffsWithReference → NO_COVERAGE
        return this.diffsWithReference;
104
    }
105
106
    public int getLow() {
107 1 1. getLow : replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getLow → NO_COVERAGE
        return this.low;
108
    }
109
110
    public int getMid() {
111 1 1. getMid : replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getMid → NO_COVERAGE
        return this.mid;
112
    }
113
114
    public int getHigh() {
115 1 1. getHigh : replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getHigh → NO_COVERAGE
        return this.high;
116
    }
117
}

Mutations

82

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

83

1.1
Location : isTrue
Killed by : none
replaced boolean return with true for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::isTrue → NO_COVERAGE

86

1.1
Location : isTrue
Killed by : none
replaced boolean return with false for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::isTrue → NO_COVERAGE

98

1.1
Location : call
Killed by : none
removed call to name/fraser/neil/plaintext/diff_match_patch::diff_cleanupEfficiency → NO_COVERAGE

99

1.1
Location : call
Killed by : none
replaced return value with null for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::call → NO_COVERAGE

103

1.1
Location : getDiffsWithReference
Killed by : none
replaced return value with Collections.emptyList for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getDiffsWithReference → NO_COVERAGE

107

1.1
Location : getLow
Killed by : none
replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getLow → NO_COVERAGE

111

1.1
Location : getMid
Killed by : none
replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getMid → NO_COVERAGE

115

1.1
Location : getHigh
Killed by : none
replaced int return with 0 for com/jsql/model/injection/strategy/blind/callable/CallableBlindBin::getHigh → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.19.1