Project

General

Profile

Actions

Bug #22747

closed

Validation on Puppet Class ID When using API

Added by Iain Walmsley about 6 years ago. Updated over 5 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 #1

Updated by The Foreman Bot about 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5284 added
Actions #2

Updated by Iain Walmsley about 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #3

Updated by Daniel Lobato Garcia about 6 years ago

  • translation missing: en.field_release set to 330
Actions

Also available in: Atom PDF