Commit Graph
65 Commits
Author SHA1 Message Date
Josh Soref acc2da063e [SECURITY-904] Fold tests back into normal files 2019-03-21 11:29:20 -04:00
Matt Sicker a489cc4ee7 Move Windows util code into test sources
Signed-off-by: Matt Sicker <boards@gmail.com>
2019-01-11 15:35:02 -06:00
Matt Sicker c35f3ba75c Add more tests for JENKINS-55448
This also refactors some test calls to mklink into a package-private Util method due to additional tests needing to create junction points.

Signed-off-by: Matt Sicker <boards@gmail.com>
2019-01-11 10:35:57 -06:00
Daniel Beck e992e1153b Merge commit '7250d8b875366ae90fa6aec13b5a5c86720e23a3' into security-master 2018-05-07 14:12:09 +02:00
Matt Sicker e229f37dd9 JENKINS-13128: Preserve copied file permissions and mtime (#3400)
* JENKINS-13128: Preserve copied file permissions and mtime

This fixes a bug where files copied locally do not preserve file permissions or last modification time.

* Use IO utility methods for exception handling

* Fix invalid path exception propagation

* Revert hudson.Util
2018-05-04 15:36:33 -04:00
Daniel Beck 7e6c0637b1 Merge branch 'security-stable-2.89' into security-stable-2.107 2018-04-26 01:20:01 +02:00
Wadeck Follonier 5cf0a77d44 [SECURITY-788] 2018-04-25 23:42:19 +02:00
Larry Singleton 8e78ab1c66 [JENKINS-48227] Use "Files.createTempDirectory" to create temp directory (#3161)
* Use "Files.createTempDirectory" to create temp directory instead
See SonarQube critical vulnerability squid:S2976 (tag: owasp-a9)
https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3AS2976

* [JENKINS-48227]
Creating a utility "static Path toPath(File file) throws IOException" method,
which wraps InvalidPathException to IOException so that it will be checked.
- also fixed public static final reference
- fixed broken test cases
- added new test cases for toPath() and createTempDir()

* Revert back to public static int

* adjustments due to merges

* Add posix check to determine if Posix FileAttributes should be included
in call to Files.createTempDirectory()

* Remove reference to private element

* Updated to use explicit imports
2017-12-22 17:38:57 +01:00
Devin Nusbaum fdccc0e838 [JENKINS-36088] Use NIO implementations of chmod and mode by default (#3135)
* Use NIO for FilePath#chmod and IOUtils#mode

* Add tests for NIO mode and chmod implementations

* Add test, remove new method, and update JavaDoc

* Provide system property to use native implementations of chmod and mode

* Revert unrelated whitespace modification

* Don't remove exception from throws and put imports in original location

* Fix broken JavaDoc links

* Ignore file type bits (above 0o7777) in Util#modeToPermission

* Use octal for constants and don't include file type bits

* Revert unnecessary changes to TarArchiverTest

* Add assertion that non-permission bits are ignored by chmod

* Use NIO copy with StandardCopyOption.COPY_ATTRIBUTES in copyToWithPermissions where possible

* Catch InvalidPathException and convert it to IOException

* Create utility method for File#toPath and use File#createDirectories after review

* Remove useless calls to toAbsolutePath and getAbsoluteFile

* Fix typos and use octal for constant after review

* Add test for behavior of copyToWithPermission with special bits
2017-12-01 10:01:34 +03:00
Devin Nusbaum 52fa4d90b9 [JENKINS-39179] [JENKINS-36088] Always use NIO to create and detect symbolic links and Windows junctions (#3133)
* Always use NIO to detect symlinks

* Make assertion failure message consistent

* Catch NoSuchFileException to keep tests passing

* Make method name more specific and simlify assumption

* Remove obsolete comment and reword the main comment in isSymlink

* Deprecate Kernel32Util#isJunctionOrSymlink

* Use assumptions for junction creation and add messages to assumptions

* Replace deprecated code with recommended alternative

* Add comment explaining call to DosFileAttributes#isOther

* Do not fall back to native code when creating symlinks

* Log FileSystemExceptions when creating symbolic links

* Catch InvalidPathException and rethrow as IOException

* Deprecate Kernel32Utils#createSymbolicLink and #getWin32FileAttributes

* Preserve original logging behavior on Windows and remove useless call to Util#displayIOException
2017-11-16 17:08:10 +01:00
Stephen Connolly f0cd7ae8ff [JENKINS-42934] Avoid using new FileInputStream / new FileOutputStream 2017-03-20 12:50:46 +00:00
Vincent Latombe 0c16c8576b [JENKINS-23507] Make FilePath.installIfNecessaryFrom follow redirects (#2331) 2016-05-13 12:36:45 +02:00
Craig Rodrigues 0611d0788a Remove use of '<' and '>' which cause javadoc errors
Tested with Java 8 and "mvn javadoc:test-javadoc".  Eliminates errors such as:

    [ERROR] java/hudson/os/DCOMSandbox.java:18: error: bad use of '>'
2016-04-06 15:52:04 -07:00
Oleg Nenashev 858849ef42 Noting JENKINS-5253 from https://github.com/jenkinsci/jenkins/pull/1429 2015-10-17 22:26:12 +03:00
Oleg Nenashev 4fd10ed723 Merge pull request #1429 from dominiquebrice/jenkins-5253b
[JENKINS-5253] Allow case insensitive patterns in Artifacts Archiving
2015-10-17 22:15:52 +03:00
Oliver Gondža 3990384257 Do not skip tests silently 2015-10-01 08:58:31 +02:00
Kanstantsin Shautsou bfa6d8be0c Remove hardcode in tar test 2015-08-25 01:09:09 +03:00
Kanstantsin Shautsou 3e187a0264 [FIXED JENKINS-10629] Unbroke stream with new tar implementation.
Causes bytes lost and truncated tar archive.
TarBuffer not used in TarArchiveOutputStream.
2015-08-25 01:09:09 +03:00
Oleg Nenashev 32dca8819c [JENKINS-10629] - Direct unit test for the issue
This test also introduces additional round-trip tests for small files
2015-04-14 18:59:38 +03:00
Dominique 40382c5fc4 [JENKINS-5253] Allow case insensitive patterns in Artifacts Archiving 2015-01-31 19:39:10 -05:00
René Scheibe bd1d6251e0 replace all deprecated @Bug annotations with @Issue 2015-01-07 17:12:21 +01:00
Jesse Glick 1fcee97d2f [FIXED JENKINS-26196] More robust handling of server errors in FilePath.installIfNecessaryFrom. 2014-12-29 14:49:27 -05:00
Jesse Glick babfb832a3 JUnit 4. 2014-12-29 14:00:48 -05:00
Jesse Glick 534328b264 [FIXED JENKINS-25759] Avoid consuming too much memory while running validateAntFileMask.
Not fully solved, since the scannedDirs field can still grow to be large, but at least clearing files/dirsNotIncluded.
Also imposing a 5s timeout on the scan regardless of file count, and defining a user-customizable bound.
2014-11-24 10:37:58 -05:00
Kohsuke Kawaguchi d5c368dd8e Merge branch 'pull-714' 2014-04-19 18:31:09 -07:00
Kohsuke Kawaguchi 1f55b80f18 fixed a test regression 2014-04-03 21:05:31 -07:00
Jesse Glick 15ac490af1 Now that we use Java 6, can finally deprecate IOException2. 2013-11-15 08:19:59 -05:00
Jesse Glick 574fe1409e [FIXED JENKINS-9540] Failure of recursive copy on slave side should be reported.
Instead it was being thrown in a Future that the master did not wait for:
the writing side failed with a closed pipe exception, and this meaningless error was thrown up.
Fixing by waiting for the reading side first, so any error there will be thrown up.
(If there was _also_ an error on the writing side, we would miss it, but typically this will just be the closed stream.)
2013-08-29 16:13:48 -04:00
Jesse Glick b1c82f1e30 stephenc asks to use TODO rather than XXX 2013-06-10 11:53:13 -04:00
kkkon 8a9e1ab59f [FIXED JENKINS-16846] fix logic and add test
FilePath#moveAllChildrenTo faild,
when same name directory exist.

change Void to void, recursive_invoke is internal helper function.

thanks review by jglick
2013-02-21 19:30:36 +09:00
Lars Hvile 35f7653b7b [JENKINS-16215] Avoiding unnecessary downloads in FilePath.installIfNecessaryFrom.
The updated version uses the locally cached timestamp, '.timestamp', to set the
'If-Modified-Since' header. 304 Not Modified responses are dealt with by
aborting the installation.
2012-12-28 14:43:41 +01:00
Erik Lindblad f66e19c072 JENKINS-15418 take shares int account, ignore short paths 2012-10-25 17:18:07 +02:00
Jesse Glick a885cc2179 [FIXED JENKINS-7214] FilePath.validateAntFileMask too slow for /configure. 2012-09-19 16:43:20 -04:00
Jesse Glick 347bca5e5a testValidateAntFileMask 2012-09-19 16:03:26 -04:00
Christoph Kutzinski c27918fefe More test refactoring to make test more readable - at least IMHO 2012-08-26 23:48:28 +02:00
Christoph Kutzinski 8a0e13813f minor test refactoring 2012-08-26 23:26:47 +02:00
bap2000 9d8f300179 Enable ant default excludes to be turned off.
Add a new overload method to list files that include the files that ant excludes by default.
2012-05-14 16:01:42 -07:00
David Reiss e15b2e19e3 [FIXED JENKINS-13202] Don't set mtime or mode on symlinks
Previously, the untar code tries to set the last modified time and mode
on every untarred file.  However, if the tar contains a broken symlink,
or a symlink that points to a file that has not been untarred yet, the
time/mode setting would fail on the broken symlink.

Symlinks don't have meaningful modified times or modes of their own, so
only set these values on non-symlinks.

Rename the file "a" in the test to expose the bug.
2012-05-08 14:52:52 -07:00
Stephen Connolly 71debc2b89 [JENKINS-13649] Adding a test case 2012-05-01 09:39:05 +01:00
Kohsuke Kawaguchi d184d53b24 [JENKINS-9118]
Tar/untar now correctly supports symlinks.
2012-03-09 18:26:22 -08:00
Christoph Kutzinski b4fe626f73 [JENKINS-11073] don't fail copyToWithPermissions if setting last-modified fails on Windows (more reliable detection of Windows platforms than before) 2011-12-30 16:51:32 +01:00
Christoph Kutzinski 8755e59c9a [FIXED JENKINS-11073] handle failure to set timestamp on Windows platforms more gracefully - this time hopefully for real 2011-11-23 20:28:51 +01:00
Christoph Kutzinski 0ccc076b40 fixed some compiler warnings 2011-07-24 10:38:52 +02:00
Kohsuke Kawaguchi 3614868694 Merge branch 'oss'
Conflicts:
	core/src/main/java/hudson/Functions.java
	core/src/main/java/hudson/model/AutoCompletionCandidates.java
	core/src/main/java/hudson/model/ViewDescriptor.java
	core/src/main/resources/lib/hudson/3rdPartyLicenses.jelly
	core/src/main/resources/lib/hudson/newFromList/form.jelly
	core/src/main/resources/lib/hudson/projectViewRow.jelly
	core/src/main/resources/lib/hudson/thirdPartyLicenses.jelly
	core/src/main/resources/lib/layout/renderOnDemand.jelly
	core/src/test/java/hudson/FilePathTest.java
	test/src/test/resources/lib/layout/RenderOnDemandTest/testBehaviour.jelly
	test/src/test/resources/scripts/BehaviorTest/testCssSelectors.jelly
	ui-samples-plugin/src/main/resources/hudson/plugins/ui_samples/JavaScriptProxy/index.jelly
2011-04-21 15:37:31 -07:00
Kohsuke Kawaguchi 957ffd3009 [FIXED JENKINS-7871] Fixed a race condition in FilePath.copyTo
that results in missing tail bits when the master is heavily loaded.
2011-04-21 13:39:48 -07:00
bap2000 5cbe17973b Add method to list with excludes 2011-04-10 14:29:55 +01:00
Kohsuke Kawaguchi c3fc09939c [FIXED JENKINS-7871] Fixed a race condition in FilePath.copyTo
that results in missing tail bits when the master is heavily loaded.
2011-03-14 13:31:58 -07:00
mindless ed81cd5f54 [FIXED HUDSON-6494] fix FilePath.getParent() so parent of /foo is /
(not "."), and handle edge case so path with no parent ("/" or "abc")
returns null instead of getting IndexOutOfBoundsException.
(returning null is consistent with File.getParentFile())


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30917 71c3de6d-444a-0410-be80-ed276b4c234a
2010-05-11 17:04:38 +00:00
mindless ae837cecf4 [FIXED HUDSON-5951] improve normalization of ".." in FilePath
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30462 71c3de6d-444a-0410-be80-ed276b4c234a
2010-04-29 07:35:22 +00:00
mindless 5ad11a0dbc [FIXED HUDSON-6332] for 1.357
Add setOverwrite(true) for local->local copy in FilePath.copyRecursiveTo().
This makes it consistent with master/slave copy (either direction),
and also avoids returning 0 if all files already have current/newer timestamp
which some code (javadoc publishing, copyartifact plugin) would interpret as
copy failure or no matching files found.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@30450 71c3de6d-444a-0410-be80-ed276b4c234a
2010-04-27 23:53:41 +00:00