Skip to content

Commit

Permalink
Merge branch 'dev' of git://github.com/galaxyproject/galaxy into repo…
Browse files Browse the repository at this point in the history
…_queue_sharing
  • Loading branch information
davebx committed Sep 21, 2016
2 parents 18b9301 + 7d76bfe commit 07cc3a9
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 91 deletions.
37 changes: 21 additions & 16 deletions lib/galaxy/security/validate_user_input.py
Expand Up @@ -9,15 +9,20 @@

log = logging.getLogger( __name__ )

VALID_PUBLICNAME_RE = re.compile( "^[a-z0-9\-]+$" )
VALID_PUBLICNAME_SUB = re.compile( "[^a-z0-9\-]" )
# Email validity parameters
VALID_EMAIL_RE = re.compile( "[^@]+@[^@]+\.[^@]+" )
EMAIL_MAX_LEN = 255

# Public name validity parameters
PUBLICNAME_MIN_LEN = 3
PUBLICNAME_MAX_LEN = 255

# Basic regular expression to check email validity.
VALID_EMAIL_RE = re.compile( "[^@]+@[^@]+\.[^@]+" )
VALID_PUBLICNAME_RE = re.compile( "^[a-z0-9._\-]+$" )
VALID_PUBLICNAME_SUB = re.compile( "[^a-z0-9._\-]" )
FILL_CHAR = '-'

# Password validity parameters
PASSWORD_MIN_LEN = 6


def validate_email( trans, email, user=None, check_dup=True ):
"""
Expand All @@ -27,9 +32,9 @@ def validate_email( trans, email, user=None, check_dup=True ):
if user and user.email == email:
return message
if not( VALID_EMAIL_RE.match( email ) ):
message = "Please enter your real email address."
elif len( email ) > 255:
message = "Email address exceeds maximum allowable length."
message = "The format of the email address is not correct."
elif len( email ) > EMAIL_MAX_LEN:
message = "Email address cannot be more than %d characters in length." % EMAIL_MAX_LEN
elif check_dup and trans.sa_session.query( trans.app.model.User ).filter_by( email=email ).first():
message = "User with that email already exists."
# If the blacklist is not empty filter out the disposable domains.
Expand All @@ -48,13 +53,13 @@ def validate_publicname( trans, publicname, user=None ):
if user and user.username == publicname:
return ''
if len( publicname ) < PUBLICNAME_MIN_LEN:
return "Public name must be at least %d characters in length" % ( PUBLICNAME_MIN_LEN )
return "Public name must be at least %d characters in length." % ( PUBLICNAME_MIN_LEN )
if len( publicname ) > PUBLICNAME_MAX_LEN:
return "Public name cannot be more than %d characters in length" % ( PUBLICNAME_MAX_LEN )
return "Public name cannot be more than %d characters in length." % ( PUBLICNAME_MAX_LEN )
if not( VALID_PUBLICNAME_RE.match( publicname ) ):
return "Public name must contain only lower-case letters, numbers and '-'"
return "Public name must contain only lower-case letters, numbers, '.', '_' and '-'."
if trans.sa_session.query( trans.app.model.User ).filter_by( username=publicname ).first():
return "Public name is taken; please choose another"
return "Public name is taken; please choose another."
return ''


Expand All @@ -67,15 +72,15 @@ def transform_publicname( trans, publicname, user=None ):
elif publicname not in [ 'None', None, '' ]:
publicname = publicname.lower()
publicname = re.sub( VALID_PUBLICNAME_SUB, FILL_CHAR, publicname )
publicname = publicname.ljust( 4, FILL_CHAR )[:255]
publicname = publicname.ljust( PUBLICNAME_MIN_LEN + 1, FILL_CHAR )[:PUBLICNAME_MAX_LEN]
if not trans.sa_session.query( trans.app.model.User ).filter_by( username=publicname ).first():
return publicname
return ''


def validate_password( trans, password, confirm ):
if len( password ) < 6:
return "Use a password of at least 6 characters"
if len( password ) < PASSWORD_MIN_LEN:
return "Use a password of at least %d characters." % PASSWORD_MIN_LEN
elif password != confirm:
return "Passwords do not match"
return "Passwords don't match."
return ''
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/controllers/mobile.py
Expand Up @@ -67,7 +67,8 @@ def __login(self, trans, login="", password=""):
# kwd['email'] = autoreg[1]
# kwd['username'] = autoreg[2]
# params = util.Params( kwd )
# message = validate_email( trans, kwd['email'] )
# message = " ".join( [ validate_email( trans, kwd['email'] ),
# validate_publicname( trans, kwd['username'] ) ] ).rstrip()
# if not message:
# message, status, user, success = self.__register( trans, 'user', False, **kwd )
# if success:
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/controllers/user.py
Expand Up @@ -530,7 +530,8 @@ def __validate_login( self, trans, **kwd ):
if autoreg[0]:
kwd['email'] = autoreg[1]
kwd['username'] = autoreg[2]
message = validate_email( trans, kwd['email'] ) # self.__validate( trans, params, email, password, password, username )
message = " ".join( [ validate_email( trans, kwd['email'] ),
validate_publicname( trans, kwd['username'] ) ] ).rstrip()
if not message:
message, status, user, success = self.__register( trans, 'user', False, **kwd )
if success:
Expand Down
6 changes: 4 additions & 2 deletions lib/galaxy/webapps/galaxy/controllers/workflow.py
Expand Up @@ -993,7 +993,7 @@ def import_workflow( self, trans, cntrller='workflow', **kwd ):
myexperiment_target_url=myexperiment_target_url )

@web.expose
def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, dataset_collection_ids=None, workflow_name=None ):
def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, dataset_collection_ids=None, workflow_name=None, dataset_names=None, dataset_collection_names=None ):
user = trans.get_user()
history = trans.get_history()
if not user:
Expand All @@ -1014,7 +1014,9 @@ def build_from_current_history( self, trans, job_ids=None, dataset_ids=None, dat
job_ids=job_ids,
dataset_ids=dataset_ids,
dataset_collection_ids=dataset_collection_ids,
workflow_name=workflow_name
workflow_name=workflow_name,
dataset_names=dataset_names,
dataset_collection_names=dataset_collection_names
)
# Index page with message
workflow_id = trans.security.encode_id( stored_workflow.id )
Expand Down
22 changes: 15 additions & 7 deletions lib/galaxy/workflow/extract.py
Expand Up @@ -25,8 +25,8 @@
WARNING_SOME_DATASETS_NOT_READY = "Some datasets still queued or running were ignored"


def extract_workflow( trans, user, history=None, job_ids=None, dataset_ids=None, dataset_collection_ids=None, workflow_name=None ):
steps = extract_steps( trans, history=history, job_ids=job_ids, dataset_ids=dataset_ids, dataset_collection_ids=dataset_collection_ids )
def extract_workflow( trans, user, history=None, job_ids=None, dataset_ids=None, dataset_collection_ids=None, workflow_name=None, dataset_names=None, dataset_collection_names=None ):
steps = extract_steps( trans, history=history, job_ids=job_ids, dataset_ids=dataset_ids, dataset_collection_ids=dataset_collection_ids, dataset_names=dataset_names, dataset_collection_names=None )
# Workflow to populate
workflow = model.Workflow()
workflow.name = workflow_name
Expand All @@ -52,7 +52,7 @@ def extract_workflow( trans, user, history=None, job_ids=None, dataset_ids=None,
return stored


def extract_steps( trans, history=None, job_ids=None, dataset_ids=None, dataset_collection_ids=None ):
def extract_steps( trans, history=None, job_ids=None, dataset_ids=None, dataset_collection_ids=None, dataset_names=None, dataset_collection_names=None ):
# Ensure job_ids and dataset_ids are lists (possibly empty)
if job_ids is None:
job_ids = []
Expand All @@ -79,19 +79,27 @@ def extract_steps( trans, history=None, job_ids=None, dataset_ids=None, dataset_
steps_by_job_id = {}
hid_to_output_pair = {}
# Input dataset steps
for hid in dataset_ids:
for i, hid in enumerate( dataset_ids ):
step = model.WorkflowStep()
step.type = 'data_input'
step.tool_inputs = dict( name="Input Dataset" )
if dataset_names:
name = dataset_names[i]
else:
name = "Input Dataset"
step.tool_inputs = dict( name=name )
hid_to_output_pair[ hid ] = ( step, 'output' )
steps.append( step )
for hid in dataset_collection_ids:
for i, hid in enumerate( dataset_collection_ids ):
step = model.WorkflowStep()
step.type = 'data_collection_input'
if hid not in summary.collection_types:
raise exceptions.RequestParameterInvalidException( "hid %s does not appear to be a collection" % hid )
collection_type = summary.collection_types[ hid ]
step.tool_inputs = dict( name="Input Dataset Collection", collection_type=collection_type )
if dataset_collection_names:
name = dataset_collection_names[i]
else:
name = "Input Dataset Collection"
step.tool_inputs = dict( name=name, collection_type=collection_type )
hid_to_output_pair[ hid ] = ( step, 'output' )
steps.append( step )
# Tool steps
Expand Down
18 changes: 9 additions & 9 deletions templates/user/info.mako
Expand Up @@ -9,7 +9,7 @@
function validateString(test_string, type) {
var mail_re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
var username_re = /^[a-z0-9\-]{3,255}$/;
var username_re = /^[a-z0-9._\-]{3,255}$/;
if (type === 'email') {
return mail_re.test(test_string);
} else if (type === 'username'){
Expand Down Expand Up @@ -45,9 +45,9 @@
original_username = $( '#name_input' ).val();
$( '#login_info' ).bind( 'submit', function( e ) {
var error_text_email= 'Please enter your valid email address.';
var error_text_email_long= 'Email cannot be more than 255 characters in length.';
var error_text_username_characters = 'Public name must contain only lowercase letters, numbers and "-". It also has to be shorter than 255 characters but longer than 2.';
var error_text_email = 'The format of the email address is not correct.';
var error_text_email_long = 'Email address cannot be more than 255 characters in length.';
var error_text_username_characters = "Public name must contain only lowercase letters, numbers, '.', '_' and '-'. It also must be between 3 and 255 characters in length.";
var email = $( '#email_input' ).val();
var name = $( '#name_input' ).val();
var validForm = true;
Expand Down Expand Up @@ -102,23 +102,23 @@
<input type="hidden" id="name_input" name="username" value="${username | h}"/>
${username | h}
<div class="toolParamHelp" style="clear: both;">
You cannot change your public name after you have created a repository in this tool shed.
You cannot change your public name after you have created a repository in this Tool Shed.
</div>
%else:
<input type="text" id="name_input" name="username" size="40" value="${username | h}"/>
<div class="toolParamHelp" style="clear: both;">
Your public name provides a means of identifying you publicly within this tool shed. Public
Your public name provides a means of identifying you publicly within this Tool Shed. Public
names must be at least three characters in length and contain only lower-case letters, numbers,
and the '-' character. You cannot change your public name after you have created a repository
in this tool shed.
dots, underscores, and dashes ('.', '_', '-'). You cannot change your public name after you have created a repository
in this Tool Shed.
</div>
%endif
%else:
<input type="text" id="name_input" name="username" size="40" value="${username | h}"/>
<div class="toolParamHelp" style="clear: both;">
Your public name is an identifier that will be used to generate addresses for information
you share publicly. Public names must be at least three characters in length and contain only lower-case
letters, numbers, and the '-' character.
letters, numbers, dots, underscores, and dashes ('.', '_', '-').
</div>
%endif
</div>
Expand Down

0 comments on commit 07cc3a9

Please sign in to comment.