Project

General

Profile

Actions

Bug #22747

closed

Validation on Puppet Class ID When using API

Added by Iain Walmsley about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
API
Target version:
Difficulty:
easy
Triaged:
Fixed in Releases:
Found in Releases:

Description

When posting data to;

/api/v2/hosts/:host/puppetclass_ids

The Puppetclass ID is not validated and a successful response is return. While this doesn't cause any issues (it isn't evaluated against the hosts puppetclasses) it means that errant data can be inserted into the database which can then only be cleaned manually. It also can be misleading - particuarly when interfacing with external systems which get a positive response.

e.g

# curl -X POST http://localhost:5000/api/v2/hosts/testhost/puppetclass_ids -d '{"puppetclass_id":"THISISINVALID"}' -H 'Content-Type: application/json'
{"host_id":1,"puppetclass_id":0}
# curl -X POST http://localhost:5000/api/v2/hosts/testhost/puppetclass_ids -d '{"puppetclass_id":"999999999"}' -H 'Content-Type: application/json'
{"host_id":1,"puppetclass_id":999999999}

Submitting patch to add validation on create action and adding test.

Actions

Also available in: Atom PDF