Package org.ow2.clif.jenkins.jobs
Class Zip
- java.lang.Object
-
- org.ow2.clif.jenkins.jobs.Zip
-
public class Zip extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
basedir()
Zip
delete()
List<String>
entries()
syntactic sugar for all entries (entries(null))List<String>
entries(String pattern)
returns entry names of zip, matching given pattern if providedZip
extractTo(File dir)
unzips to directoryZip
extractTo(String dir)
File
getFile()
String
id()
Path
sanitize(Path entry)
Protection against malicious zip entries that could contain ..
-
-
-
Method Detail
-
getFile
public File getFile()
-
id
public String id()
-
sanitize
public Path sanitize(@Nonnull Path entry)
Protection against malicious zip entries that could contain .. path elements or possibly an absolute path. An absolute path is turned relative by discarding the root element. Then the path is normalized (discard . and resolve .. path elements). Finally, all occurrences of .. path elements are merely discarded.- Parameters:
entry
- a path- Returns:
- a sanitized version of the given path
-
entries
public List<String> entries(String pattern) throws IOException
returns entry names of zip, matching given pattern if provided- Parameters:
pattern
- a Java regular expression as a string- Returns:
- the list of entries matching the given pattern
- Throws:
IOException
- the zip archive could not be correctly unzipped
-
entries
public List<String> entries() throws IOException
syntactic sugar for all entries (entries(null))- Returns:
- all zip entries as a list
- Throws:
IOException
- the zip archive could not be correctly unzipped
-
basedir
public String basedir() throws IOException
- Returns:
- the first entry name if directory, or empty string otherwise
- Throws:
IOException
- the zip archive could not be correctly unzipped
-
extractTo
public Zip extractTo(String dir) throws IOException
- Throws:
IOException
-
extractTo
public Zip extractTo(File dir) throws IOException
unzips to directory- Parameters:
dir
- the target directory- Returns:
- this Zip object
- Throws:
IOException
- the zip archive could not be correctly unzipped
-
delete
public Zip delete()
-
-