diff --git a/website/integrations/osticket/SUPPORT-POLISH-328.md b/website/integrations/osticket/SUPPORT-POLISH-328.md index fb1a9f1a..e6109c6d 100644 --- a/website/integrations/osticket/SUPPORT-POLISH-328.md +++ b/website/integrations/osticket/SUPPORT-POLISH-328.md @@ -8,6 +8,8 @@ The homepage resolves an explicit list through `Topic::getPublicHelpTopics()`. I Native parent-prefixed topic labels are matched by their unique leaf name; ambiguous public branches are omitted. A public intake selected before sign-in is remembered for five minutes and consumed once after successful existing SSO/native authentication. Only relative `/open.php`, a currently public positive topic ID, or `/alpha-signup.php` is accepted. Recheck topic visibility after sign-in. Staff/Dev/appeal flows retain precedence; external URLs, private topics and POST payloads are excluded. The common SSO nonce validation and account/native authorisation checks are unchanged. +During early plugin bootstrap, validate only the candidate's syntax: osTicket has not initialised its configuration yet. The fully initialised SSO entrypoint validates public visibility before storing the navigation context, and validates it again before returning. A syntactically valid private-topic candidate is never stored as an authorised return destination. + `configure-public-sales.php` defaults to a read-only plan. Run it with `--apply` only for an authorised rollout. It creates **Customer sales enquiries**, routed through the existing Sales department/team, using only standard Ticket Details form 2. The existing private **Sales enquiries** email/internal topic remains private and unchanged. The installer requires transactional topic tables, serialises creation with a named lock, validates repeat runs and refuses routing/form drift. It does not create a ticket or process a payment/refund. ## Shared actions diff --git a/website/integrations/osticket/intake-navigation.php b/website/integrations/osticket/intake-navigation.php index 40f6eb7d..cdd95fc9 100644 --- a/website/integrations/osticket/intake-navigation.php +++ b/website/integrations/osticket/intake-navigation.php @@ -1,9 +1,14 @@ 128) return null; if ($candidate==='/alpha-signup.php' || $candidate==='/open.php') return $candidate; - if (!preg_match('~^/open\.php\?topicId=([1-9][0-9]{0,8})$~D',$candidate,$match)) return null; + return preg_match('~^/open\.php\?topicId=([1-9][0-9]{0,8})$~D',$candidate) ? $candidate : null; +} +function dune_public_intake_path($candidate) { + $candidate=dune_intake_candidate_path($candidate); + if ($candidate===null || $candidate==='/alpha-signup.php' || $candidate==='/open.php') return $candidate; + preg_match('~topicId=([1-9][0-9]{0,8})$~D',$candidate,$match); $public=Topic::getPublicHelpTopics(); return is_array($public) && array_key_exists((int)$match[1],$public) ? $candidate : null; } @@ -13,7 +18,9 @@ function dune_requested_intake_path($file, $query, $method) { if ($file!=='open.php') return null; if (!array_key_exists('topicId',$query)) return '/open.php'; if (!is_string($query['topicId'])) return null; - return dune_public_intake_path('/open.php?topicId='.$query['topicId']); + // Plugin bootstrap runs before osTicket initialises $cfg. Validate syntax here; + // the SSO entrypoint checks public visibility after main.inc.php has loaded. + return dune_intake_candidate_path('/open.php?topicId='.$query['topicId']); } function dune_remember_intake_path(&$session, $query, $now, $method='GET') { unset($session['dune_intake_return']); diff --git a/website/integrations/osticket/tests/intake-navigation-test.php b/website/integrations/osticket/tests/intake-navigation-test.php index f469f002..b5f1e575 100644 --- a/website/integrations/osticket/tests/intake-navigation-test.php +++ b/website/integrations/osticket/tests/intake-navigation-test.php @@ -1,5 +1,5 @@ 'General support',11=>'Report a Problem / Access Issue',14=>'Parental consent request [Preview]',21=>'Customer sales enquiries'];static function getPublicHelpTopics(){return self::$public;}} +class Topic {static $ready=true;static $public=[1=>'General support',11=>'Report a Problem / Access Issue',14=>'Parental consent request [Preview]',21=>'Customer sales enquiries'];static function getPublicHelpTopics(){if(!self::$ready)throw new RuntimeException('Native configuration is not initialised');return self::$public;}} require dirname(__DIR__).'/intake-navigation.php'; $checks=0; function intake_check($value,$label){global $checks;$checks++;if(!$value)throw new RuntimeException($label);} @@ -8,8 +8,10 @@ foreach([null,[],false,'https://example.test/open.php','//example.test/open.php' intake_check(dune_requested_intake_path('open.php',['topicId'=>'21'],'GET')==='/open.php?topicId=21','Selected public topic lost'); intake_check(dune_requested_intake_path('open.php',[],'HEAD')==='/open.php','Generic intake lost'); intake_check(dune_requested_intake_path('alpha-signup.php',[],'GET')==='/alpha-signup.php','Alpha route lost'); -foreach([['open.php',['topicId'=>['21']],'GET'],['open.php',['topicId'=>'17'],'GET'],['open.php',['topicId'=>'21'],'POST'],['tickets.php',[],'GET']]as$args)intake_check(dune_requested_intake_path(...$args)===null,'Invalid request remembered'); +foreach([['open.php',['topicId'=>['21']],'GET'],['open.php',['topicId'=>'21'],'POST'],['tickets.php',[],'GET']]as$args)intake_check(dune_requested_intake_path(...$args)===null,'Invalid request remembered'); +Topic::$ready=false;intake_check(dune_requested_intake_path('open.php',['topicId'=>'21'],'GET')==='/open.php?topicId=21','Bootstrap consulted an unavailable native configuration');Topic::$ready=true; $session=['dune_sso_state'=>'existing-nonce','dune_session_ref'=>'existing-reference']; +$untrusted=dune_requested_intake_path('open.php',['topicId'=>'17'],'GET');dune_remember_intake_path($session,['intake'=>$untrusted],100);intake_check(dune_take_intake_path($session,101)===null,'Private bootstrap candidate persisted'); dune_remember_intake_path($session,['intake'=>'/open.php?topicId=21'],100); intake_check(dune_take_intake_path($session,101)==='/open.php?topicId=21','Successful sign-in route lost'); intake_check(dune_take_intake_path($session,102)===null,'Return context replayed');