Search in sources :

Example 1 with Method

use of com.jsql.model.injection.vendor.model.yaml.Method in project jsql-injection by ron190.

the class StrategyInjectionError method checkApplicability.

@Override
public void checkApplicability() {
    // Reset applicability of new Vendor
    this.isApplicable = false;
    var strategyYaml = this.injectionModel.getMediatorVendor().getVendor().instance().getModelYaml().getStrategy();
    if (strategyYaml.getError().getMethod().isEmpty()) {
        LOGGER.log(LogLevel.CONSOLE_DEFAULT, "No Error strategy for {}", this.injectionModel.getMediatorVendor().getVendor());
        return;
    }
    var configurationYaml = strategyYaml.getConfiguration();
    LOGGER.log(LogLevel.CONSOLE_DEFAULT, "{} Error...", () -> I18nUtil.valueByKey("LOG_CHECKING_STRATEGY"));
    this.tabCapacityMethod = new String[strategyYaml.getError().getMethod().size()];
    var indexErrorMethod = 0;
    var errorCapacity = 0;
    for (Method errorMethod : strategyYaml.getError().getMethod()) {
        boolean methodIsApplicable = this.isApplicable(configurationYaml, errorMethod);
        if (methodIsApplicable) {
            Matcher regexSearch = this.getPerformance(configurationYaml, errorMethod);
            if (regexSearch.find()) {
                errorCapacity = this.getCapacity(indexErrorMethod, errorCapacity, errorMethod, regexSearch);
            } else {
                LOGGER.log(LogLevel.CONSOLE_ERROR, "{} {} but injectable size is incorrect", () -> I18nUtil.valueByKey("LOG_VULNERABLE"), errorMethod::getName);
                methodIsApplicable = false;
            }
        }
        if (methodIsApplicable) {
            this.allow(indexErrorMethod);
        } else {
            this.unallow(indexErrorMethod);
        }
        indexErrorMethod++;
    }
}
Also used : Matcher(java.util.regex.Matcher) Method(com.jsql.model.injection.vendor.model.yaml.Method)

Example 2 with Method

use of com.jsql.model.injection.vendor.model.yaml.Method in project jsql-injection by ron190.

the class AddressMenuBar method initErrorMethods.

public void initErrorMethods(Vendor vendor) {
    this.itemRadioStrategyError.removeAll();
    var indexError = 0;
    if (vendor != MediatorHelper.model().getMediatorVendor().getAuto() && vendor.instance().getModelYaml().getStrategy().getError() != null) {
        for (Method methodError : vendor.instance().getModelYaml().getStrategy().getError().getMethod()) {
            JMenuItem itemRadioVendor = new JRadioButtonMenuItem(methodError.getName());
            itemRadioVendor.setEnabled(false);
            itemRadioVendor.setName("itemRadioVendor" + methodError.getName());
            this.itemRadioStrategyError.add(itemRadioVendor);
            this.groupStrategy.add(itemRadioVendor);
            int indexErrorFinal = indexError;
            itemRadioVendor.addActionListener(actionEvent -> {
                this.menuStrategy.setText(methodError.getName());
                MediatorHelper.model().getMediatorStrategy().setStrategy(MediatorHelper.model().getMediatorStrategy().getError());
                MediatorHelper.model().getMediatorStrategy().getError().setIndexErrorStrategy(indexErrorFinal);
            });
            indexError++;
        }
    }
}
Also used : JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) Method(com.jsql.model.injection.vendor.model.yaml.Method) JMenuItem(javax.swing.JMenuItem)

Example 3 with Method

use of com.jsql.model.injection.vendor.model.yaml.Method in project jsql-injection by ron190.

the class SqlEngine method populateTabError.

/**
 * Dynamically add textPanes to Error tab for current vendor.
 */
private static void populateTabError() {
    SqlEngine.tabbedPaneError.removeAll();
    if (SqlEngine.modelYaml.getStrategy().getError() == null) {
        return;
    }
    for (Method methodError : SqlEngine.modelYaml.getStrategy().getError().getMethod()) {
        var panelError = new JPanel(new BorderLayout());
        final var refMethodError = new Method[] { methodError };
        var textPaneError = new JTextPaneLexer(refMethodError[0]::setQuery, refMethodError[0]::getQuery);
        SqlEngine.resetLexer(textPaneError);
        textPaneError.switchSetterToVendor();
        textPaneError.setText(methodError.getQuery().trim());
        textPaneError.setBorder(SqlEngine.borderRight);
        panelError.add(new LightScrollPane(1, 0, 1, 0, textPaneError), BorderLayout.CENTER);
        var panelLimit = new JPanel();
        panelLimit.setLayout(new BoxLayout(panelLimit, BoxLayout.LINE_AXIS));
        panelLimit.add(new JLabel(" Overflow limit: "));
        panelLimit.add(new JTextField(Integer.toString(methodError.getCapacity())));
        // TODO Integrate Error limit
        panelError.add(panelLimit, BorderLayout.SOUTH);
        SqlEngine.tabbedPaneError.addTab(methodError.getName(), panelError);
        SqlEngine.tabbedPaneError.setTitleAt(SqlEngine.tabbedPaneError.getTabCount() - 1, String.format("<html><div style=\"text-align:left;width:100px;\">%s</div></html>", methodError.getName()));
        SqlEngine.textPanesError.add(textPaneError);
    }
}
Also used : JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) LightScrollPane(com.jsql.view.swing.scrollpane.LightScrollPane) JLabel(javax.swing.JLabel) JTextPaneObjectMethod(com.jsql.view.swing.sql.text.JTextPaneObjectMethod) Method(com.jsql.model.injection.vendor.model.yaml.Method) JTextPaneLexer(com.jsql.view.swing.sql.text.JTextPaneLexer) JTextField(javax.swing.JTextField)

Aggregations

Method (com.jsql.model.injection.vendor.model.yaml.Method)3 LightScrollPane (com.jsql.view.swing.scrollpane.LightScrollPane)1 JTextPaneLexer (com.jsql.view.swing.sql.text.JTextPaneLexer)1 JTextPaneObjectMethod (com.jsql.view.swing.sql.text.JTextPaneObjectMethod)1 BorderLayout (java.awt.BorderLayout)1 Matcher (java.util.regex.Matcher)1 BoxLayout (javax.swing.BoxLayout)1 JLabel (javax.swing.JLabel)1 JMenuItem (javax.swing.JMenuItem)1 JPanel (javax.swing.JPanel)1 JRadioButtonMenuItem (javax.swing.JRadioButtonMenuItem)1 JTextField (javax.swing.JTextField)1