<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>CVE Report</title>
  <link
    rel="stylesheet"
    href="https://cdn.jsdelivr.net/npm/@tabler/core@latest/dist/css/tabler.min.css"
  />
  <style>
    @import url("https://rsms.me/inter/inter.css");

    :root {
      --tblr-font-sans-serif: Inter, -apple-system, BlinkMacSystemFont,
        San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif !important;
      --main-color: #2c3e50;
      --info-color: #a1b8c7;
    }

    body {
      font-family: var(--tblr-font-sans-serif);
    }

    .page-title {
      color: var(--main-color);
    }

    .card-header-light {
      background-color: var(--info-color);
      color: #fff;
    }

    .table th,
    .table td {
      padding: 0.15rem;
      vertical-align: top;
      border-top: none;
    }

    .table th {
      text-align: left;
    }

    .table-sm th,
    .table-sm td {
      border: none;
    }

    .table-sm th:first-child,
    .table-sm td:first-child {
      width: 200px;
      text-align: left;
    }

    .table {
      table-layout: fixed;
    }

    .icon {
      margin-right: 0.5rem;
    }

    .mb-3 {
      margin-bottom: 1.5rem !important;
    }

    .mb-4 {
      margin-bottom: 2rem !important;
    }

    h4 {
      margin-top: 0;
    }
  </style>
</head>
<body>
  <div class="page">
    <div class="container-xl">
      <div class="page-header page-header-border">
        <div class="container-fluid">
          <div class="row align-items-center">
            <div class="col">
              <h2 class="page-title">SploitScan</h2>
              <div class="text-secondary mt-1">CVE Report</div>
            </div>
            <div class="col-auto">
              <div class="btn-list">
                <a href="https://github.com/xaitax/SploitScan" class="btn">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    class="icon icon-tabler icon-tabler-brand-github"
                    width="24"
                    height="24"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="#2c3e50"
                    fill="none"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                    <path
                      d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2
                        c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0
                        -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6
                        -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0
                        -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5"
                    />
                  </svg>
                  GitHub
                </a>
                <a href="https://x.com/xaitax" class="btn d-none d-md-inline-flex">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    class="icon icon-tabler icon-tabler-brand-x"
                    width="24"
                    height="24"
                    viewBox="0 0 24 24"
                    stroke-width="1.5"
                    stroke="#2c3e50"
                    fill="none"
                    stroke-linecap="round"
                    stroke-linejoin="round"
                  >
                    <path stroke="none" d="M0 0h24v24H0z" fill="none" />
                    <path d="M4 4l11.733 16h4.267l-11.733 -16z" />
                    <path
                      d="M4 20l6.768 -6.768m2.46 -2.46l6.772 -6.772"
                    />
                  </svg>
                  Twitter/X
                </a>
              </div>
            </div>
          </div>
        </div>
      </div>

      <br />

      {% for cve in cve_data %}
      {# -------------------------------------------------------------------------
         Use local variables to reduce repetitive checks while preserving output
         ------------------------------------------------------------------------- #}
      {% set cve_meta = cve['CVE Data'].get('cveMetadata', {}) if cve['CVE Data'] else {} %}
      {% set containers = cve['CVE Data'].get('containers', {}) if cve['CVE Data'] else {} %}
      {% set cna = containers.get('cna', {}) %}
      {% set metrics = cna.get('metrics', []) %}
      {% set references = cna.get('references', []) %}
      {% set descriptions = cna.get('descriptions', []) %}
      {% set description = descriptions[0]['value'] if descriptions else 'N/A' %}
      {% set cve_id = cve_meta.get('cveId', 'N/A') %}
      {% set date_published = cve_meta.get('datePublished', None) %}
      {% set base_score = metrics[0]['cvssV3_1']['baseScore']
         if metrics and metrics[0].get('cvssV3_1') else 'N/A' %}
      {% set base_severity = metrics[0]['cvssV3_1']['baseSeverity']
         if metrics and metrics[0].get('cvssV3_1') else 'N/A' %}
      {% set vector_string = metrics[0]['cvssV3_1']['vectorString']
         if metrics and metrics[0].get('cvssV3_1') else 'N/A' %}

      <div class="card mb-4">
        <div class="card-header card-header-light">
          <h3 class="card-title">
            <a name="{{ cve_meta['CVE ID'] if cve_meta.get('CVE ID') else cve_id }}"></a>
            {{ cve_id }}
          </h3>
        </div>
        <div class="card-body">
          <div class="mb-3">
            <h4><span class="icon">🔍</span> Vulnerability Information</h4>
            <p>{{ description }}</p>
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>Published</td>
                  <td>
                    {# Using 'datetimeformat' filter if date_published is valid #}
                    {{ date_published|datetimeformat if date_published else 'N/A' }}
                  </td>
                </tr>
                <tr>
                  <td>Base Score</td>
                  <td>
                    {{ base_score }} ({{ base_severity }})
                  </td>
                </tr>
                <tr>
                  <td>Vector</td>
                  <td>{{ vector_string }}</td>
                </tr>
              </tbody>
            </table>
          </div>

          <div class="mb-3">
            <h4><span class="icon">♾️</span> Exploit Prediction Score (EPSS)</h4>
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>Score</td>
                  {% if cve['EPSS Data'] and cve['EPSS Data'].get('data') %}
                  <td>
                    {{ "%.2f" % (cve['EPSS Data']['data'][0]['epss'] * 100) }}%
                    Probability of exploitation
                  </td>
                  {% else %}
                  <td>N/A</td>
                  {% endif %}
                </tr>
              </tbody>
            </table>
          </div>

          <div class="mb-3">
            <h4><span class="icon">🛡️</span> CISA KEV Catalog</h4>
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>Listed</td>
                  <td>
                    {{ cve['CISA Data']['cisa_status'] if cve['CISA Data'] else 'N/A' }}
                  </td>
                </tr>
                <tr>
                  <td>Ransomware</td>
                  <td>
                    {{ cve['CISA Data']['ransomware_use'] if cve['CISA Data'] else 'N/A' }}
                  </td>
                </tr>
              </tbody>
            </table>
          </div>

          <div class="mb-3">
            <h4>
              <span class="icon">💣</span>
              Public Exploits (Total: {{ cve['Public Exploits Total'] }})
            </h4>
            {% if cve['GitHub Data']['pocs'] %}
            <div class="mb-3">
              <h4>GitHub</h4>
              <table class="table table-sm">
                <tbody>
                  {% for poc in cve['GitHub Data']['pocs'] %}
                  <tr>
                    <td>{{ poc['created_at']|datetimeformat }}</td>
                    <td>
                      <a href="{{ poc['html_url'] }}" target="_blank">
                        {{ poc['html_url'] }}
                      </a>
                    </td>
                  </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
            {% endif %}

            {% if cve['VulnCheck Data']['data'] %}
            <div class="mb-3">
              <h4>VulnCheck</h4>
              <table class="table table-sm">
                <tbody>
                  {% for item in cve['VulnCheck Data']['data'] %}
                  {% for xdb in item['vulncheck_xdb'] %}
                  <tr>
                    <td>{{ xdb['date_added']|datetimeformat }}</td>
                    <td>
                      <a
                        href="{{ xdb['clone_ssh_url']
                          .replace('git@github.com:', 'https://github.com/')
                          .replace('.git', '') }}"
                        target="_blank"
                      >
                        {{ xdb['clone_ssh_url']
                          .replace('git@github.com:', 'https://github.com/')
                          .replace('.git', '') }}
                      </a>
                    </td>
                  </tr>
                  {% endfor %}
                  {% endfor %}
                </tbody>
              </table>
            </div>
            {% endif %}

            {% if cve['ExploitDB Data'] %}
            <div class="mb-3">
              <h4>Exploit-DB</h4>
              <table class="table table-sm">
                <tbody>
                  {% for item in cve['ExploitDB Data'] %}
                  <tr>
                    <td>{{ item['date']|datetimeformat }}</td>
                    <td>
                      <a
                        href="https://www.exploit-db.com/exploits/{{ item['id'] }}"
                        target="_blank"
                      >
                        https://www.exploit-db.com/exploits/{{ item['id'] }}
                      </a>
                    </td>
                  </tr>
                  {% endfor %}
                </tbody>
              </table>
            </div>
            {% endif %}

            <div class="mb-3">
              <h4>Other</h4>
              <table class="table table-sm">
                <tbody>
                  {% if cve['PacketStorm Data']['packetstorm_url'] %}
                  <tr>
                    <td>PacketStorm</td>
                    <td>
                      <a
                        href="{{ cve['PacketStorm Data']['packetstorm_url'] }}"
                        target="_blank"
                      >
                        {{ cve['PacketStorm Data']['packetstorm_url'] }}
                      </a>
                    </td>
                  </tr>
                  {% endif %}
                  {% if cve['Nuclei Data']['file_path'] %}
                  <tr>
                    <td>Nuclei</td>
                    <td>
                      <a
                        href="
                          https://raw.githubusercontent.com/
                          projectdiscovery/nuclei-templates/main/
                          {{ cve['Nuclei Data']['file_path'] }}"
                        target="_blank"
                      >
                        {{ cve['Nuclei Data']['file_path'] }}
                      </a>
                    </td>
                  </tr>
                  {% endif %}
                </tbody>
              </table>
            </div>
          </div>

          <div class="mb-3">
            <h4><span class="icon">🕵️</span> HackerOne Hacktivity</h4>
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>Rank</td>
                  <td>
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['rank'] }}
                    {% else %}
                      N/A
                    {% endif %}
                  </td>
                </tr>
                <tr>
                  <td>Reports Submitted</td>
                  <td>
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['reports_submitted_count'] }}
                    {% else %}
                      N/A
                    {% endif %}
                  </td>
                </tr>
                <tr>
                  <td>Severity</td>
                  <td>
                    🔍 Unknown:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_unknown'] }}
                    {% else %}
                      0
                    {% endif %}
                    ,
                    🚫 None:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_none'] }}
                    {% else %}
                      0
                    {% endif %}
                    ,
                    ⚠️ Low:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_low'] }}
                    {% else %}
                      0
                    {% endif %}
                    ,
                    🔧 Medium:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_medium'] }}
                    {% else %}
                      0
                    {% endif %}
                    ,
                    🔥 High:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_high'] }}
                    {% else %}
                      0
                    {% endif %}
                    ,
                    💀 Critical:
                    {% if cve['HackerOne Data']
                          and cve['HackerOne Data'].get('data')
                          and cve['HackerOne Data']['data'].get('cve_entry') %}
                      {{ cve['HackerOne Data']['data']['cve_entry']['severity_count_critical'] }}
                    {% else %}
                      0
                    {% endif %}
                  </td>
                </tr>
              </tbody>
            </table>
          </div>

          <div class="mb-3">
            <h4><span class="icon">🤖</span> AI-Powered Risk Assessment</h4>
            <pre style="white-space: pre-wrap;">
{{ cve['Risk Assessment'] }}
            </pre>
          </div>

          <div class="mb-3">
            <h4><span class="icon">⚠️</span> Patching Priority Rating</h4>
            <table class="table table-sm">
              <tbody>
                <tr>
                  <td>Priority</td>
                  <td>
                    {% if cve['Priority'] and cve['Priority']['Priority'] %}
                      {{ cve['Priority']['Priority'] }}
                    {% else %}
                      N/A
                    {% endif %}
                  </td>
                </tr>
              </tbody>
            </table>
          </div>

          <div class="mb-3">
            <h4><span class="icon">📚</span> Further References</h4>
            <table class="table table-sm">
              <tbody>
                {% if references %}
                  {% for ref in references %}
                  <ul>
                    <li>
                      <a href="{{ ref['url'] }}" target="_blank">
                        {{ ref['url'] }}
                      </a>
                    </li>
                  </ul>
                  {% endfor %}
                {% else %}
                  <tr>
                    <td>N/A</td>
                  </tr>
                {% endif %}
              </tbody>
            </table>
          </div>
        </div>
      </div>
      {% endfor %}
    </div>
  </div>

  <script
    src="https://cdn.jsdelivr.net/npm/@tabler/core@latest/dist/js/tabler.min.js"
  ></script>
</body>
</html>
