OLD | NEW |
1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
4 # | 4 # |
5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
8 # details. | 8 # details. |
9 # | 9 # |
10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
11 # this program; if not, write to the Free Software Foundation, Inc., 51 | 11 # this program; if not, write to the Free Software Foundation, Inc., 51 |
12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
13 # | 13 # |
14 # Copyright Buildbot Team Members | 14 # Copyright Buildbot Team Members |
15 | 15 |
16 | 16 |
17 from twisted.web import html | 17 from twisted.web import html |
18 from twisted.web.util import Redirect | 18 from twisted.web.util import Redirect |
19 import re, urllib, time | 19 import urllib, time |
20 from twisted.python import log | 20 from twisted.python import log |
21 from twisted.internet import defer | 21 from twisted.internet import defer |
22 from buildbot import interfaces | 22 from buildbot import interfaces |
23 from buildbot.status.web.base import HtmlResource, BuildLineMixin, \ | 23 from buildbot.status.web.base import HtmlResource, BuildLineMixin, \ |
24 path_to_build, path_to_slave, path_to_builder, path_to_change, \ | 24 path_to_build, path_to_slave, path_to_builder, path_to_change, \ |
25 path_to_root, getAndCheckProperties, ICurrentBox, build_get_class, \ | 25 path_to_root, getAndCheckProperties, ICurrentBox, build_get_class, \ |
26 map_branches, path_to_authfail, ActionResource | 26 map_branches, path_to_authfail, ActionResource |
27 | 27 |
28 from buildbot.status.web.build import BuildsResource, StatusResourceBuild | 28 from buildbot.status.web.build import BuildsResource, StatusResourceBuild |
29 from buildbot import util | 29 from buildbot import util |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 # check if this is allowed | 153 # check if this is allowed |
154 if not auth_ok: | 154 if not auth_ok: |
155 if not self.getAuthz(req).actionAllowed('forceBuild', req, self.buil
der_status): | 155 if not self.getAuthz(req).actionAllowed('forceBuild', req, self.buil
der_status): |
156 log.msg("..but not authorized") | 156 log.msg("..but not authorized") |
157 return Redirect(path_to_authfail(req)) | 157 return Redirect(path_to_authfail(req)) |
158 # ensure that they've filled out the username field at least. | 158 # ensure that they've filled out the username field at least. |
159 if name == "<unknown>": | 159 if name == "<unknown>": |
160 log.msg("..but didn't include a username to blame") | 160 log.msg("..but didn't include a username to blame") |
161 return Redirect(path_to_authfail(req)) | 161 return Redirect(path_to_authfail(req)) |
162 | 162 |
| 163 master = self.getBuildmaster(req) |
| 164 |
163 # keep weird stuff out of the branch revision, and property strings. | 165 # keep weird stuff out of the branch revision, and property strings. |
164 # TODO: centralize this somewhere. | 166 branch_validate = master.config.validation['branch'] |
165 if not re.match(r'^[\w.+/~-]*$', branch): | 167 revision_validate = master.config.validation['revision'] |
| 168 if not branch_validate.match(branch): |
166 log.msg("bad branch '%s'" % branch) | 169 log.msg("bad branch '%s'" % branch) |
167 return Redirect(path_to_builder(req, self.builder_status)) | 170 return Redirect(path_to_builder(req, self.builder_status)) |
168 if not re.match(r'^[ \w\.\-\/]*$', revision): | 171 if not revision_validate.match(revision): |
169 log.msg("bad revision '%s'" % revision) | 172 log.msg("bad revision '%s'" % revision) |
170 return Redirect(path_to_builder(req, self.builder_status)) | 173 return Redirect(path_to_builder(req, self.builder_status)) |
171 properties = getAndCheckProperties(req) | 174 properties = getAndCheckProperties(req) |
172 if properties is None: | 175 if properties is None: |
173 return Redirect(path_to_builder(req, self.builder_status)) | 176 return Redirect(path_to_builder(req, self.builder_status)) |
174 if not branch: | 177 if not branch: |
175 branch = None | 178 branch = None |
176 if not revision: | 179 if not revision: |
177 revision = None | 180 revision = None |
178 | 181 |
179 master = self.getBuildmaster(req) | |
180 d = master.db.sourcestamps.addSourceStamp(branch=branch, | 182 d = master.db.sourcestamps.addSourceStamp(branch=branch, |
181 revision=revision, project=project, repository=repository) | 183 revision=revision, project=project, repository=repository) |
182 def make_buildset(ssid): | 184 def make_buildset(ssid): |
183 r = ("The web-page 'force build' button was pressed by '%s': %s\n" | 185 r = ("The web-page 'force build' button was pressed by '%s': %s\n" |
184 % (html.escape(name), html.escape(reason))) | 186 % (html.escape(name), html.escape(reason))) |
185 return master.addBuildset( | 187 return master.addBuildset( |
186 builderNames=[self.builder_status.getName()], | 188 builderNames=[self.builder_status.getName()], |
187 ssid=ssid, reason=r, properties=properties.asDict()) | 189 ssid=ssid, reason=r, properties=properties.asDict()) |
188 d.addCallback(make_buildset) | 190 d.addCallback(make_buildset) |
189 d.addErrback(log.err, "(ignored) while trying to force build") | 191 d.addErrback(log.err, "(ignored) while trying to force build") |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 if path in s.getBuilderNames(): | 528 if path in s.getBuilderNames(): |
527 builder_status = s.getBuilder(path) | 529 builder_status = s.getBuilder(path) |
528 return StatusResourceBuilder(builder_status) | 530 return StatusResourceBuilder(builder_status) |
529 if path == "_all": | 531 if path == "_all": |
530 return StatusResourceAllBuilders(self.getStatus(req)) | 532 return StatusResourceAllBuilders(self.getStatus(req)) |
531 if path == "_selected": | 533 if path == "_selected": |
532 return StatusResourceSelectedBuilders(self.getStatus(req)) | 534 return StatusResourceSelectedBuilders(self.getStatus(req)) |
533 | 535 |
534 return HtmlResource.getChild(self, path, req) | 536 return HtmlResource.getChild(self, path, req) |
535 | 537 |
OLD | NEW |