Bug 1463747

Summary: restraint should validate URL and handle broken ones without crashing
Product: [Retired] Restraint Reporter: Jan Stancek <jstancek>
Component: generalAssignee: Artem Savkov <asavkov>
Status: CLOSED NEXTRELEASE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.1.30CC: asavkov, bpeck, dcallagh, mjia, rjoost
Target Milestone: 0.1.31Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-11 06:27:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jan Stancek 2017-06-21 16:01:17 UTC
Description of problem:
If I specify broken URL in fetch node, it will fail the regexp match and task->fetch.url will be NULL, leading to crash with no message other available for user:

gdb) bt
#0  0x000000000040ad2c in parse_task (error=0x7ffdb494df88, recipe=0x19daf30, task_node=0x19f7240) at recipe.c:258
#1  recipe_parse (error=0x19bd048, recipe_uri=<optimized out>, doc=<optimized out>) at recipe.c:394
#2  recipe_handler (user_data=0x19bd020) at recipe.c:579
#3  0x00000000005f5594 in g_main_dispatch (context=0x19c0c40) at gmain.c:3065
#4  g_main_context_dispatch (context=context@entry=0x19c0c40) at gmain.c:3641
#5  0x00000000005f58f8 in g_main_context_iterate (context=0x19c0c40, block=block@entry=1, dispatch=dispatch@entry=1, 
    self=<optimized out>) at gmain.c:3712
#6  0x00000000005f5cda in g_main_loop_run (loop=0x19d6880) at gmain.c:3906
#7  0x00000000004088d8 in main (argc=1, argv=0x7ffdb494e268) at server.c:648
(gdb) f 0
#0  0x000000000040ad2c in parse_task (error=0x7ffdb494df88, recipe=0x19daf30, task_node=0x19f7240) at recipe.c:258
258	        task->path = g_build_filename(task->recipe->base_path,
(gdb) list
253	        } else {
254	            task->ssl_verify = FALSE;
255	        }
256	        xmlFree(ssl_verify);
257	
258	        task->path = g_build_filename(task->recipe->base_path,
259	                task->fetch.url->host,
260	                task->fetch.url->path,
261	                task->fetch.url->fragment,
262	                NULL);
(gdb) p task->fetch.url
$7 = (struct restraint_url *) 0x0

Version-Release number of selected component (if applicable):
restraint-0.1.30-1.el7_2.x86_64

How reproducible:
100%

Steps to Reproduce:
1. leave out "git://" from url

Actual results:
restraint crash

Expected results:
no crash, message informing user, that URL is invalid

Additional info:

Comment 1 Artem Savkov 2017-06-22 08:14:26 UTC
https://gerrit.beaker-project.org/5714