• Leigh Stoller's avatar
    * Replace the argument processing code in all pages. Currently we rely on · 48acc8e3
    Leigh Stoller authored
      register_globals=1 to turn POST/GET/COOKIES arguments in local variables.
      This is known to be a terrible security risk, and we keep saying we are
      going to fix it, and now I am. In order to accomplish this on a
      transitional basis (since I don't want the entire web interface to stop
      working while I debug it), and because the code just needs the cleanup, I
      am doing it like this: Each page will sport new declarations at the top:
    
    	RequiredPageArguments("experiment", PAGEARG_EXPERIMENT,
                                  "template",   PAGEARG_TEMPLATE,
                                  "instance",   PAGEARG_INSTANCE,
                                  "metadata",   PAGEARG_METADATA,
                                  "osinfo",     PAGEARG_OSINFO,
                                  "image",      PAGEARG_IMAGE,
                                  "project",    PAGEARG_PROJECT,
                                  "group",      PAGEARG_GROUP,
                                  "user",       PAGEARG_USER,
    			      "node",       PAGEARG_NODE,
    			      "yesno",      PAGEARG_BOOLEAN,
    			      "message",    PAGEARG_STRING,
    			      "age",        PAGEARG_INTEGER,
                                  "cost",       PAGEARG_NUMERIC,
                                  "formfields", PAGEARG_ARRAY,
                                  "unknown",    PAGEARG_ANYTHING);
    
    	OptionalPageArguments("canceled", PAGEARG_BOOLEAN);
    
      The first token in each pair is the name of the global variable to
      set, and the second token is the type. So, for "experiment" we look at
      the URL for a pid/eid or exptidx, etc, sanity check them (safe for a
      DB query), and then try to find that experiment in the DB. If it maps
      to an experiment, set global variable $experiment to the object. Since
      its a required argument, produce an error if not supplied. Similar
      treatment for optional arguments, with the obvious difference.
    
      The goal is to have ALL argument processing in one place, consistent,
      and correct. I've found numerous places where we leak unchecked
      arguments into queries. It also cuts out a lot of duplicated code.
    
    * To make the above easier to deal with, I've been replacing lots of
      hardcoded URLS in the code of the form:
    
    	foo.php3?pid=$pid&eid=$eid ...
    
      with
    
            CreateURL("foo", $experiment)
    
      which creates and returns the neccessary url string, by looking at
      the type of its arguments (experiment, template, instance, etc.)
    
      Eventually plan to replace them all so that URL handling throughout
      the code is all defined in one place (all the new URL code is in
      url_defs.php).
    
    * I have cranked up error reporting to tell me anytime a variable is
      used before it is initialized, plus a bunch of other stuff that PHP
      deems improper. Think of it like -Wall ... and boy we get a lot of
      warnings.  A very large percentage of the diffs are to fix all these
      warnings.
    
      The warnings are currently going to /usr/testbed/log/php-errors.log,
      and I'll be adding a script to capture them each night and mail them
      to tbops. This file also gets errors (this will be a change for
      developers; rather then seeing errors and warnings dumped in the
      middle of web pages, they will go to this file instead).
    
    * Major refactoring of the code. More objects (nodes, images, osids).
      Moving tons of queries into the objects in the hopes of someday
      getting to a point where we can split the web interface onto a
      different server.  Lots of general cleanup.
    48acc8e3
template_graph.php 1.51 KB