Exploit database

GH-8e79ba761eba863eb3784aeaf7f9667d

sj/spring-data-rest-cve-2017-8046

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2017-8046

13 sources

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

Repository files24

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

spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/support/PersistentEntityResourceProcessor.java

Java · 2,161 bytes
package org.springframework.data.rest.webmvc.support;

import static org.springframework.util.ClassUtils.*;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.support.Repositories;
import org.springframework.data.rest.webmvc.PersistentEntityResource;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.hateoas.Resource;
import org.springframework.hateoas.ResourceProcessor;

/**
 * @author Jon Brisbin
 */
public class PersistentEntityResourceProcessor implements ResourceProcessor<PersistentEntityResource> {

	private final List<DomainTypeResourceProcessor> resourceProcessors = new ArrayList<DomainTypeResourceProcessor>();

	@Autowired
	public PersistentEntityResourceProcessor(Repositories repositories,
			List<ResourceProcessor<Resource<?>>> resourceProcessors) {
		if (null != resourceProcessors) {
			for (ResourceProcessor<Resource<?>> rp : resourceProcessors) {
				TypeInformation<?> typeInfo = ClassTypeInformation.from(rp.getClass());
				TypeInformation<?> domainType = typeInfo.getTypeArguments().get(0);
				if (null != repositories.getPersistentEntity(domainType.getType())) {
					this.resourceProcessors.add(new DomainTypeResourceProcessor(domainType.getType(), rp));
				}
			}
		}
	}

	@Override
	public PersistentEntityResource process(PersistentEntityResource resource) {

		Object content = resource.getContent();

		if (null == content) {
			return resource;
		}

		Class<?> domainType = content.getClass();
		for (DomainTypeResourceProcessor rp : resourceProcessors) {
			if (isAssignable(domainType, rp.domainType)) {
				rp.resourceProcessor.process(resource);
			}
		}

		return resource;
	}

	private static class DomainTypeResourceProcessor {
		final Class<?> domainType;
		final ResourceProcessor<Resource<?>> resourceProcessor;

		private DomainTypeResourceProcessor(Class<?> domainType, ResourceProcessor<Resource<?>> resourceProcessor) {
			this.domainType = domainType;
			this.resourceProcessor = resourceProcessor;
		}
	}

}