Skip to content

Commit 8743a2f

Browse files
committed
Selectively encode entities in splices into xml
Don't want to encode in ~/.credentials, but do in any xml file. Should do it wholesale... TODO: wrap `xmlSafe` around everything that's spliced into xml
1 parent 503c649 commit 8743a2f

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

libraries/job_blurbs.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ def stdRefSpec
88
"+refs/heads/*:refs/remotes/${repo_user}/* +refs/pull/*/head:refs/remotes/${repo_user}/pr/*/head"
99
end
1010

11+
def xmlSafe(str)
12+
CGI.escapeHTML(str)
13+
end
14+
1115
def properties(repoUser, repoName, repoRef, params)
1216
stringPar =
1317
"""
@@ -52,12 +56,12 @@ def flowProject(options = {})
5256
buildNameScript = options.fetch(:buildNameScript, setBuildNameScript)
5357

5458
<<-EOX
55-
<description>#{CGI.escapeHTML(description)}</description>
59+
<description>#{xmlSafe(description)}</description>
5660
#{properties(repoUser, repoName, repoRef, params)}
5761
<scm class="hudson.scm.NullSCM"/>
5862
<canRoam>true</canRoam>
5963
<concurrentBuild>#{concurrent}</concurrentBuild>
60-
<dsl>#{CGI.escapeHTML(buildNameScript+"\n\n"+dsl)}</dsl>
64+
<dsl>#{xmlSafe(buildNameScript+"\n\n"+dsl)}</dsl>
6165
EOX
6266
end
6367

@@ -95,10 +99,10 @@ def env(name)
9599
end
96100

97101
<<-EOX
98-
<description>#{CGI.escapeHTML(description)}</description>
102+
<description>#{xmlSafe(description)}</description>
99103
#{properties(repoUser, repoName, repoRef, params)}
100104
#{scmBlurb(refspec)}
101-
#{restriction % {nodes: CGI.escapeHTML(nodeRestriction)} if nodeRestriction}
105+
#{restriction % {nodes: xmlSafe(nodeRestriction)} if nodeRestriction}
102106
<concurrentBuild>#{concurrent}</concurrentBuild>
103107
<builders>
104108
#{groovySysScript(buildNameScript)}
@@ -200,7 +204,7 @@ def groovySysScript(script)
200204
<<-EOH.gsub(/^ /, '')
201205
<hudson.plugins.groovy.SystemGroovy plugin="groovy">
202206
<scriptSource class="hudson.plugins.groovy.StringScriptSource">
203-
<command>#{CGI.escapeHTML(script)}</command>
207+
<command>#{xmlSafe(script)}</command>
204208
</scriptSource>
205209
</hudson.plugins.groovy.SystemGroovy>
206210
EOH

recipes/_worker-config-debian.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,12 @@
7272
variables({
7373
:sonatypePass => chef_vault_item("worker-publish", "sonatype")['pass'],
7474
:sonatypeUser => chef_vault_item("worker-publish", "sonatype")['user'],
75-
:privateRepoPass => CGI.escapeHTML(chef_vault_item("worker-publish", "private-repo")['pass']), # OMG more papercuts
75+
:privateRepoPass => chef_vault_item("worker-publish", "private-repo")['pass'],
7676
:privateRepoUser => chef_vault_item("worker-publish", "private-repo")['user'],
7777
:s3DownloadsPass => chef_vault_item("worker-publish", "s3-downloads")['pass'],
7878
:s3DownloadsUser => chef_vault_item("worker-publish", "s3-downloads")['user']
7979
})
80+
helpers(ScalaJenkinsInfra::JobBlurbs)
8081
end
8182
end
8283

recipes/_worker-config-rhel.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@
2727
sensitive true
2828

2929
variables({
30-
:privateRepoPass => CGI.escapeHTML(chef_vault_item("worker", "private-repo-public-jobs")['pass']),
30+
:privateRepoPass => chef_vault_item("worker", "private-repo-public-jobs")['pass'],
3131
:privateRepoUser => chef_vault_item("worker", "private-repo-public-jobs")['user']
3232
})
33+
helpers(ScalaJenkinsInfra::JobBlurbs)
3334
end
3435
end
3536
end

templates/default/m2-settings-public-jobs.xml.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<server>
1313
<id>pr-scala</id>
1414
<username><%= @privateRepoUser %></username>
15-
<password><%= @privateRepoPass %></password>
15+
<password><%= xmlSafe(@privateRepoPass) %></password>
1616
</server>
1717
</servers>
1818

@@ -27,7 +27,7 @@
2727
</repository>
2828
<repository>
2929
<id>scala-release-temp</id>
30-
<name>Scala Relese snapshots</name>
30+
<name>Scala Release snapshots</name>
3131
<url><%=node['repos']['private']['release-temp']%></url>
3232
</repository>
3333
</repositories>

templates/default/m2-settings.xml.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<server>
1818
<id>private-repo</id>
1919
<username><%= @privateRepoUser %></username>
20-
<password><%= @privateRepoPass %></password>
20+
<password><%= xmlSafe(@privateRepoPass) %></password>
2121
</server>
2222
<!-- <server>
2323
<id>mirror</id>

0 commit comments

Comments
 (0)