CallableCharInsertion.java

1
package com.jsql.model.injection.strategy.blind;
2
3
import com.jsql.model.injection.strategy.blind.patch.Diff;
4
import com.jsql.model.injection.strategy.blind.patch.DiffMatchPatch;
5
6
import java.util.LinkedList;
7
import java.util.List;
8
import java.util.concurrent.CopyOnWriteArrayList;
9
10
/**
11
 * Define a call HTTP to the server, require the associated url, character
12
 * position and bit. Opcodes represent the differences between
13
 * the reference page, and the resulting page.
14
 */
15
public class CallableCharInsertion extends AbstractCallableBoolean<CallableCharInsertion> {
16
    
17
    // List of differences found between the reference page, and the present page
18
    private LinkedList<Diff> opcodes = new LinkedList<>();
19
    
20
    private static final DiffMatchPatch DIFF_MATCH_PATCH = new DiffMatchPatch();
21
22
    private final InjectionCharInsertion injectionCharInsertion;
23
    
24
    private final String metadataInjectionProcess;
25
    
26
    /**
27
     * Constructor for preparation and blind confirmation.
28
     * @param inj
29
     * @param injectionCharInsertion
30
     */
31
    public CallableCharInsertion(String inj, InjectionCharInsertion injectionCharInsertion, String metadataInjectionProcess) {
32
        
33
        this.injectionCharInsertion = injectionCharInsertion;
34
        this.metadataInjectionProcess = metadataInjectionProcess;
35
        this.booleanUrl = inj;
36
    }
37
38
    /**
39
     * Check if a result page means the SQL query is true,
40
     * confirm that nothing in the resulting page is also defined
41
     * in the pages from every FALSE SQL queries.
42
     * @return true if the current SQL query is true
43
     */
44
    @Override
45
    public boolean isTrue() {
46
47
        // Fix #95422: ConcurrentModificationException on iterator.next()
48
        List<Diff> copyTrueMarks = new CopyOnWriteArrayList<>(this.injectionCharInsertion.getConstantTrueMark());
49
        for (Diff trueDiff: copyTrueMarks) {
50 1 1. isTrue : negated conditional → NO_COVERAGE
            if (!this.opcodes.contains(trueDiff)) {
51 1 1. isTrue : replaced boolean return with true for com/jsql/model/injection/strategy/blind/CallableCharInsertion::isTrue → NO_COVERAGE
                return false;
52
            }
53
        }
54
55 1 1. isTrue : replaced boolean return with false for com/jsql/model/injection/strategy/blind/CallableCharInsertion::isTrue → NO_COVERAGE
        return true;
56
    }
57
58
    /**
59
     * Process the URL HTTP call, use function inject() from the model.
60
     * Build the list of differences found between TRUE and the current page.
61
     * @return Functional Blind Callable
62
     */
63
    @Override
64
    public CallableCharInsertion call() {
65
        
66
        String source = this.injectionCharInsertion.callUrl(this.booleanUrl, this.metadataInjectionProcess, this);
67
        
68
        this.opcodes = CallableCharInsertion.DIFF_MATCH_PATCH.diffMain(
69
            this.injectionCharInsertion.getBlankFalseMark(),
70
            source,
71
            false
72
        );
73
74 1 1. call : removed call to com/jsql/model/injection/strategy/blind/patch/DiffMatchPatch::diffCleanupEfficiency → NO_COVERAGE
        CallableCharInsertion.DIFF_MATCH_PATCH.diffCleanupEfficiency(this.opcodes);
75
        
76 1 1. call : replaced return value with null for com/jsql/model/injection/strategy/blind/CallableCharInsertion::call → NO_COVERAGE
        return this;
77
    }
78
    
79
    public List<Diff> getOpcodes() {
80 1 1. getOpcodes : replaced return value with Collections.emptyList for com/jsql/model/injection/strategy/blind/CallableCharInsertion::getOpcodes → NO_COVERAGE
        return this.opcodes;
81
    }
82
}

Mutations

50

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

51

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

55

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

74

1.1
Location : call
Killed by : none
removed call to com/jsql/model/injection/strategy/blind/patch/DiffMatchPatch::diffCleanupEfficiency → NO_COVERAGE

76

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

80

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

Active mutators

Tests examined


Report generated by PIT 1.16.1