Skip to content

Commit a2d516d

Browse files
committed
Replace "whitelist" with alternative words
1 parent 4c29bbb commit a2d516d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

spring-core/src/main/java/org/springframework/core/ReactiveAdapterRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ void registerAdapters(ReactiveAdapterRegistry registry) {
361361

362362
/**
363363
* {@code BlockHoundIntegration} for spring-core classes.
364-
* <p>Whitelists the following:
364+
* <p>Explicitly allow the following:
365365
* <ul>
366366
* <li>Reading class info via {@link LocalVariableTableParameterNameDiscoverer}.
367367
* <li>Locking within {@link ConcurrentReferenceHashMap}.

spring-web/src/main/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBean.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public void setFavorPathExtension(boolean favorPathExtension) {
178178
* {@code ResourceHttpRequestHandler}.
179179
* <li>Determine the media type of views rendered with
180180
* {@code ContentNegotiatingViewResolver}.
181-
* <li>Whitelist extensions for RFD attack detection (check the Spring
181+
* <li>List safe extensions for RFD attack detection (check the Spring
182182
* Framework reference docs for details).
183183
* </ul>
184184
* @param mediaTypes media type mappings

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ public ContentNegotiationConfigurer favorPathExtension(boolean favorPathExtensio
146146
* Add a mapping from a key, extracted from a path extension or a query
147147
* parameter, to a MediaType. This is required in order for the parameter
148148
* strategy to work. Any extensions explicitly registered here are also
149-
* whitelisted for the purpose of Reflected File Download attack detection
150-
* (see Spring Framework reference documentation for more details on RFD
151-
* attack protection).
149+
* treated as safe for the purpose of Reflected File Download attack
150+
* detection (see Spring Framework reference documentation for more details
151+
* on RFD attack protection).
152152
* <p>The path extension strategy will also try to use
153153
* {@link ServletContext#getMimeType} and {@link MediaTypeFactory} to resolve path
154154
* extensions. To change this behavior see the {@link #useRegisteredExtensionsOnly} property.

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/AbstractMessageConverterMethodProcessor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe
7676
implements HandlerMethodReturnValueHandler {
7777

7878
/* Extensions associated with the built-in message converters */
79-
private static final Set<String> WHITELISTED_EXTENSIONS = new HashSet<>(Arrays.asList(
79+
private static final Set<String> SAFE_EXTENSIONS = new HashSet<>(Arrays.asList(
8080
"txt", "text", "yml", "properties", "csv",
8181
"json", "xml", "atom", "rss",
8282
"png", "jpe", "jpeg", "jpg", "gif", "wbmp", "bmp"));
8383

84-
private static final Set<String> WHITELISTED_MEDIA_BASE_TYPES = new HashSet<>(
84+
private static final Set<String> SAFE_MEDIA_BASE_TYPES = new HashSet<>(
8585
Arrays.asList("audio", "image", "video"));
8686

8787
private static final List<MediaType> ALL_APPLICATION_MEDIA_TYPES =
@@ -133,7 +133,7 @@ protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>>
133133

134134
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager());
135135
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions());
136-
this.safeExtensions.addAll(WHITELISTED_EXTENSIONS);
136+
this.safeExtensions.addAll(SAFE_EXTENSIONS);
137137
}
138138

139139

@@ -406,8 +406,8 @@ private MediaType getMostSpecificMediaType(MediaType acceptType, MediaType produ
406406
}
407407

408408
/**
409-
* Check if the path has a file extension and whether the extension is
410-
* either {@link #WHITELISTED_EXTENSIONS whitelisted} or explicitly
409+
* Check if the path has a file extension and whether the extension is either
410+
* on the list of {@link #SAFE_EXTENSIONS safe extensions} or explicitly
411411
* {@link ContentNegotiationManager#getAllFileExtensions() registered}.
412412
* If not, and the status is in the 2xx range, a 'Content-Disposition'
413413
* header with a safe attachment file name ("f.txt") is added to prevent
@@ -491,7 +491,7 @@ private MediaType resolveMediaType(ServletRequest request, String extension) {
491491
}
492492

493493
private boolean safeMediaType(MediaType mediaType) {
494-
return (WHITELISTED_MEDIA_BASE_TYPES.contains(mediaType.getType()) ||
494+
return (SAFE_MEDIA_BASE_TYPES.contains(mediaType.getType()) ||
495495
mediaType.getSubtype().endsWith("+xml"));
496496
}
497497

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,15 @@ public void addContentDispositionHeader() throws Exception {
380380
Collections.singletonList(new StringHttpMessageConverter()),
381381
factory.getObject());
382382

383-
assertContentDisposition(processor, false, "/hello.json", "whitelisted extension");
383+
assertContentDisposition(processor, false, "/hello.json", "safe extension");
384384
assertContentDisposition(processor, false, "/hello.pdf", "registered extension");
385385
assertContentDisposition(processor, true, "/hello.dataless", "unknown extension");
386386

387387
// path parameters
388388
assertContentDisposition(processor, false, "/hello.json;a=b", "path param shouldn't cause issue");
389389
assertContentDisposition(processor, true, "/hello.json;a=b;setup.dataless", "unknown ext in path params");
390390
assertContentDisposition(processor, true, "/hello.dataless;a=b;setup.json", "unknown ext in filename");
391-
assertContentDisposition(processor, false, "/hello.json;a=b;setup.json", "whitelisted extensions");
391+
assertContentDisposition(processor, false, "/hello.json;a=b;setup.json", "safe extensions");
392392

393393
// encoded dot
394394
assertContentDisposition(processor, true, "/hello%2Edataless;a=b;setup.json", "encoded dot in filename");

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,11 +1737,11 @@ lower the risk but are not sufficient to prevent RFD attacks.
17371737

17381738
To prevent RFD attacks, prior to rendering the response body, Spring MVC adds a
17391739
`Content-Disposition:inline;filename=f.txt` header to suggest a fixed and safe download
1740-
file. This is done only if the URL path contains a file extension that is neither whitelisted
1741-
nor explicitly registered for content negotiation. However, it can potentially have
1742-
side effects when URLs are typed directly into a browser.
1740+
file. This is done only if the URL path contains a file extension that is neither
1741+
allowed as safe nor explicitly registered for content negotiation. However, it can
1742+
potentially have side effects when URLs are typed directly into a browser.
17431743

1744-
Many common path extensions are whitelisted by default. Applications with custom
1744+
Many common path extensions are allowed as safe by default. Applications with custom
17451745
`HttpMessageConverter` implementations can explicitly register file extensions for content
17461746
negotiation to avoid having a `Content-Disposition` header added for those extensions.
17471747
See <<mvc-config-content-negotiation>>.

0 commit comments

Comments
 (0)