Skip to content

Commit

Permalink
Fixed spotbugs PATH_TRAVERSAL_IN issue in FileBoolean (#9638)
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Waite <[email protected]>
  • Loading branch information
StefanSpieker and MarkEWaite authored Dec 3, 2024
1 parent 7d65825 commit e994d29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/jenkins/util/io/FileBoolean.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import jenkins.model.Jenkins;
import org.apache.commons.io.FilenameUtils;

/**
* Uses a presence/absence of a file as a persisted boolean storage.
Expand All @@ -29,7 +30,7 @@ public FileBoolean(File file) {
}

public FileBoolean(Class owner, String name) {
this(new File(Jenkins.get().getRootDir(), owner.getName().replace('$', '.') + '/' + name));
this(new File(Jenkins.get().getRootDir(), FilenameUtils.getName(owner.getName().replace('$', '.') + '/' + name)));

Check warning on line 33 in core/src/main/java/jenkins/util/io/FileBoolean.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 33 is not covered by tests
}

/**
Expand Down
1 change: 0 additions & 1 deletion core/src/spotbugs/excludesFilter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@
<Class name="jenkins.slaves.restarter.UnixSlaveRestarter"/>
<Class name="jenkins.SoloFilePathFilter"/>
<Class name="jenkins.util.groovy.GroovyHookScript"/>
<Class name="jenkins.util.io.FileBoolean"/>
<Class name="jenkins.util.JavaVMArguments"/>
<Class name="jenkins.util.SystemProperties"/>
<Class name="jenkins.util.VirtualFile$FilePathVF"/>
Expand Down

0 comments on commit e994d29

Please sign in to comment.