Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed script name verification #740

Merged
merged 1 commit into from
Feb 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ Browse the Jenkins issue tracker to see any [open issues](https://issues.jenkins
* Fixed support for the
[Static Code Analysis Plugins](https://wiki.jenkins-ci.org/display/JENKINS/Static+Code+Analysis+Plug-ins)
([#724](https://github.com/jenkinsci/job-dsl-plugin/pull/724))
* Fixed support for scripts in directories when using the command line runner
([#740](https://github.com/jenkinsci/job-dsl-plugin/pull/740))
* Built-in support for the
[GitHub Pull Request Builder Plugin](https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin)
is deprecated, see [Migration](Migration#migrating-to-143)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ class DslScriptLoader {
}

private static boolean isValidScriptName(String scriptFile) {
int idx = scriptFile.lastIndexOf('.')
String normalizedName = idx > -1 ? scriptFile[0..idx - 1] : scriptFile
String fileName = new File(scriptFile).name
int idx = fileName.lastIndexOf('.')
String normalizedName = idx > -1 ? fileName[0..idx - 1] : fileName
if (normalizedName.length() == 0 || !Character.isJavaIdentifierStart(normalizedName.charAt(0))) {
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,17 @@ folder('folder-b') {
e.message =~ /test-script\.dsl/
}

def 'script in directory'() {
setup:
ScriptRequest request = new ScriptRequest('foo/test.dsl', null, resourcesDir, false)

when:
DslScriptLoader.runDslEngine(request, jm)

then:
noExceptionThrown()
}

def 'script with method'() {
setup:
ScriptRequest request = new ScriptRequest(
Expand Down
2 changes: 2 additions & 0 deletions job-dsl-core/src/test/resources/foo/test.dsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
job('test') {
}