Search in sources :

Example 1 with XPathExpressionEngine

use of org.apache.commons.configuration.tree.xpath.XPathExpressionEngine in project zaproxy by zaproxy.

the class AddOnCollection method load.

private void load(ZapXmlConfiguration config) {
    config.setExpressionEngine(new XPathExpressionEngine());
    try {
        // See if theres a ZAP release defined
        String version = config.getString("core/version");
        if (Platform.daily.equals(platform)) {
            // Daily releases take precedence even if running on Kali as they will have been manually installed
            version = config.getString("core/daily-version", version);
        } else if (Constant.isKali()) {
            version = config.getString("core/kali-version", version);
        }
        if (version != null && version.length() > 0) {
            String relUrlStr = config.getString("core/relnotes-url", null);
            URL relUrl = null;
            if (relUrlStr != null) {
                relUrl = new URL(relUrlStr);
            }
            this.zapRelease = new ZapRelease(version, new URL(config.getString("core/" + platform.name() + "/url")), config.getString("core/" + platform.name() + "/file"), config.getLong("core/" + platform.name() + "/size"), config.getString("core/relnotes"), relUrl, config.getString("core/" + platform.name() + "/hash"));
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
    try {
        // And then load the addons
        String[] addOnIds = config.getStringArray("addon");
        for (String id : addOnIds) {
            logger.debug("Found addon " + id);
            AddOn ao;
            try {
                ao = new AddOn(id, downloadDir, config.configurationAt("addon_" + id));
                ao.setInstallationStatus(AddOn.InstallationStatus.AVAILABLE);
            } catch (Exception e) {
                logger.warn("Failed to create add-on for " + id, e);
                continue;
            }
            if (ao.canLoadInCurrentVersion()) {
                // Ignore ones that dont apply to this version
                this.addOns.add(ao);
            } else {
                logger.debug("Ignoring addon " + ao.getName() + " cant load in this version");
            }
        }
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : XPathExpressionEngine(org.apache.commons.configuration.tree.xpath.XPathExpressionEngine) URL(java.net.URL)

Example 2 with XPathExpressionEngine

use of org.apache.commons.configuration.tree.xpath.XPathExpressionEngine in project zaproxy by zaproxy.

the class AddOnUnitTest method createZapVersionsXml.

private static ZapXmlConfiguration createZapVersionsXml() throws Exception {
    ZapXmlConfiguration zapVersionsXml = new ZapXmlConfiguration(ZAP_VERSIONS_XML);
    zapVersionsXml.setExpressionEngine(new XPathExpressionEngine());
    return zapVersionsXml;
}
Also used : ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) XPathExpressionEngine(org.apache.commons.configuration.tree.xpath.XPathExpressionEngine)

Aggregations

XPathExpressionEngine (org.apache.commons.configuration.tree.xpath.XPathExpressionEngine)2 URL (java.net.URL)1 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)1