Opened 14 years ago
Closed 11 years ago
#34 closed defect (fixed)
SQL cleanup - use DBI ? substitutions, move all SQL into IPDB.pm
Reported by: | Kris Deugau | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 2.8 |
Version: | Keywords: | ||
Cc: |
Description
Much of the SQL currently uses:
$sth = $dbh->prepare("INSERT INTO table (cols) values ('$literal1','$literal2')"); $sth->execute;
instead of:
$sth = $dbh->prepare("INSERT INTO table (cols) values (?,?)"); $sth->execute($literal1, $literal2);
Switching to CGI::Simple (#15) is exposing several places where this is problematic.
This is also something of an SQL-injection security issue - using DBI's parameter replacement means that user data goes right into the table, instead of munging the SQL (deliberately or otherwise).
Change History (28)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
comment:3 by , 14 years ago
comment:4 by , 13 years ago
(In [508]) /branches/stable
Prep-for-release cleanup of buglets found making sure the demo
install works
- Clean up instructions for creating the database. Apparently the PL/pgSQL "language" module required for the last-modified triggers can't be installed by a regular user, and isn't available by default. O_o
- Fix a missed $IPDB::webpath-in-single-quotes
- Add a quick hack to allow automagical allocation from private net ranges. See #38.
- Partially convert some critical bits to use bound parameters in SQL for new allocations. See #34, mostly cleaned up already on /trunk or /branches/htmlform
- Set $privdata = internally so that an allocation via admin tools doesn't error out
comment:5 by , 12 years ago
comment:6 by , 12 years ago
Priority: | minor → major |
---|---|
Summary: | SQL cleanup - use DBI ? substitutions → SQL cleanup - use DBI ? substitutions, move all SQL into IPDB.pm |
comment:7 by , 12 years ago
comment:8 by , 12 years ago
comment:9 by , 12 years ago
comment:10 by , 12 years ago
comment:11 by , 12 years ago
comment:12 by , 12 years ago
(In [528]) /trunk
Clean up and move SQL for static IP pool list to IPDB.pm. See #34.
- Rename listPool in main.cgi to showPool, so that we can:
- Add listPool sub in IPDB.pm
- Convert getBlockData to return a hashref instead of an array, and update the one extant call
Tweak template to use odd for row colors
comment:13 by , 12 years ago
comment:14 by , 12 years ago
comment:15 by , 12 years ago
comment:16 by , 12 years ago
comment:17 by , 12 years ago
comment:18 by , 12 years ago
(In [534]) /trunk
Clean up and merge SQL for block-edit page into getBlockData.
Fortunately, the enhancement does not affect previous uses of
that sub. See #34.
Also tweak the template with a whitespace nitpick and to escape
HTML-funky characters in the circuit ID, description, notes, or
restricted data. Still need to confirm these can be reversed
on submission. See The Ticket That Won't Die, #3.
comment:19 by , 12 years ago
(In [536]) /trunk
Clean up and move SQL for post-update backlink to IPDB.pm. See #34.
Also rename getParent() to subParent() to fit in with ipParent() and
blockParent().
Fix a couple "Use of uninitialized..." log-noise bugs. See #31.
Move some HTML-entity-escaping into the template, and shuffle lines
munging the notes and restricted data on post-update value display
so we can properly munge in <br> for \n. Doesn't seem to be a way
to plug that into HTML::Template. :( See #3.
comment:20 by , 12 years ago
comment:21 by , 12 years ago
comment:22 by , 12 years ago
(In [541]) /trunk
Start on SQL in admin.cgi. See #34.
- Convert Q-n-D allocation list on main page to use existing getTypeList()
- Convert timestamp-update master block list to use new getMasterList(), with a flag set to return the last-modified time. Also convert main.cgi new assignment page to use this, with the flag set to not return the lastmod.
- Tweak admin main template to match
While following the code for the master block list, I also removed
several useless globals (@masterblocks, %allocated, %free, and
%routed) since they were only used originally in one place (index
page from main.cgi), obsoleted by changes in r523, and in fact got
overridden locally before that anyway.
comment:23 by , 12 years ago
comment:24 by , 12 years ago
(In [544]) /trunk
Extend findAllocateFrom() to allow passing a target block to allocate
to restrict the freeblock selection
Remove local SQL for confirmation page for "assign this block" in
admin.cgi in favour of existing data and subs. See #34.
For admin.cgi "assign this block", if the requested IP type does not
match the pool, the type will be adjusted and a warning pushed out.
Add space on "assign this block" template for a warning.
comment:25 by , 12 years ago
comment:26 by , 12 years ago
comment:27 by , 12 years ago
Milestone: | 3.0 → 2.8 |
---|
comment:28 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Resolving; with two exceptions all direct SQL has been moved to IPDB.pm.
Exceptions:
- main.cgi, when browse-assigning a static IP, pool data is retrieved with a dbh->selectrow_array(). This is already obsoleted in /trunk due to the new allocation structures; the code uses a second call to getBlockData().
- ipdb-rpc.cgi, getAvailableStatics uses dbh->selectall_arrayref for an operation not used in the web UI.
(In [448]) /branches/htmlform