SubscriberLogger.java

1
/*******************************************************************************
2
 * Copyhacked (H) 2012-2025.
3
 * This program and the accompanying materials
4
 * are made available under no term at all, use it like
5
 * you want, but share and discuss it
6
 * every time possible with every body.
7
 *
8
 * Contributors:
9
 *      ron190 at ymail dot com - initial implementation
10
 ******************************************************************************/
11
package com.jsql.view.subscriber;
12
13
import com.jsql.model.InjectionModel;
14
import com.jsql.model.injection.strategy.StrategyError;
15
import com.jsql.util.AnsiColorUtil;
16
import org.apache.logging.log4j.LogManager;
17
import org.apache.logging.log4j.Logger;
18
19
/**
20
 * View in the MVC pattern for integration test, process actions sent by the model.<br>
21
 */
22
public class SubscriberLogger extends AbstractSubscriber {
23
24
    private static final Logger LOGGER = LogManager.getRootLogger();
25
    private final InjectionModel model;
26
27
    public SubscriberLogger(InjectionModel model) {
28
        this.model = model;
29
    }
30
31
    @Override
32
    protected void execute(Seal request) {
33
        switch (request) {
34
            case Seal.AddDatabases r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
35
            case Seal.AddTables r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
36
            case Seal.AddColumns r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
37
38
            case Seal.AddTabExploitWeb r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
39
            case Seal.GetTerminalResult r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
40
41
            case Seal.MarkStrategyInvulnerable(var indexError, var strategy) -> {
42 1 1. execute : negated conditional → NO_COVERAGE
                if (strategy instanceof StrategyError) {
43
                    LOGGER.debug(() -> AnsiColorUtil.addRedColor(
44
                        this.model.getMediatorEngine().getEngine().instance().getModelYaml().getStrategy().getError().getMethod().get(indexError).getName()
45
                    ));
46
                } else {
47
                    LOGGER.debug(() -> AnsiColorUtil.addRedColor(strategy.getClass().getSimpleName()));
48
                }
49
            }
50
            case Seal.MarkStrategyVulnerable(var indexError, var strategy) -> {
51 1 1. execute : negated conditional → NO_COVERAGE
                if (strategy instanceof StrategyError) {
52
                    LOGGER.info(() -> AnsiColorUtil.addGreenColor(
53
                        this.model.getMediatorEngine().getEngine().instance().getModelYaml().getStrategy().getError().getMethod().get(indexError).getName()
54
                    ));
55
                } else {
56
                    LOGGER.info(() -> AnsiColorUtil.addGreenColor(strategy.getClass().getSimpleName()));
57
                }
58
            }
59
60
            case Seal.MarkFileSystemInvulnerable r -> LOGGER.debug(() -> AnsiColorUtil.addRedColor(r.getClass().getSimpleName()));
61
            case Seal.MarkFileSystemVulnerable r -> LOGGER.info(() -> AnsiColorUtil.addGreenColor(r.getClass().getSimpleName()));
62
63
            case Seal.MessageBinary(var message) -> LOGGER.info(message::trim);
64
            default -> {
65
                // empty
66
            }
67
        }
68
    }
69
}

Mutations

42

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

51

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

Active mutators

Tests examined


Report generated by PIT 1.22.1