Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

- Fixed the `Hidden`, `IP address`, and `Hostname` questions to always use the correct value regardless of what was submitted, and restored the missing access check on the tree cascade dropdown children endpoint
- Fixed the `LDAP select` question's autocomplete search to properly handle special characters in the search text
- Fix visibility conditions on tree cascade dropdown questions
- Fixed the `Tree cascade Dropdown` field so that the subtree depth limit is enforced when loading children via AJAX
- Fixed the `Tree cascade Dropdown` question to only show items from the configured custom dropdown instead of all custom dropdowns
Expand Down
6 changes: 6 additions & 0 deletions src/Controller/TreeDropdownChildrenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use CommonTreeDropdown;
use Glpi\Application\View\TemplateRenderer;
use Glpi\Controller\AbstractController;
use Glpi\Controller\Form\Utils\CanCheckAccessPolicies;
use Glpi\Http\Firewall;
use Glpi\Security\Attribute\SecurityStrategy;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -47,6 +48,8 @@

final class TreeDropdownChildrenController extends AbstractController
{
use CanCheckAccessPolicies;

#[SecurityStrategy(Firewall::STRATEGY_AUTHENTICATED)]
#[Route(
path: 'TreeDropdownChildren',
Expand All @@ -66,6 +69,9 @@ public function __invoke(Request $request): Response
return new Response('', Response::HTTP_OK);
}

// Validate that the form is readable for the current user
$this->checkFormAccessPolicies($question->getForm(), $request);

/** @var QuestionTypeItemDropdown $question_type */
$question_type = $question->getQuestionType();

Expand Down
3 changes: 2 additions & 1 deletion src/Model/Dropdown/LdapDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,11 @@ public function getDropdownValues(LdapDropdownQuery $query): array

// Insert search text into filter if specified
if ($search_text !== '') {
$escaped_search_text = ldap_escape($search_text, '', LDAP_ESCAPE_FILTER);
$ldap_filter = sprintf(
"(& %s (%s))",
$config->getLdapFilter(),
$attribute . '=*' . $search_text . '*',
$attribute . '=*' . $escaped_search_text . '*',
);
} else {
$ldap_filter = $config->getLdapFilter();
Expand Down
7 changes: 7 additions & 0 deletions src/Model/QuestionType/HiddenQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ public function isHiddenInput(): bool
return true;
}

#[Override]
public function prepareEndUserAnswer(Question $question, mixed $answer): mixed
{
// Ignore the submitted value: this field must never be attacker-controlled.
return $question->fields['default_value'];
}

#[Override]
public static function getConfigKey(): string
{
Expand Down
7 changes: 7 additions & 0 deletions src/Model/QuestionType/HostnameQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ public function isHiddenInput(): bool
return true;
}

#[Override]
public function prepareEndUserAnswer(Question $question, mixed $answer): mixed
{
// Ignore the submitted value: this field must never be attacker-controlled.
return gethostbyaddr(NetworkHelper::getRemoteIpAddress());
}

#[Override]
public static function getConfigKey(): string
{
Expand Down
7 changes: 7 additions & 0 deletions src/Model/QuestionType/IpAddressQuestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ public function isHiddenInput(): bool
return true;
}

#[Override]
public function prepareEndUserAnswer(Question $question, mixed $answer): mixed
{
// Ignore the submitted value: this field must never be attacker-controlled.
return NetworkHelper::getRemoteIpAddress();
}

#[Override]
public static function getConfigKey(): string
{
Expand Down