tags:

views:

710

answers:

3

I am evaluating the Hudson build system for use as a centralized, "sterile" build environment for a large company with very distributed development (from both a geographical and managerial perspective). One goal is to ensure that builds are only a function of the contents of a source control tree and a build script (also part of that tree). This way, we can be certain that the code placed into a production environment actually originated from our source control system.

Hudson seems to provide an ant script with the full set of rights assigned to the user invoking the Hudson server itself. Because we want to allow individual development groups to modify their build scripts without administrator intervention, we would like a way to sandbox the build process to (1) limit the potential harm caused by an errant build script, and (2) avoid all the games one might play to insert malicious code into a build.

Here's what I think I want (at least for Ant, we aren't using Maven/Ivy right now):

  • The Ant build script only has access to its workspace directory
  • It can only read from the source tree (so that svn updates can be trusted and no other code is inserted).
  • It could perhaps be allowed read access to certain directories (Ant distribution, JDK, etc.) that are required for the build classpath.

I can think of three ways to implement this:

  1. Write an ant wrapper that uses the Java security model to constrain access
  2. Create a user for each build and assign the rights described above. Launch builds in this user space.
  3. (Updated) Use Linux "Jails" to avoid the burden of creating a new user account for each build process. I know little about these though, but we will be running our builds on a Linux box with a recent RedHatEL distro.

Am I thinking about this problem correctly? What have other people done?

Update: This guy considered the chroot jail idea:

https://www.thebedells.org/blog/2008/02/29/l33t-iphone-c0d1ng-ski1lz

Update 2: Trust is an interesting word. Do we think that any developers might attempt anything malicious? Nope. However, I'd bet that, with 30 projects building over the course of a year with developer-updated build scripts, there will be several instances of (1) accidental clobbering of filesystem areas outside of the project workspace, and (2) build corruptions that take a lot of time to figure out. Do we trust all our developers to not mess up? Nope. I don't trust myself to that level, that's for sure.

With respect to malicious code insertion, the real goal is to be able to eliminate the possibility from consideration if someone thinks that such a thing might have happened.

Also, with controls in place, developers can modify their own build scripts and test them without fear of catastrophe. This will lead to more build "innovation" and higher levels of quality enforced by the build process (unit test execution, etc.)

A: 

How many projects will Hudson be building? Perhaps one Hudson instance would be too big, given the security concerns you are expressing. Have you considered distributing the Hudson instances out - one per team. This avoids the permission issue entirely.

Michael Donohue
Let's call it 30-ish. However, nobody's doing actual CI right now, so the actual build volume will be quite low. We would hate to force the number of build servers to scale linearly with the number of builds.
ShabbyDoo
@Shabby From what I've seen, people start with a single Hudson instance. Hudson has a nice feature where you can create views, to show groups of projects together. However, the views themselves start to crowd in, and after about 20 views are on your Hudson server, the UI doesn't look right. These issues are about to be solved, however.
Michael Donohue
+2  A: 

This may not be something you can change, but if you can't trust the developers then you have a larger problem then what they can or can not do to your build machine.

You could go about this a different way, if you can't trust what is going to be run, you may need a dedicated person(s) to act as build master to verify not only changes to your SCM, but also execute the builds.

Then you have a clear path of responsibilty for builds to not be modified after the build and to only come from that build system.

Another option is to firewall off outbound requests from the build machine to only allow certain resources like your SCM server, and your other operational network resources like e-mail, os updates etc.

This would prevent people from making requests in Ant to off the build system for resources not in source control.

When using Hudson you can setup a Master/Slave configuration and then not allow builds to be performed on the Master. If you configure the Slaves to be in a virtual machine, that can be easily snapshotted and restored, then you don't have to worry about a person messing up the build environment. If you apply a firewall to these Slaves, then it should solve your isolation needs.

Scott Markwell
+1  A: 

I suggest you have 1 Hudson master instance, which is an entry point for everyone to see/configure/build the projects. Then you can set up multiple Hudson slaves, which might very well be virtual machines or (not 100% sure if this is possible) simply unprivileged users on the same machine.

Once you have this set up, you can tie builds to specific nodes, which are not allowed - either by virtual machine boundaries or by Linux filesystem permissions - to modify other workspaces.

Robert Munteanu