@@ -22,9 +22,9 @@
Loading
22 22
23 23
/*
24 24
 * $Id: FileUtil.java,v 1.3 2008-09-09 23:41:42 kfuchsbe Exp $
25 -
 * 
25 +
 *
26 26
 * $Date: 2008-09-09 23:41:42 $ $Revision: 1.3 $ $Author: kfuchsbe $
27 -
 * 
27 +
 *
28 28
 * Copyright CERN, All Rights Reserved.
29 29
 */
30 30
package cern.accsoft.steering.jmad.util;
@@ -36,21 +36,29 @@
Loading
36 36
37 37
/**
38 38
 * This Class provides some methods to simply access output-files
39 -
 * 
39 +
 *
40 40
 * @author Kajetan Fuchsberger (kajetan.fuchsberger at cern.ch)
41 41
 */
42 42
public class TempFileUtilImpl implements TempFileUtil {
43 43
44 -
    /** the name of the dir which is created below the basepath */
44 +
    /**
45 +
     * the name of the dir which is created below the basepath
46 +
     */
45 47
    public static final String TMPDIR_NAME = "jmad-tmp";
46 48
47 -
    /** the logger for the class */
49 +
    /**
50 +
     * the logger for the class
51 +
     */
48 52
    private static final Logger LOGGER = LoggerFactory.getLogger(TempFileUtilImpl.class);
49 53
50 -
    /** the output-path including username and host */
54 +
    /**
55 +
     * the output-path including username and host
56 +
     */
51 57
    private String outputPath = null;
52 58
53 -
    /** The preferences object, to be injected */
59 +
    /**
60 +
     * The preferences object, to be injected
61 +
     */
54 62
    private JMadPreferences preferences;
55 63
56 64
    /**
@@ -62,17 +70,21 @@
Loading
62 70
63 71
    @Override
64 72
    public final File getOutputFile(String relativePath) {
65 -
        return createFile(outputPath + File.separator + relativePath);
73 +
        return createFile(outputPath + File.separator + stripDirectoryTraversal(relativePath));
66 74
    }
67 75
68 76
    @Override
69 77
    public File getOutputDir(String relativePath) {
70 -
        return createDir(outputPath + File.separator + relativePath);
78 +
        return createDir(outputPath + File.separator + stripDirectoryTraversal(relativePath));
71 79
    }
72 80
73 81
    @Override
74 82
    public final File getOutputFile(Object object, String relativePath) {
75 -
        return createFile(getObjectPath(object) + File.separator + relativePath);
83 +
        return createFile(getObjectPath(object) + File.separator + stripDirectoryTraversal(relativePath));
84 +
    }
85 +
86 +
    private static String stripDirectoryTraversal(String relativePath) {
87 +
        return relativePath.replace("../", "/");
76 88
    }
77 89
78 90
    @Override
@@ -93,7 +105,7 @@
Loading
93 105
94 106
    /**
95 107
     * creates a file object with the given path and takes care that all dirs up to the file exist.
96 -
     * 
108 +
     *
97 109
     * @param fullPath the full path to the file
98 110
     * @return the file
99 111
     */
@@ -109,7 +121,7 @@
Loading
109 121
110 122
    /**
111 123
     * Creates a file objecte representing the directory of the given path and creates it if it does not exist.
112 -
     * 
124 +
     *
113 125
     * @param fullPath the full path of the directory
114 126
     * @return a file representing the directory
115 127
     */
@@ -121,7 +133,7 @@
Loading
121 133
122 134
    /**
123 135
     * creates the output - dir tree with the correct user - rights
124 -
     * 
136 +
     *
125 137
     * @return the final output - dir
126 138
     */
127 139
    private final String createDirTree() {
Files Complexity Coverage
src/java/cern/accsoft/steering/jmad 42.29% 47.36%
Project Totals (293 files) 42.29% 47.36%
199.2
openjdk11=
TRAVIS_OS_NAME=linux
199.1
TRAVIS_OS_NAME=linux
openjdk8=
200.1
TRAVIS_OS_NAME=linux
openjdk8=
200.2
openjdk11=
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading