Project

General

Profile

Bug #22747

Validation on Puppet Class ID When using API

Added by Iain Walmsley 8 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
API
Target version:
Difficulty:
easy
Triaged:
Bugzilla link:
Team Backlog:
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.

Associated revisions

Revision a8c113c0 (diff)
Added by Iain Walmsley 8 months ago

Fixes #22747 - vet puppetclass_id on addition

History

#1 Updated by The Foreman Bot 8 months ago

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

#2 Updated by Iain Walmsley 8 months ago

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

#3 Updated by Daniel Lobato Garcia 8 months ago

  • Legacy Backlogs Release (now unused) set to 330

Also available in: Atom PDF