CallableTime.java

1
package com.jsql.model.injection.strategy.blind;
2
3
import com.jsql.model.InjectionModel;
4
import com.jsql.model.injection.strategy.blind.AbstractInjectionBoolean.BooleanMode;
5
6
import java.util.Calendar;
7
import java.util.Date;
8
9
/**
10
 * Define a call HTTP to the server, require the associated url, character position and bit.
11
 * diffSeconds represents the response time of the current page
12
 */
13
public class CallableTime extends AbstractCallableBoolean<CallableTime> {
14
    
15
    /**
16
     * Time before the url call.
17
     */
18
    private final Calendar calendarOnStart = Calendar.getInstance();
19
    
20
    /**
21
     * Time at the end of the url call.
22
     */
23
    private final Calendar calendarOnEnd = Calendar.getInstance();
24
    
25
    /**
26
     * Current page loading time.
27
     */
28
    private long diffSeconds;
29
30
    private final InjectionModel injectionModel;
31
    
32
    private final InjectionTime injectionTime;
33
    private final String metadataInjectionProcess;
34
    
35
    /**
36
     * Constructor for preparation and blind confirmation.
37
     */
38
    public CallableTime(
39
        String sqlQuery,
40
        InjectionModel injectionModel,
41
        InjectionTime injectionTime,
42
        BooleanMode blindMode,
43
        String metadataInjectionProcess
44
    ) {
45
        
46
        this.injectionModel = injectionModel;
47
        this.injectionTime = injectionTime;
48
        this.metadataInjectionProcess = metadataInjectionProcess;
49
        this.booleanUrl = this.injectionModel.getMediatorVendor().getVendor().instance().sqlTimeTest(sqlQuery, blindMode);
50
    }
51
    
52
    /**
53
     * Constructor for bit test.
54
     */
55
    public CallableTime(
56
        String sqlQuery,
57
        int indexCharacter,
58
        int bit,
59
        InjectionModel injectionModel,
60
        InjectionTime injectionTime,
61
        BooleanMode blindMode,
62
        String metadataInjectionProcess
63
    ) {
64
        
65
        this(sqlQuery, injectionModel, injectionTime, blindMode, metadataInjectionProcess);
66
        this.booleanUrl = this.injectionModel.getMediatorVendor().getVendor().instance().sqlBitTestTime(sqlQuery, indexCharacter, bit, blindMode);
67
        this.currentIndex = indexCharacter;
68
        this.currentBit = bit;
69
    }
70
    
71
    @Override
72
    public boolean isTrue() {
73
74 1 1. isTrue : negated conditional → NO_COVERAGE
        int countSleepTimeStrategy = this.injectionModel.getMediatorUtils().getPreferencesUtil().isLimitingSleepTimeStrategy()
75
            ? this.injectionModel.getMediatorUtils().getPreferencesUtil().countSleepTimeStrategy()
76
            : 5;
77
        
78 3 1. isTrue : replaced boolean return with true for com/jsql/model/injection/strategy/blind/CallableTime::isTrue → NO_COVERAGE
2. isTrue : negated conditional → NO_COVERAGE
3. isTrue : changed conditional boundary → NO_COVERAGE
        return this.diffSeconds < countSleepTimeStrategy;
79
    }
80
81
    /**
82
     * Process the URL HTTP call, use function inject() from the model.
83
     * Calculate the response time of the current page.
84
     * @return Functional Time callable
85
     */
86
    @Override
87
    public CallableTime call() {
88
        
89 1 1. call : removed call to java/util/Calendar::setTime → NO_COVERAGE
        this.calendarOnStart.setTime(new Date());
90
        this.injectionTime.callUrl(this.booleanUrl, this.metadataInjectionProcess, this);
91 1 1. call : removed call to java/util/Calendar::setTime → NO_COVERAGE
        this.calendarOnEnd.setTime(new Date());
92
        
93
        long timeInMillisOnStart = this.calendarOnStart.getTimeInMillis();
94
        long timeInMillisOnEnd = this.calendarOnEnd.getTimeInMillis();
95
        
96 1 1. call : Replaced long subtraction with addition → NO_COVERAGE
        long diff = timeInMillisOnEnd - timeInMillisOnStart;
97
        
98 1 1. call : Replaced long division with multiplication → NO_COVERAGE
        this.diffSeconds = diff / 1000;
99
        
100 1 1. call : replaced return value with null for com/jsql/model/injection/strategy/blind/CallableTime::call → NO_COVERAGE
        return this;
101
    }
102
}

Mutations

74

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

78

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

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

3.3
Location : isTrue
Killed by : none
changed conditional boundary → NO_COVERAGE

89

1.1
Location : call
Killed by : none
removed call to java/util/Calendar::setTime → NO_COVERAGE

91

1.1
Location : call
Killed by : none
removed call to java/util/Calendar::setTime → NO_COVERAGE

96

1.1
Location : call
Killed by : none
Replaced long subtraction with addition → NO_COVERAGE

98

1.1
Location : call
Killed by : none
Replaced long division with multiplication → NO_COVERAGE

100

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

Active mutators

Tests examined


Report generated by PIT 1.16.1