Skip to content

Commit c3ce6c4

Browse files
fix: after review
1 parent fc238ad commit c3ce6c4

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

modules/swagger-parser-v3/src/main/java/io/swagger/v3/parser/util/RefUtils.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ public static String buildUrl(String rootPath, String relativePath) {
172172
}
173173
}
174174

175+
/**
176+
* @deprecated - new readExternalRef with PermittedUrlsChecker is preferred because it prevents bypassing security checks
177+
*/
178+
@Deprecated
179+
public static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
180+
Path parentDirectory) {
181+
return readExternalRef(file, refFormat, auths, parentDirectory, null);
182+
}
183+
175184
public static String readExternalRef(String file, RefFormat refFormat, List<AuthorizationValue> auths,
176185
Path parentDirectory, PermittedUrlsChecker permittedUrlsChecker) {
177186

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/RemoteUrlTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ public void testTooManyRedirectsThrowsException() throws Exception {
193193
@Test(expectedExceptions = HostDeniedException.class)
194194
public void testRedirectWithForbiddenProtocolThrowsException() throws Exception {
195195
String nextPath = "/redirect";
196-
// Chain 6 redirects
197196
for (int i = 0; i < 3; i++) {
198197
String target = "/redirect" + (i + 1);
199198
stubFor(get(urlEqualTo(nextPath))
@@ -203,19 +202,14 @@ public void testRedirectWithForbiddenProtocolThrowsException() throws Exception
203202
nextPath = target;
204203
}
205204

206-
// Add stub for /redirect6 to return a 200 OK response, but it's not expected to be reached
205+
// Add stub for /redirect3 to return a 200 OK response, but it's not expected to be reached
207206
stubFor(get(urlEqualTo(nextPath))
208207
.willReturn(aResponse()
209208
.withStatus(200)
210209
.withBody("Final destination")));
211210

212211
String startUrl = String.format("https://%s:%d/redirect", LOCALHOST, WIRE_MOCK_PORT);
213212

214-
try {
215-
RemoteUrl.urlToString(startUrl, null, new PermittedUrlsCheckerAllowLocal());
216-
} catch (IOException e) {
217-
assertTrue(e.getMessage().contains("Too many redirects"));
218-
throw e;
219-
}
213+
RemoteUrl.urlToString(startUrl, null, new PermittedUrlsCheckerAllowLocal());
220214
}
221215
}

0 commit comments

Comments
 (0)