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 files6

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

extension/csw/api/src/main/java/org/geoserver/csw/feature/sort/ComplexComparatorFactory.java

Java · 2,720 bytes
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
 * (c) 2001 - 2013 OpenPlans
 * This code is licensed under the GPL 2.0 license, available at the root
 * application directory.
 */
package org.geoserver.csw.feature.sort;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import org.opengis.feature.Feature;
import org.opengis.filter.sort.SortBy;
import org.opengis.filter.sort.SortOrder;

/**
 * Builds comparators against complex features based on {@link SortBy} definitions
 *
 * @author Andrea Aime - GeoSolutions
 */
public class ComplexComparatorFactory {

    /**
     * Builds a composite comparator matching the specified sortBy array
     *
     * <ul>
     *   <li>{@link SortBy#NATURAL_ORDER}: sort by feature id (acceding)
     *   <li>{@link SortBy#REVERSE_ORDER}: sort by feature id (descending)
     *   <li>sort by supplied property name, and sort order
     * </ul>
     *
     * @param sortBy sort order (defined in order of precidence)
     */
    public static Comparator<Feature> buildComparator(SortBy... sortBy) {
        if (sortBy.length == 0) {
            throw new IllegalArgumentException(
                    "No way to build comparators out of an empty comparator set");
        }

        if (sortBy.length == 1) {
            return buildComparator(sortBy[0]);
        } else {
            List<Comparator<Feature>> comparators = new ArrayList<>();
            for (SortBy curr : sortBy) {
                Comparator<Feature> comparator = buildComparator(curr);
                comparators.add(comparator);
            }

            return new CompositeComparator<>(comparators);
        }
    }

    /**
     * Builds a single comparator based on the sortBy specification.
     *
     * <ul>
     *   <li>{@link SortBy#NATURAL_ORDER}: sort by feature id (acceding)
     *   <li>{@link SortBy#REVERSE_ORDER}: sort by feature id (descending)
     *   <li>sort by supplied property name, and sort order
     * </ul>
     *
     * @param sortBy indication of sort order
     * @return Comparator used to determine sort order
     */
    public static Comparator<Feature> buildComparator(SortBy sortBy) {
        if (sortBy == null) {
            throw new NullPointerException(
                    "The sortBy argument must be not null (consider SortBy.UNSORTED)");
        }

        if (sortBy == SortBy.NATURAL_ORDER) {
            return new FidComparator(true);
        } else if (sortBy == SortBy.REVERSE_ORDER) {
            return new FidComparator(false);
        } else {
            return new PropertyComparator<>(
                    sortBy.getPropertyName(), sortBy.getSortOrder() == SortOrder.ASCENDING);
        }
    }
}