should validate the parameters of agent API

Bug #1240458 reported by Ken'ichi Ohmichi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Ken'ichi Ohmichi

Bug Description

The agent API has some parameters, but they are not validated.
Each parameter is stored to the table "agent_builds", and each column is defined as varchar(255).

mysql> desc agent_builds;
    +--------------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +--------------+--------------+------+-----+---------+----------------+
    | created_at | datetime | YES | | NULL | |
    | updated_at | datetime | YES | | NULL | |
    | deleted_at | datetime | YES | | NULL | |
    | id | int(11) | NO | PRI | NULL | auto_increment |
    | hypervisor | varchar(255) | YES | MUL | NULL | |
    | os | varchar(255) | YES | | NULL | |
    | architecture | varchar(255) | YES | | NULL | |
    | version | varchar(255) | YES | | NULL | |
    | url | varchar(255) | YES | | NULL | |
    | md5hash | varchar(255) | YES | | NULL | |
    | deleted | int(11) | YES | | NULL | |
    +--------------+--------------+------+-----+---------+----------------+

Due to this fact, if specifying very long characters as a parameter, the stored data is truncated like the following:

$ nova agent-create os arch 1 url hash 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
[..]
$
$ $ nova agent-list
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----+--------------+---------+---------+-----+
| Agent_id | Hypervisor | OS | Architecture | Version | Md5hash | Url |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----+--------------+---------+---------+-----+
| 1 | 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234 | os | arch | 1 | hash | url |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----+--------------+---------+---------+-----+
$

so the parameters should be validated before storing to DB.

Changed in nova:
assignee: nobody → Ken'ichi Ohmichi (oomichi)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/52054

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/52054
Committed: http://github.com/openstack/nova/commit/de7321d53fb4a2c01e5fbccbec1954c00ef363d6
Submitter: Jenkins
Branch: master

commit de7321d53fb4a2c01e5fbccbec1954c00ef363d6
Author: Ken'ichi Ohmichi <email address hidden>
Date: Wed Oct 16 19:29:22 2013 +0900

    Validate parameters of agent API

    The agent API has some parameters, but they are not validated.
    Each parameter is stored to the table "agent_builds", and each column
    is defined as varchar(255).

    mysql> desc agent_builds;
    +--------------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +--------------+--------------+------+-----+---------+----------------+
    | created_at | datetime | YES | | NULL | |
    | updated_at | datetime | YES | | NULL | |
    | deleted_at | datetime | YES | | NULL | |
    | id | int(11) | NO | PRI | NULL | auto_increment |
    | hypervisor | varchar(255) | YES | MUL | NULL | |
    | os | varchar(255) | YES | | NULL | |
    | architecture | varchar(255) | YES | | NULL | |
    | version | varchar(255) | YES | | NULL | |
    | url | varchar(255) | YES | | NULL | |
    | md5hash | varchar(255) | YES | | NULL | |
    | deleted | int(11) | YES | | NULL | |
    +--------------+--------------+------+-----+---------+----------------+

    This patch adds the validation with the type and the length.

    Closes-Bug: 1240458

    Change-Id: Id06235ebde62f7b96c55b0bd2be5d941bfd2e999

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → icehouse-1
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: icehouse-1 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.