Exploit database

GH-9a017fa45abc7e1f8f6ba6e1285cae54

iplayforsg/cve-2023-51444

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-51444

1 source

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.

Repository files87Next files →

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

main/src/main/java/org/geoserver/catalog/SLDNamedLayerValidator.java

Java · 2,322 bytes
/* (c) 2017 Open Source Geospatial Foundation - all rights reserved
 * This code is licensed under the GPL 2.0 license, available at the root
 * application directory.
 */
package org.geoserver.catalog;

import java.util.ArrayList;
import java.util.List;
import org.geotools.styling.NamedStyle;
import org.geotools.styling.StyledLayer;
import org.geotools.styling.StyledLayerDescriptor;
import org.opengis.referencing.crs.CoordinateReferenceSystem;

/** GeoServerSLDVisitor for collecting assorted validation errors and reporting them */
public class SLDNamedLayerValidator extends GeoServerSLDVisitorAdapter {

    public List<Exception> validationErrors = new ArrayList<>();

    public SLDNamedLayerValidator(Catalog catalog, CoordinateReferenceSystem fallbackCrs) {
        super(catalog, fallbackCrs);
    }

    public List<Exception> getValidationErrors() {
        return validationErrors;
    }

    @Override
    public void visit(StyledLayerDescriptor sld) {
        try {
            super.visit(sld);
        } catch (Exception e) {
            validationErrors.add(e);
        }
    }

    @Override
    public PublishedInfo visitNamedLayerInternal(StyledLayer namedLayer) {
        PublishedInfo p = catalog.getLayerGroupByName(namedLayer.getName());
        if (p == null) {
            p = catalog.getLayerByName(namedLayer.getName());
        }
        if (p == null) {
            validationErrors.add(
                    new Exception(
                            "No layer or layer group named '"
                                    + namedLayer.getName()
                                    + "' found in the catalog"));
        }
        return p;
    }

    @Override
    public StyleInfo visitNamedStyleInternal(NamedStyle namedStyle) {
        StyleInfo s = catalog.getStyleByName(namedStyle.getName());
        if (s == null) {
            validationErrors.add(
                    new Exception(
                            "No style named '" + namedStyle.getName() + "' found in the catalog"));
        }
        return s;
    }

    public static List<Exception> validate(Catalog catalog, StyledLayerDescriptor sld) {
        SLDNamedLayerValidator validator = new SLDNamedLayerValidator(catalog, null);
        sld.accept(validator);
        return validator.getValidationErrors();
    }
}