<commit_before><div class="page-header">
  <div class="btn-toolbar pull-right">
    <div class="btn-group btn-group-sm">
      <%= link_to '<span class="glyphicon glyphicon-flag"> Filters</span>'.html_safe, filters_path, { :class => 'btn btn-default' } %>
    </div>
  </div>
  <h1 class="pull-left">
    <%= pluralize(@alerts.count, 'Alert') %>
  </h1>

  <%= form_tag(alerts_path, :method => "get", :class => "form-inline text-center", :role => "form") do %>
    <div class="form-group">
      <%= search_field_tag :q, params[:q], :placeholder => "Search", :class => "form-control" %>
    </div>
    <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
    <% unless params[:q].blank? %>
      <%= link_to "clear", alerts_path(source: params[:source], class_name: params[:class_name], level: params[:level], hostname: params[:hostname]), class: "btn" %>
    <% end %>
  <% end %>
</div>

<div class="article">&nbsp;
  <div class="btn-toolbar pull-left">
    <% if @servers.length > 1 %>
      <div class="btn-group btn-group-sm">
        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @hostname.nil? ? "All Hosts" : h(@hostname) %> <span class="caret"></span></a>
        <ul class="dropdown-menu">
          <li><%= link_to "All Hosts", alerts_path(class_name: params[:class_name], level: params[:level], q: params[:q]) %></li>
          <li class="divider"></li>
          <% @servers.each do |hostname| %>
            <li><%= link_to hostname, alerts_path(source: params[:source], class_name: params[:class_name], level: params[:level], hostname: hostname, q: params[:q]) %></li>
          <% end %>
        </ul>
      </div>
    <% end %>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @source.nil? ? "All Sources" : @source.display_name %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Sources", alerts_path(class_name: params[:class_name], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
        <% Group.order("id").each do |group| %>
          <% unless group.sources.active.empty? %>
            <li class="divider"></li>
            <% group.sources.active.each do |source| %>
              <li><%= link_to h(source.display_name), alerts_path(source: source.name, class_name: params[:class_name], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
            <% end %>
          <% end %>
        <% end %>
      </ul>
    </div>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @level.nil? ? "All Levels" : @level.titleize %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Levels", alerts_path(class_name: params[:class_name], source: params[:source], hostname: params[:hostname], q: params[:q]) %></li>
        <li class="divider"></li>
        <% Alert::LEVELS[1..-1].each do |level| %>
        <li><%= link_to h(level.titleize), alerts_path(level: level.downcase, class_name: params[:class_name], source: params[:source], hostname: params[:hostname], q: params[:q]) %></li>
        <% end %>
      </ul>
    </div>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @class_name.nil? ? "All Alerts" : h(@class_name) %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Alerts", alerts_path(source: params[:source], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
        <li class="divider"></li>
        <% alerts.each do |alert| %>
          <% if alert == "-" %>
            <li class="divider"></li>
          <% else %>
            <li><%= link_to h(alert), alerts_path(class_name: alert, source: params[:source], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
          <% end %>
        <% end %>
      </ul>
    </div>
  </div>
</div>

<% if @alerts.size > 0 %>
  <div class="panel-group" id="alert">
    <% @alerts.each do |alert| %>
      <div class="panel panel-default">
        <div class="panel-heading panel-title panel-list">
          <% if alert.level != 3 %><span class="pull-right"><%= level_label(alert.level).html_safe %></span><% end %>
          <%= link_to ((alert.status.blank? ? "" : "[#{alert.status}] ") + h(alert.message)).html_safe, "#alert_#{alert.id}", :class => "accordion-toggle", :id => "link_#{alert.id}", :data => { :toggle => "collapse", :parent => "#alert" }, :href => "#alert_#{alert.id}" %>
        </div>
        <div class="panel-collapse collapse" id="alert_<%= alert.id %>">
          <div class="panel-body alert-inner">
            <% if can?(:destroy, Alert) %>
              <div class="btn-group btn-group-sm pull-right">
                <a class="btn btn-default dropdown-toggle" id="<%= alert.id %>-delete" data-toggle="dropdown" href="#">
                  <span class="glyphicon glyphicon-trash"></span> <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                  <li><%= link_to "by Message", alert_path(alert, q: params[:q],
                                                                  source: params[:source],
                                                                  level: params[:level],
                                                                  class_name: params[:class_name],
                                                                  hostname: params[:hostname],
                                                                  page: params[:page]),
                                                                  method: :delete,
                                                                  data: { :confirm => 'Are you sure?' },
                                                                  remote: true,
                                                                  id: "#{alert.id}-delete-message" %></li>
                  <li><%= link_to "by Class", alert_path(alert, q: params[:q],
                                                                source: params[:source],
                                                                level: params[:level],
                                                                class_name: params[:class_name],
                                                                hostname: params[:hostname],
                                                                filter: "class_name",
                                                                page: params[:page]),
                                                                method: :delete,
                                                                data: { :confirm => 'Are you sure?' },
                                                                remote: true,
                                                                id: "#{alert.id}-delete-class" %></li>
                  <% unless alert.source_id.nil? %>
                    <li><%= link_to "by Source", alert_path(alert, q: params[:q],
                                                                   source: params[:source],
                                                                   level: params[:level],
                                                                   class_name: params[:class_name],
                                                                   hostname: params[:hostname],
                                                                   filter: "source",
                                                                   page: params[:page]),
                                                                   method: :delete,
                                                                   data: { :confirm => 'Are you sure?' },
                                                                   remote: true,
                                                                   id: "#{alert.id}-delete-source" %></li>
                  <% end %>
                </ul>
              </div>
            <% end %>
            <p class="class_name"><%= link_to alert.class_name, alerts_path(class_name: h(alert.class_name),
                                                                            source: params[:source],
                                                                            level: params[:level],
                                                                            hostname: params[:hostname],
                                                                            q: params[:q]) %></p>
            <% unless alert.source_id.blank? %>
              <h5>Source</h5>
              <%= link_to alert.source.display_name, source_path(alert.source) %>
            <% end %>

            <% unless alert.article_id.blank? %>
              <h5>Article</h5>
              <%= link_to alert.article.uid, article_path(alert.article) %>
            <% end %>

            <h5>Time</h5>
            <%= alert.created_at.to_s(:friendly) %>

            <% unless alert.hostname.blank? %>
              <h5>Hostname</h5>
              <%= alert.hostname %>
            <% end %>

            <% unless alert.content_type.blank? or alert.content_type == "text/html" %>
              <h5>Content Type</h5>
              <%= alert.content_type %>
            <% end %>

            <% unless alert.target_url.blank? %>
              <h5>Target URL</h5>
              <%= link_to alert.target_url, alert.target_url %>
            <% end %>

            <% if ["Net::HTTPUnauthorized","ActionDispatch::RemoteIp::IpSpoofAttackError"].include? alert.class_name %>
              <% unless alert.remote_ip.blank? %>
                <h5>Remote IP</h5>
                <%= link_to alert.remote_ip, alert.remote_ip %>
              <% end %>

              <% unless alert.user_agent.blank? %>
                <h5>User Agent</h5>
                <%= alert.user_agent %>
              <% end %>
            <% end %>

            <% unless alert.details.blank? %>
              <h5>Details</h5>
              <%= h(alert.details) %>
            <% end %>

            <% unless alert.trace.blank? %>
              <h5>Trace</h5>
              <%= simple_format(alert.trace) %>
            <% end %>
          </div>
        </div>
      </div><commit_msg>show sanitized html from network error<commit_after><div class="page-header">
  <div class="btn-toolbar pull-right">
    <div class="btn-group btn-group-sm">
      <%= link_to '<span class="glyphicon glyphicon-flag"> Filters</span>'.html_safe, filters_path, { :class => 'btn btn-default' } %>
    </div>
  </div>
  <h1 class="pull-left">
    <%= pluralize(@alerts.count, 'Alert') %>
  </h1>

  <%= form_tag(alerts_path, :method => "get", :class => "form-inline text-center", :role => "form") do %>
    <div class="form-group">
      <%= search_field_tag :q, params[:q], :placeholder => "Search", :class => "form-control" %>
    </div>
    <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
    <% unless params[:q].blank? %>
      <%= link_to "clear", alerts_path(source: params[:source], class_name: params[:class_name], level: params[:level], hostname: params[:hostname]), class: "btn" %>
    <% end %>
  <% end %>
</div>

<div class="article">&nbsp;
  <div class="btn-toolbar pull-left">
    <% if @servers.length > 1 %>
      <div class="btn-group btn-group-sm">
        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @hostname.nil? ? "All Hosts" : h(@hostname) %> <span class="caret"></span></a>
        <ul class="dropdown-menu">
          <li><%= link_to "All Hosts", alerts_path(class_name: params[:class_name], level: params[:level], q: params[:q]) %></li>
          <li class="divider"></li>
          <% @servers.each do |hostname| %>
            <li><%= link_to hostname, alerts_path(source: params[:source], class_name: params[:class_name], level: params[:level], hostname: hostname, q: params[:q]) %></li>
          <% end %>
        </ul>
      </div>
    <% end %>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @source.nil? ? "All Sources" : @source.display_name %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Sources", alerts_path(class_name: params[:class_name], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
        <% Group.order("id").each do |group| %>
          <% unless group.sources.active.empty? %>
            <li class="divider"></li>
            <% group.sources.active.each do |source| %>
              <li><%= link_to h(source.display_name), alerts_path(source: source.name, class_name: params[:class_name], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
            <% end %>
          <% end %>
        <% end %>
      </ul>
    </div>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @level.nil? ? "All Levels" : @level.titleize %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Levels", alerts_path(class_name: params[:class_name], source: params[:source], hostname: params[:hostname], q: params[:q]) %></li>
        <li class="divider"></li>
        <% Alert::LEVELS[1..-1].each do |level| %>
        <li><%= link_to h(level.titleize), alerts_path(level: level.downcase, class_name: params[:class_name], source: params[:source], hostname: params[:hostname], q: params[:q]) %></li>
        <% end %>
      </ul>
    </div>
    <div class="btn-group btn-group-sm">
      <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"><span class="glyphicon glyphicon-filter"></span> <%= @class_name.nil? ? "All Alerts" : h(@class_name) %> <span class="caret"></span></a>
      <ul class="dropdown-menu">
        <li><%= link_to "All Alerts", alerts_path(source: params[:source], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
        <li class="divider"></li>
        <% alerts.each do |alert| %>
          <% if alert == "-" %>
            <li class="divider"></li>
          <% else %>
            <li><%= link_to h(alert), alerts_path(class_name: alert, source: params[:source], level: params[:level], hostname: params[:hostname], q: params[:q]) %></li>
          <% end %>
        <% end %>
      </ul>
    </div>
  </div>
</div>

<% if @alerts.size > 0 %>
  <div class="panel-group" id="alert">
    <% @alerts.each do |alert| %>
      <div class="panel panel-default">
        <div class="panel-heading panel-title panel-list">
          <% if alert.level != 3 %><span class="pull-right"><%= level_label(alert.level).html_safe %></span><% end %>
          <%= link_to ((alert.status.blank? ? "" : "[#{alert.status}] ") + h(alert.message)).html_safe, "#alert_#{alert.id}", :class => "accordion-toggle", :id => "link_#{alert.id}", :data => { :toggle => "collapse", :parent => "#alert" }, :href => "#alert_#{alert.id}" %>
        </div>
        <div class="panel-collapse collapse" id="alert_<%= alert.id %>">
          <div class="panel-body alert-inner">
            <% if can?(:destroy, Alert) %>
              <div class="btn-group btn-group-sm pull-right">
                <a class="btn btn-default dropdown-toggle" id="<%= alert.id %>-delete" data-toggle="dropdown" href="#">
                  <span class="glyphicon glyphicon-trash"></span> <span class="caret"></span>
                </a>
                <ul class="dropdown-menu">
                  <li><%= link_to "by Message", alert_path(alert, q: params[:q],
                                                                  source: params[:source],
                                                                  level: params[:level],
                                                                  class_name: params[:class_name],
                                                                  hostname: params[:hostname],
                                                                  page: params[:page]),
                                                                  method: :delete,
                                                                  data: { :confirm => 'Are you sure?' },
                                                                  remote: true,
                                                                  id: "#{alert.id}-delete-message" %></li>
                  <li><%= link_to "by Class", alert_path(alert, q: params[:q],
                                                                source: params[:source],
                                                                level: params[:level],
                                                                class_name: params[:class_name],
                                                                hostname: params[:hostname],
                                                                filter: "class_name",
                                                                page: params[:page]),
                                                                method: :delete,
                                                                data: { :confirm => 'Are you sure?' },
                                                                remote: true,
                                                                id: "#{alert.id}-delete-class" %></li>
                  <% unless alert.source_id.nil? %>
                    <li><%= link_to "by Source", alert_path(alert, q: params[:q],
                                                                   source: params[:source],
                                                                   level: params[:level],
                                                                   class_name: params[:class_name],
                                                                   hostname: params[:hostname],
                                                                   filter: "source",
                                                                   page: params[:page]),
                                                                   method: :delete,
                                                                   data: { :confirm => 'Are you sure?' },
                                                                   remote: true,
                                                                   id: "#{alert.id}-delete-source" %></li>
                  <% end %>
                </ul>
              </div>
            <% end %>
            <p class="class_name"><%= link_to alert.class_name, alerts_path(class_name: h(alert.class_name),
                                                                            source: params[:source],
                                                                            level: params[:level],
                                                                            hostname: params[:hostname],
                                                                            q: params[:q]) %></p>
            <% unless alert.source_id.blank? %>
              <h5>Source</h5>
              <%= link_to alert.source.display_name, source_path(alert.source) %>
            <% end %>

            <% unless alert.article_id.blank? %>
              <h5>Article</h5>
              <%= link_to alert.article.uid, article_path(alert.article) %>
            <% end %>

            <h5>Time</h5>
            <%= alert.created_at.to_s(:friendly) %>

            <% unless alert.hostname.blank? %>
              <h5>Hostname</h5>
              <%= alert.hostname %>
            <% end %>

            <% unless alert.content_type.blank? or alert.content_type == "text/html" %>
              <h5>Content Type</h5>
              <%= alert.content_type %>
            <% end %>

            <% unless alert.target_url.blank? %>
              <h5>Target URL</h5>
              <%= link_to alert.target_url, alert.target_url %>
            <% end %>

            <% if ["Net::HTTPUnauthorized","ActionDispatch::RemoteIp::IpSpoofAttackError"].include? alert.class_name %>
              <% unless alert.remote_ip.blank? %>
                <h5>Remote IP</h5>
                <%= link_to alert.remote_ip, alert.remote_ip %>
              <% end %>

              <% unless alert.user_agent.blank? %>
                <h5>User Agent</h5>
                <%= alert.user_agent %>
              <% end %>
            <% end %>

            <% unless alert.details.blank? %>
              <h5>Details</h5>
              <%= sanitize alert.details %>
            <% end %>

            <% unless alert.trace.blank? %>
              <h5>Trace</h5>
              <%= simple_format(alert.trace) %>
            <% end %>
          </div>
        </div>
      </div>
{'fraction_non_alphanumeric': 0.16085965483555845, 'fraction_numerical': 0.0025119784155928733, 'mean_word_length': 1.3825778565887177, 'pattern_counts': {'":': 0, '<': 439, '<?xml version=': 0, '>': 473, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 144, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6416066', 'n_tokens_mistral': 5714, 'n_tokens_neox': 5314, 'n_words': 1121}