Skip to content

Fix config tab visibility and restrict config update fields - #25

Open
Lainow wants to merge 4 commits into
mainfrom
fix-config-tab-rights-and-input
Open

Lainow wants to merge 4 commits into
mainfrom
fix-config-tab-rights-and-input

Conversation

@Lainow

@Lainow Lainow commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Checklist before requesting a review

Please delete options that are not relevant.

  • I have performed a self-review of my code.
  • I have added tests (when available) that prove my fix is effective or that my feature works.
  • I have updated the CHANGELOG with a short functional description of the fix or new feature.
  • This change requires a documentation update.

@Lainow Lainow self-assigned this Oct 1, 2026
@Lainow
Lainow requested a review from stonebuzz October 1, 2026 14:52
Comment thread src/Config.php
*
* @return array<string, mixed>
*/
public function prepareInputForUpdate($input): array

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data-integrity fix with no non-regression test: nothing asserts that update(['id' => $id, 'entities_id' => $other]) leaves entities_id unchanged while config fields are still updated. tests/Units/ConfigTest.php already has the fixtures needed (createItem(Config::class, ...) / updateItem).

Comment thread src/Config.php

public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0): string
{
if (!self::canView()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rights fix with no test: no assertion that getTabNameForItem() returns '' (and displayTabContentForItem() returns false) for a profile without config READ, and returns the tab otherwise.

Comment thread front/config.form.php Outdated
$config->update($_POST);
$config->update(
['id' => (int) $_POST['id']]
+ array_intersect_key($_POST, array_flip(Config::getAllConfigFields())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant with the new prepareInputForUpdate(), which applies the same whitelist on every update path. Keeping the filter in one place (the model) is enough; $config->update($_POST) would behave identically and getAllConfigFields() could stay private.

Comment thread src/Config.php
*
* @return array<string, mixed>
*/
public function prepareInputForUpdate($input): array

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whitelist also strips every _-prefixed control key (_no_message, _no_history, keys injected by other plugins' hooks). Harmless today since the only caller is the form, but worth keeping keys starting with _ if internal callers ever update this item.

@Lainow
Lainow requested a review from stonebuzz October 2, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants