Closed (fixed)
Project:
Drupal.org drush
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Issue tags:
Reporter:
Created:
14 Jan 2010 at 17:03 UTC
Updated:
3 Jan 2014 at 01:08 UTC
Jump to comment: Most recent
This issue deals with bringing the library download feature (seen below) to drupal-org.make.
101 To download an external library (this will be placed in sites/all/libraries by default):
102 ====
103 libraries[tinymce][download][type] = "get"
104 libraries[tinymce][download][url] = "http://downloads.sourceforge.net/project/tinymce/TinyMCE/3.2.7/tinymce_3_2_7.zip"
105 libraries[tinymce][directory_name] = "tinymce"
106 ====
107
108 To download an external library and place it in an alternate location (this
109 code downloads jQuery UI and places it in modules/jquery_ui/jquery.ui):
110 ====
111 libraries[jquery_ui][download][type] = "get"
112 libraries[jquery_ui][download][url] = "http://jquery-ui.googlecode.com/files/jquery.ui-1.6.zip"
113 libraries[jquery_ui][directory_name] = jquery.ui
114 libraries[jquery_ui][destination] = modules/jquery_ui
115 ====
For security reasons, the "get" feature of drush.make was removed from drupal.org's implementation. The consensus appears to be that if a white-list is implemented to verify no malicious or illegal code was being packaged and stored on drupal.org, the "get" feature would be enabled.
Is there a way to verify the following line:
libraries[jquery_ui][download][url] = "http://jquery-ui.googlecode.com/files/jquery.ui-1.6.zip"
...against a white-list that contains something like the following?
http://downloads.sourceforge.net/project/tinymce/*
Comments
Comment #1
philbar commentedRelated: #594704: Allow packaged install profiles on d.o to pull in code from other sources + sites
Comment #2
dmitrig01 commentedI would prefer to have d.o introduce a new property, something like externals[] and just keep a list of name => url. WHat do you think?
Comment #3
philbar commentedIf the property is the same as the current convention "libraries[]", then the .make file can be used apart form d.o. This seems more ideal since this is intended for use on install profiles and some people might want to package the install profile on their own.
Comment #4
philbar commentedAlso, correct me if I'm wrong, but it sounds like your assuming the whitelist could have the full download URL. I don't think a system like this will be sustainable.
Something like
externals[tinymce]will not work because:1. The location of tinymce could change. The full download URL should be the resposibility of the install profile maintainer because it would be much to much work for the whitelist maintainer to manage contantly changing download locations.
2. It doesn't account for different versions. Not every module could be expected to work with the latest version of the library.
For this reason, the Install Profile maintainer should provide the URL which downloads the version of the library they want.
Comment #5
dmitrig01 commented(1) Well if the URL changes, how is it going to be marked as on the whitelist anyway?
(2) easy enough to solve - have different versions just as anything else does - different URLs point to different versions.
Comment #6
philbar commentedThe whitelist you are proposing would look like this for only one library, TinyMCE, with only version 3.2.7:
Or the whitelist I'm suggesting:
Which whitelist is easier to maintain if the TinyMCE developers changes their download location to the following:
It's your call. If you don't think it will be too much work for the whitelist maintainer when a change like this happens, than go ahead.
I imagine it would be a nightmare if sourceforce.net or Google Code changes their download locations because many libraries are hosted on these sites and dozens of URLs would need to be changed by a single whitelist maintainer. This seems like an unnecessary bottleneck.
Comment #7
dmitrig01 commentedI have a brilliant idea - ask the (potential) whitelist maintainer!
Comment #8
philbar commentedIt appears we are waiting to choose the whitelist maintainer until this issue is complete.
Maybe we should just make the decision here.
I sincerely feel using wildcards instead exact URLs will be the best approach since it accomplishes what we need to keep malicious code out of distributions and will result in a smaller whitelist file which in turn makes it easier to maintain.
Comment #9
cweagansI will volunteer to maintain the whitelist, and I think that it would be best to start simple (specific download URLs) and add features as needed (wildcards and such).
Comment #10
philbar commentedAre you suggesting something like this:
Wouldn't it be easier for the following to be the whitelist format?
I just don't want to have to rely on the whitelist maintainer to update the list every time a new version of the library comes out. It seems like more to manage than is necessary. With specific download URLs you would have to be updating it weekly with the release of every new library version. Why don't we save the hassel and just whitelist entire libraries rather than individual library versions.
Comment #11
philbar commentedSee: #779452: Whitelist for external dependencies
Comment #12
alex_b commentedLet's support wildcards. It reflects the use case better. We will need to decide on allowing external libraries on a library per library basis, not a library version basis.
Comment #13
dmitrig01 commentedI'm convinced. Someone wanna code this up?
Comment #14
philbar commentedWe need to work with
drush_make_add_librariesfound on line 161 of drush_make.drush.incI propose something like the following:
NOTE: i doubt any of the above code works, because I'm new to PHP. But hopefully it's a start.
Comment #15
andrechun commentedHow about something like this?
Comment #16
philbar commentedComment #17
dmitrig01 commentedThere's no patch yet. There is a plugin system. Look in contrib/drush_make_d_o.drush.inc for more.
Comment #18
dmitrig01 commentedbefore moving into code I want to talk to the d.o people
Comment #19
q0rban commentedSubscribe
Comment #20
dixon_This makes most sense to me: If a whitelist *is* provided that will be taken into account. And if a whitelist *isn't* provided everything will pass through. This isn't reflected in the pseudo code in #15, what I can see.
What would be the best approach? This functionality can be useful for things outside of the usecase for drupal.org also.
Comment #21
dmitrig01 commentedyeah, the code itself isn't really an issue, semantics are more of the issue here.
Comment #22
dmitrig01 commentedSo, 5 things need to happen for this to get in.
1) We need to appoint a whitelist maintainer.
2) We need to figure out what in format the whitelist will be kept.
3) The whitelist maintainer (and others potentially) need to create the whitelist.
4) This needs to be coded in Drush Make
5) It needs to be deployed on Drupal.org
I'll handle #4, and #5 needs to happen after all the others, but #1-3 still need to be solved.
Comment #23
Amazon commentedDmitrig01 and I discussed the issue this morning. I've also bumped into dww mid-researching.
Here's the current plan:
1) We need to appoint a whitelist maintainer.
I've reached out to crell and cweagans to see what needs to be done for this. I've volunteered to kick it off, but I'll need to pass it along to some others quickly.
2) We need to figure out in what format the whitelist will be kept.
For Drupal.org the white-list content type has been created. http://drupal.org/node/add/packaging-whitelist
3) The whitelist maintainer (and others potentially) need to create the whitelist.
Paraphrased from dww:
We further discussed which issue queue to track these changes. End users will submit an issue in the packaging white list component of the drupal.org infrastructure project to get packages added to the white-list content type.
Dmitrig01 will need to create the white-list content type view on drupal.org that drush make can read.
4) This needs to be coded in Drush Make
Dmitrig01 will add this capability to drush make.
5) It needs to be deployed on Drupal.org
Dmitrig01 has access to a local development environment by asking for a shell account to access the druapl.org BZR. Write access to a BZR development branch, combined with Hudson will allow him to deploy and test his code in a drupal.org development environment.
Finally, I've sent dmitrig01 a copy of 3281d's plan for developing and deploying this so he's in sync with dww and hunmonk.
Comment #24
dwwGood summary, thanks. Just to clarify a few things:
Meta summary and battle plan is probably best kept up to date at the Install Profile Packaging Community Initiative handbook page. That has the benefit of a) already having a bunch of this plan spelled out and b) being a handbook page that anyone can edit and keep updated, instead of a comment in one of the issues for a specific part of the overall plan, which no one else can edit.
This issue is specifically about fixing drush_make to read and enforce the whitelist once it exists. As such, postponed is probably the most appropriate status here, since drush_make can't enforce a whitelist that doesn't yet exist. ;)
#779452: Whitelist for external dependencies has more discussion about what the white list nodes themselves are for and how they should be used. That's where the next action needs to happen -- views for the white list nodes. The policy stuff is also being discussed over there, although the creation of a packaging whitelist maintainer role should probably be split out into a separate infra issue to avoid confusion.
Hurray that dmitri01 wants to help move this forward, thanks!!!
-Derek
Comment #25
rickvug commentedAmazon's comment #23 provides a clear path forward. It sounds like points 4 and 5 are where the work is. Starting and maintaining the whitelist itself should be quite simple.
Comment #26
webchickSubscribe and tagging.
Comment #27
jhedstromUn-postponing, since Drush Make can support an arbitrary whitelist before there is an official one, it just needs the code and tests to do so.
Comment #28
dwwd.o-specific drush validation code now lives in http://drupal.org/project/drupalorg_drush. Moving this issue to the right queue.
Comment #29
hunmonk commenteda working patch for this lives on the
684788-library-whitelistbranch. leveraging the work at #779452: Whitelist for external dependencies, it loads the whitelist, runs it through a regex-ifier function, then tries to match alllibrariesentries against the list. if you run drush with the -d switch, there's some nice debug output describing what it's doing.still to do:
.+. if we do keep this approach, that function will need to be expanded to provide proper escaping for regex special characters. if we decide that the whitelist entries are straight regexes, we can simply rip it out.Comment #30
hunmonk commentedlatest code at the
684788-library-whitelistbranch addresses the issues in #29.as discussed over at #779452-39: Whitelist for external dependencies, the incoming whitelist entries are now full regexes, so the code on the consuming end that dealt with transforming it has been ripped out.
i added
packaging_whitelist.jsonto the test suite, and rewrote the library tests to use it, so we now have test coverage for both a 'good' and 'bad' download location for a library.i believe all the major issues have been addressed here.
Comment #31
dwwReviewing this branch, I see a few issues:
A) Instead of adding
drupalorg_drush_get_remote_file(), any reason not to just usedrush_download_file()?B) This way of verifying isn't ideal:
Due to short-circuit evaluation, as soon as we hit one verification failure, $pass will be FALSE and we'll never verify any other libraries in the make file. IMHO it's better to loop through everything so we can provide complete info to the end user about anything in their .make file that's not kosher, instead of just bailing out at the first error and only telling them about that.
C) There appears to be some inconsistency in the handling of the whitelist URLs. Sometimes we honor the command-line arg to specify your own, other times we hard-code based on the constant, e.g. here:
D) Maybe not a bug, but I don't understand why sometimes we use
drush_log()and other times we use$this->log().E) Not clear to me why
function verify()is taking$library_databy reference.F) Codestyle: newline after the return; or break; for each case statement in a switch().
G) I'm concerned about this:
We'd better ensure the whitelist regexs never use '@' internally. Either we should automatically escape any '@' characters in inside each regexp, or perhaps add validation over at #779452: Whitelist for external dependencies so that the list of URLs never includes '@'. I think automatically escaping in drupalorg_drush is cleaner and better than a semi-arbitrary restriction on the whitelist regexp, and relying on server-side validation instead of just doing the safe thing in the client.
H) Shouldn't verify() return FALSE instead of NULL if there's no 'url' defined?
That's what I saw on a visual review. Running the phpunit tests seems to have worked:
I haven't closely reviewed the tests themselves, nor manually tested myself.
Comment #32
dwwFYI: I realized point B effects other verification code paths in the plugin, so I think it's cleaner to handle that separately:
#1401738: Fix verification logic so we find all errors and report them at once
Comment #33
hunmonk commentedA)
drupalorg_drush_get_remote_file()is a more robust function thandrush_download_file(), therefore i would vote to try and get it merged into drush core instead of using drush core's inferior function. so, leaving that in for now...C) cleaned this up to use only one define
D)
$this->logspecifically logs a make build error, whereasdrush_log(), as used here, outputs debug messages. i added a TODO to either cleanup the name of the log wrapper function, or remove it entirely.G) added a support function to properly escape the regex delimiter in the whitelist url regexes, and wrap them in the delimiter.
E), F), H) simple, all fixed.
Comment #34
dwwFound a few more minor problems, worked with hunmonk to fix them. We then did a squash merge to put all of this into master via one commit (since Chad wasn't doing careful commit messages along the way, and we don't really need the specific small-scale history now that this is done).
Again, I'd normally tag this "needs drupal.org deployment" instead of calling it fixed, but that's really for #1365536: Switch distribution packaging system to use just drush core and drupalorg_drush and http://drupal.org/community-initiatives/drupalorg/distribution-packaging itself...