tem/tenant/tssl_certificate_inner.sql

              SELECT 'dynamic' AS component, sqlpage.run_sql('shell/shell.sql') AS properties;
              -- not including breadcrumbs from sqlpage_aide_navigation
              -- not including page title from sqlpage_aide_navigation
              

              SELECT 'title' AS component, (SELECT COALESCE(title, caption)
    FROM sqlpage_aide_navigation
   WHERE namespace = 'prime' AND path = 'tem/tenant/tssl_certificate_inner.sql/index.sql') as contents;
    ;
  --- Display breadcrumb
  SELECT
      'breadcrumb' AS component;
  SELECT
      'Home' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/'    AS link;
  SELECT
      'Threat Exposure Management' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/tem/index.sql' AS link;  
  SELECT 'Attack Surface Mapping By Tenant' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/tem/attack_surface_mapping_tenant.sql' AS link;
  SELECT tenant_name AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/tem/tenant/attack_surface_mapping_inner.sql?tenant_id=' || $tenant_id AS link FROM tem_tenant WHERE tenant_id=$tenant_id;
  SELECT 'Findings' AS title,
          sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/tem/tenant/finding.sql?tenant_id=' || $tenant_id AS link;
  SELECT 'TestSSL Report' AS title,
      sqlpage.environment_variable('SQLPAGE_SITE_PREFIX') || '/tem/tenant/tssl_certificate.sql?tenant_id=' || $tenant_id AS link;
  SELECT host AS title,
      '#' AS link
  FROM tem_testssl_general
  WHERE tenant_id = $tenant_id;

  --- Dsply Page Title
  SELECT
    'title'   as component,
    'TestSSL Report' as contents;

  SELECT
    'text'              as component,
    'The TestSSL Report provides a comprehensive overview of the SSL/TLS security posture of scanned hosts. It consolidates findings from server configurations, supported protocols, cipher suites, forward secrecy settings, HTTP headers, browser simulations, vulnerabilities, and overall ratings into a structured and easily interpretable format. Each entry includes a unique identifier, severity level, and descriptive details, allowing security teams to quickly identify and prioritize issues. The report helps organizations assess compliance with best practices, track security improvements over time, and make informed decisions to strengthen their SSL/TLS configurations, ensuring robust protection for web applications and client connections.' as contents;
  


  select 
  'table' as component,
  TRUE    as freeze_columns,
  TRUE    as freeze_headers,
  TRUE    as border;  
     
      select 
          'Invocation' as 'General Info',
          invocation as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'Open SSL' as 'General Info',
          openssl as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'Version' as 'General Info',
          version as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'Host' as 'General Info',
          host as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'ip' as 'General Info',
          ip as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'port' as 'General Info',
          port as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id
      union all
      select 
          'service' as 'General Info',
          service as 'Value'
          FROM tem_testssl_general WHERE tenant_id=$tenant_id

 select 
      'tab' as component;
  -- Pretests tab (active only if tab=pretests) 
  select 
      'Pretests' as title,
      (coalesce($tab, 'pretests') = 'pretests') as active,
      '?component=tab&tab=pretests&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Protocols tab (active only if tab=protocols) 
  select 
      'Protocols' as title,
      ($tab = 'protocols') as active,
      '?component=tab&tab=protocols&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

   -- Ciphers tab (active only if tab=ciphers)
  select 
      'Ciphers' as title,
      ($tab = 'ciphers') as active,
      '?component=tab&tab=ciphers&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Server Preferences tab (active only if tab=server-preferences)
  select 
      'Server Preferences' as title,
      ($tab = 'server-preferences') as active,
      '?component=tab&tab=server-preferences&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Forward Secrecy (active only if tab=forward-secrecy)
  select 
      'Forward Secrecy' as title,
      ($tab = 'forward-secrecy') as active,
      '?component=tab&tab=forward-secrecy&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Server Defaults / Certificates (active only if tab=protocols)
  select 
      'Server Defaults / Certificates' as title,
      ($tab = 'server-defaults') as active,
      '?component=tab&tab=server-defaults&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- HTTP Response Headers (active only if tab=http-response-header)
  select 
      'HTTP Response Headers' as title,
      ($tab = 'http-response-header') as active,
      '?component=tab&tab=http-response-header&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Vulnerabilities (active only if tab=http-response-header)
  select 
      'Vulnerabilities' as title,
      ($tab = 'vulnerabilitie') as active,
      '?component=tab&tab=vulnerabilitie&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Browser Simulations (active only if tab=browser-simulations)
  select 
      'Browser Simulations' as title,
      ($tab = 'browser-simulations') as active,
      '?component=tab&tab=browser-simulations&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

  -- Rating (active only if tab=rating)
  select 
      'Rating' as title,
      ($tab = 'rating') as active,
      '?component=tab&tab=rating&uniform_resource_id='||$uniform_resource_id||'&tenant_id='||$tenant_id as link;

      -- Pretests tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_pretest WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Pretests' as contents WHERE $tab = 'pretests';
      SELECT
      'text'              as component,
      'Quick preliminary checks performed before the detailed scan. These verify basic connectivity, service availability, and whether the host can be tested reliably.' as contents
      WHERE $tab = 'pretests';
  
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'pretests';
      select id,severity,finding from tem_testssl_pretest where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'pretests';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='pretests';
        ;;

      -- Protocols tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_protocols WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Protocols' as contents WHERE $tab = 'protocols';
      SELECT
      'text'              as component,
      'Lists the supported SSL/TLS protocol versions (e.g., TLS 1.0, 1.2, 1.3). Helps identify if older, insecure protocols are enabled or only modern secure ones are accepted.' as contents
      WHERE $tab = 'protocols';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'protocols';
      select id,severity,finding from tem_testssl_protocols where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'protocols';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='protocols';
        ;;

      -- Ciphers tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_ciphers WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Ciphers' as contents WHERE $tab = 'ciphers';
      SELECT
      'text'              as component,
      'Shows the encryption algorithms (ciphers) supported by the server. Weak or outdated ciphers (like CBC-based ones) are flagged, while strong ciphers are marked safe.' as contents
      WHERE $tab = 'ciphers';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'ciphers';
      select id,severity,finding from tem_testssl_ciphers where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'ciphers';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='ciphers';
        ;;

      -- Server Preferences tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_server_references WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Server Preferences' as contents WHERE $tab = 'server-preferences';
      SELECT
      'text'              as component,
      'Describes how the server prioritizes protocols and ciphers. For example, whether the server enforces its own cipher order or allows clients to choose.' as contents
      WHERE $tab = 'server-preferences';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'server-preferences';
      select id,severity,finding from tem_testssl_server_references where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'server-preferences';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='server-preferences';
        ;;

      -- Forward Secrecy (FS) tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_fs WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Forward Secrecy (FS)' as contents WHERE $tab = 'forward-secrecy';
      SELECT
      'text'              as component,
      'Checks whether the server supports forward secrecy using key exchange methods (e.g., ECDHE). FS ensures that past communications remain secure even if the server’s private key is compromised later.' as contents
      WHERE $tab = 'forward-secrecy';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'forward-secrecy';
      select id,severity,finding from tem_testssl_fs where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'forward-secrecy';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='forward-secrecy';
        ;;

      -- Server Defaults / Certificates tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_server_default WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Server Defaults / Certificates' as contents WHERE $tab = 'server-defaults';
      SELECT
      'text'              as component,
      'Displays SSL/TLS certificate information such as common name, issuer, validity, and other defaults. This helps verify domain ownership, certificate authority, and expiration.' as contents
      WHERE $tab = 'server-defaults';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'server-defaults';
      select id,severity,finding from tem_testssl_server_default where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'server-defaults';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='server-defaults';
        ;;

      -- HTTP Response Headers tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_header_response WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'HTTP Response Headers' as contents WHERE $tab = 'http-response-header';
      SELECT
      'text'              as component,
      'Lists security-related HTTP headers (e.g., HSTS, X-Frame-Options, CSP). These help protect against attacks like clickjacking, XSS, or protocol downgrade.' as contents
      WHERE $tab = 'http-response-header';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'http-response-header';
      select header_response_id as "header response id",severity,finding from tem_testssl_header_response where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'http-response-header';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='http-response-header';
        ;;

      -- Vulnerabilities tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_vulnerabilitie WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Vulnerabilities' as contents WHERE $tab = 'vulnerabilitie';
      SELECT
      'text'              as component,
      'Tests the server against known SSL/TLS vulnerabilities (e.g., Heartbleed, POODLE, LUCKY13). Any positive finding here indicates a serious risk.' as contents
      WHERE $tab = 'vulnerabilitie';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'vulnerabilitie';
      select vulnerability_id as "vulnerability id",severity,finding from tem_testssl_vulnerabilitie where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'vulnerabilitie';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='vulnerabilitie';
        ;;

      -- Browser Simulations tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_browser_simulation WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
      SELECT
      'title'   as component,
      'Browser Simulations' as contents WHERE $tab = 'browser-simulations';
      SELECT
      'text'              as component,
      'Simulates how different browsers and versions connect to the server. This helps verify compatibility and whether old browsers are blocked from insecure connections.' as contents
      WHERE $tab = 'browser-simulations';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'browser-simulations';
      select simulation_id as "simulation id",severity,finding from tem_testssl_browser_simulation where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'browser-simulations';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='browser-simulations';
        ;;

     -- Rating Simulations tab
      SET total_rows = (SELECT COUNT(*) FROM tem_testssl_rating WHERE uniform_resource_id= $uniform_resource_id AND tenant_id = $tenant_id);
SET limit = COALESCE($limit, 50);
SET offset = COALESCE($offset, 0);
SET total_pages = ($total_rows + $limit - 1) / $limit;
SET current_page = ($offset / $limit) + 1;
       SELECT
      'title'   as component,
      'Rating' as contents WHERE $tab = 'rating';
      SELECT
      'text'              as component,
      'Provides an overall grade (A, B, etc.) summarizing the server’s SSL/TLS configuration strength. This is often based on industry benchmarks like SSL Labs grading.' as contents
      WHERE $tab = 'rating';
      SELECT 'table' AS component,
          TRUE AS sort,
          TRUE AS search,
          'Host' as markdown where $tab = 'rating';
      select rating_id as "rating id",severity,finding from tem_testssl_rating where uniform_resource_id= $uniform_resource_id AND tenant_id=$tenant_id AND $tab = 'rating';
      SELECT 'text' AS component,
    (SELECT CASE WHEN CAST($current_page AS INTEGER) > 1 THEN '[Previous](?limit=' || $limit || '&offset=' || ($offset - $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    || ' '
    || '(Page ' || $current_page || ' of ' || $total_pages || ") "
    || (SELECT CASE WHEN CAST($current_page AS INTEGER) < CAST($total_pages AS INTEGER) THEN '[Next](?limit=' || $limit || '&offset=' || ($offset + $limit) || COALESCE('&component=' || replace($component, ' ', '%20'), '') || COALESCE('&tab=' || replace($tab, ' ', '%20'), '') || COALESCE('&uniform_resource_id=' || replace($uniform_resource_id, ' ', '%20'), '') || COALESCE('&tenant_id=' || replace($tenant_id, ' ', '%20'), '') || ')' ELSE '' END)
    AS contents_md
 WHERE $tab='rating';
        ;