Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
bfe65c8a
Commit
bfe65c8a
authored
Apr 03, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x' into 2.0.x
parents
03762d5a
0f27b1a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
2 deletions
+25
-2
ProjectGenerator.java
...ringframework/boot/cli/command/init/ProjectGenerator.java
+10
-1
InitCommandTests.java
...ringframework/boot/cli/command/init/InitCommandTests.java
+15
-1
No files found.
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java
View file @
bfe65c8a
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -117,8 +117,17 @@ class ProjectGenerator {
private
void
extractFromStream
(
ZipInputStream
zipStream
,
boolean
overwrite
,
File
outputFolder
)
throws
IOException
{
ZipEntry
entry
=
zipStream
.
getNextEntry
();
String
canonicalOutputPath
=
outputFolder
.
getCanonicalPath
()
+
File
.
separator
;
while
(
entry
!=
null
)
{
File
file
=
new
File
(
outputFolder
,
entry
.
getName
());
String
canonicalEntryPath
=
file
.
getCanonicalPath
();
if
(!
canonicalEntryPath
.
startsWith
(
canonicalOutputPath
))
{
throw
new
ReportableException
(
"Entry '"
+
entry
.
getName
()
+
"' would be written to '"
+
canonicalEntryPath
+
"'. This is outside the output location of '"
+
canonicalOutputPath
+
"'. Verify your target server configuration."
);
}
if
(
file
.
exists
()
&&
!
overwrite
)
{
throw
new
ReportableException
((
file
.
isDirectory
()
?
"Directory"
:
"File"
)
+
" '"
+
file
.
getName
()
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/InitCommandTests.java
View file @
bfe65c8a
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -125,6 +125,20 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
assertThat
(
archiveFile
).
exists
();
}
@Test
public
void
generateProjectAndExtractWillNotWriteEntriesOutsideOutputLocation
()
throws
Exception
{
File
folder
=
this
.
temporaryFolder
.
newFolder
();
byte
[]
archive
=
createFakeZipArchive
(
"../outside.txt"
,
"Fake content"
);
MockHttpProjectGenerationRequest
request
=
new
MockHttpProjectGenerationRequest
(
"application/zip"
,
"demo.zip"
,
archive
);
mockSuccessfulProjectGeneration
(
request
);
assertThat
(
this
.
command
.
run
(
"--extract"
,
folder
.
getAbsolutePath
()))
.
isEqualTo
(
ExitStatus
.
ERROR
);
File
archiveFile
=
new
File
(
folder
.
getParentFile
(),
"outside.txt"
);
assertThat
(
archiveFile
).
doesNotExist
();
}
@Test
public
void
generateProjectAndExtractWithConvention
()
throws
Exception
{
File
folder
=
this
.
temporaryFolder
.
newFolder
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment