Threat Intelligence Dashboard Installation

This tutorial assumes you already have a web server set up and running. If you do not, please reference the NGINX project for instructions on setting up a web server.


SSH into your web server using your preferred client. Then switch to the user that owns the web server directories.


Before starting, make sure you are in your project directory. In this example, the project is located in threat-dashboard. To navigate there, run the command below.

Terminal
cd /var/www/html/threat-dashboard


To run this project, a few prerequisites are required. First, ensure Python 3 is installed by running:

Terminal
sudo apt install python3


Next, install pip:

Terminal
sudo apt install python3-pip


You will also need the Python virtual environment package. Install it by running:

Terminal
sudo apt install python3-venv


Once installed, create a virtual environment in the current directory:

Terminal
sudo python3 -m venv venv


Activate the virtual environment:

Terminal
source venv/bin/activate


Install the required Python packages (feedparser, BeautifulSoup, and requests):

Terminal
pip install feedparser beautifulsoup4 requests


Create the required subdirectories:
/threat-dashboard/backend — stores the Python script
/threat-dashboard/data — stores the processed JSON data

Terminal
mkdir backend data


In the backend folder, create a file named fetch_feeds.py and paste the following code:
Go to Next Step ↓

#!/usr/bin/env python3

# Imports standard helpers for JSON output, text cleanup, dates, and file paths.
import json
import re
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from pathlib import Path

# Imports third-party libraries for parsing feeds, scraping articles, and making HTTP requests.
import feedparser
from bs4 import BeautifulSoup
import requests


# Builds paths relative to the threat-dashboard project and chooses where the JSON feed data will be saved.
BASE_DIR = Path(__file__).resolve().parent.parent
OUTPUT_FILE = BASE_DIR / "data" / "feeds.json"

# Defines every source the feed will pull from.
FEEDS = [
    {"name": "ZDI Upcoming", "url": "https://www.zerodayinitiative.com/rss/upcoming/", "type": "article"},
    {"name": "ZDI Published", "url": "https://www.zerodayinitiative.com/rss/published/", "type": "article"},
    {"name": "CVEFeed", "url": "https://cvefeed.io/rssfeed/latest.xml", "type": "article"},
    {"name": "Rapid7 Emergent Threat Response", "url": "https://blog.rapid7.com/tag/emergent-threat-response/rss/", "type": "article"},
    {"name": "Rapid7 Detection and Response", "url": "https://blog.rapid7.com/tag/detection-and-response/rss/", "type": "article"},
    {"name": "Rapid7 Vulnerability Management", "url": "https://blog.rapid7.com/tag/vulnerability-management/rss/", "type": "article"},
    {"name": "Rapid7 Cloud Security", "url": "https://blog.rapid7.com/tag/cloud-security/rss/", "type": "article"},
    {"name": "Microsoft Security Blog", "url": "https://www.microsoft.com/en-us/security/blog/feed/", "type": "article"},
    {"name": "Krebs on Security", "url": "https://krebsonsecurity.com/feed/", "type": "article"},
    {"name": "HackRead", "url": "https://hackread.com/feed/", "type": "article"},
    {"name": "Cisco Incident Response", "url": "https://blogs.cisco.com/tag/incident-response/feed", "type": "article"},
    {"name": "AWS Security Incident Response", "url": "https://aws.amazon.com/blogs/security/tag/incident-response/feed/", "type": "article"},
    {"name": "WindowsIR", "url": "https://windowsir.blogspot.com/feeds/posts/default", "type": "article"},
    {"name": "CrowdStrike", "url": "https://www.crowdstrike.com/en-us/blog/feed/", "type": "article"},
    {"name": "Intezer", "url": "https://intezer.com/feed/", "type": "article"},
    {"name": "DataBreaches", "url": "https://databreaches.net/feed/", "type": "article"},
    {"name": "Trend Micro Cyberthreat", "url": "https://newsroom.trendmicro.com/cyberthreat?pagetemplate=rss", "type": "article"},
    {"name": "Darknet Diaries", "url": "https://feeds.megaphone.fm/darknetdiaries", "type": "podcast"},
    {"name": "Have I Been Pwned Breaches", "url": "https://haveibeenpwned.com/feed/breaches/", "type": "article"},
]

# Converts articles into plain text.
def clean_html(raw_text):
    if not raw_text:
        return ""

    soup = BeautifulSoup(raw_text, "html.parser")
    text = soup.get_text(" ", strip=True)
    text = re.sub(r"\s+", " ", text)
    return text.strip()

# Creates a short summary for each feed item.
def make_summary(entry, feed_type):
    if feed_type == "podcast":
        return "Latest podcast episode from Darknet Diaries."

    raw_summary = (
        entry.get("summary")
        or entry.get("description")
        or entry.get("subtitle")
        or ""
    )

    summary = clean_html(raw_summary)

    if not summary:
        summary = clean_html(entry.get("title", ""))

    sentences = re.split(r"(?<=[.!?])\s+", summary)

    if sentences and sentences[0]:
        return sentences[0][:240]

    return summary[:240]

# Converts feed dates and times to UTC.
def parse_date(entry):
    date_fields = [
        entry.get("published"),
        entry.get("updated"),
        entry.get("created"),
    ]

    for date_value in date_fields:
        if not date_value:
            continue

        try:
            parsed = parsedate_to_datetime(date_value)
            if parsed.tzinfo is None:
                parsed = parsed.replace(tzinfo=timezone.utc)
            return parsed.astimezone(timezone.utc).isoformat()
        except Exception:
            pass

    return datetime.now(timezone.utc).isoformat()

# Downloads the linked article, extracting readable text for tagging.
def fetch_article_content(url):
    try:
        headers = {
            "User-Agent": "Mozilla/5.0 Threat Intelligence Dashboard"
        }

        response = requests.get(
            url,
            headers=headers,
            timeout=6,
            allow_redirects=True
        )

        if response.status_code != 200:
            return ""

        content_type = response.headers.get("Content-Type", "")

        if "text/html" not in content_type:
            return ""

        html = response.text[:250000]

        soup = BeautifulSoup(html, "html.parser")

        for tag in soup(["script", "style", "nav", "header", "footer", "aside", "form", "iframe"]):
            tag.decompose()

        paragraphs = soup.find_all("p", limit=25)

        text = " ".join(
            p.get_text(" ", strip=True)
            for p in paragraphs
            if len(p.get_text(" ", strip=True)) > 40
        )

        text = re.sub(r"\s+", " ", text).strip()

        return text[:3000]

    except Exception:
        return ""

# Assigns basic topic tags by matching keywords.
def classify_article(text):
    text = text.lower()

    keywords = {
        "Zero-Day": ["zero-day", "0day", "0-day"],
        "CVE": ["cve-", "cve "],
        "Ransomware": ["ransomware", "extortion"],
        "Malware": ["malware", "trojan", "backdoor", "loader", "stealer"],
        "Phishing": ["phishing", "credential theft", "credential harvesting"],
        "Cloud": ["aws", "azure", "cloud", "s3", "iam"],
        "Incident Response": ["incident response", "forensics", "dfir"],
        "Data Breach": ["data breach", "breach", "leaked", "exposed data"],
        "Exploit": ["exploit", "exploitation", "proof-of-concept", "poc"],
        "Patch": ["patch", "patched", "security update", "update available"],
    }

    matched_tags = []

    for tag, terms in keywords.items():
        if any(term in text for term in terms):
            matched_tags.append(tag)

    if matched_tags:
        return matched_tags

    return ["General"]

# Pulls recent entries from all configured feeds and sorts them chronologically.
def fetch_articles():
    articles = []
    seen_links = set()

    for feed in FEEDS:
        parsed_feed = feedparser.parse(feed["url"])

        for entry in parsed_feed.entries[:5]:
            title = clean_html(entry.get("title", "Untitled"))
            link = entry.get("link", "")

            if not link or link in seen_links:
                continue

            seen_links.add(link)

            summary = make_summary(entry, feed["type"])

            content = ""
            if feed["type"] != "podcast":
                content = fetch_article_content(link)

            articles.append({
                "title": title,
                "date": parse_date(entry),
                "source": feed["name"],
                "summary": summary,
                "content": content,
                "tags": classify_article(f"{title} {summary} {content}"),
                "link": link,
                "type": feed["type"],
            })

    articles.sort(key=lambda item: item["date"], reverse=True)
    return articles[:200]

# Creates the output folder if needed, fetches feed data, and writes it to feeds.json.
def main():
    OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)

    articles = fetch_articles()

    with open(OUTPUT_FILE, "w", encoding="utf-8") as file:
        json.dump(articles, file, indent=2, ensure_ascii=False)

    print(f"Saved {len(articles)} articles to {OUTPUT_FILE}")

# Runs the script when this file is executed directly.
if __name__ == "__main__":
    main()
            


Back to Top ↑

In the data folder, create a file named feeds.json. Leave this file blank as it will be populated when the script runs.


To test the setup, run the script:

Terminal
python backend/fetch_feeds.py


To verify the output:

Terminal
cat /var/www/html/threat-dashboard/data/feeds.json


To automate data collection, schedule the script using a cron job. In this example, it runs every 30 minutes.

Terminal
crontab -e


Add the following line, then save:


*/30 * * * * /var/www/html/threat-dashboard/venv/bin/python /var/www/html/threat-dashboard/backend/fetch_feeds.py
            


Confirm the cron job is configured correctly. You should see the new entry when you run:

Terminal
crontab -l


This will give you a quick setup for grabbing the data, so that you can use it how you wish. If you want to customize the feeds, or the way the data is processed, you can edit the fetch_feeds.py script as needed.


Once data collection is working, you can set up the front end. In your project directory, create a file named app.js and paste the following code:
Go to Next Step ↓

/* Global Variables */
const FEED_URL = "data/feeds.json";
const REFRESH_INTERVAL = 300000; // 5 minutes

let articles = [];
let activeSearch = "";


/* Document Object Model Elements */
const feedList = document.getElementById("feedList");
const articleCount = document.getElementById("articleCount");
const lastUpdated = document.getElementById("lastUpdated");
const refreshButton = document.getElementById("refreshButton");

const searchInput = document.getElementById("searchInput");

const readerPlaceholder = document.getElementById("readerPlaceholder");

const desktopArticleCard = document.getElementById("desktopArticleCard");
const desktopArticleSource = document.getElementById("desktopArticleSource");
const desktopArticleTitle = document.getElementById("desktopArticleTitle");
const desktopArticleDate = document.getElementById("desktopArticleDate");
const desktopArticleSummary = document.getElementById("desktopArticleSummary");
const desktopArticleLink = document.getElementById("desktopArticleLink");

const mobileArticleModal = document.getElementById("mobileArticleModal");
const mobileArticleSource = document.getElementById("mobileArticleSource");
const mobileArticleTitle = document.getElementById("mobileArticleTitle");
const mobileArticleDate = document.getElementById("mobileArticleDate");
const mobileArticleSummary = document.getElementById("mobileArticleSummary");
const mobileArticleLink = document.getElementById("mobileArticleLink");
const closeModalButton = document.getElementById("closeModalButton");


/* Fetch Feed Data */
async function fetchArticles() {
  try {
    const response = await fetch(`${FEED_URL}?cacheBust=${Date.now()}`);

    if (!response.ok) {
      throw new Error(`Feed request failed: ${response.status}`);
    }

    articles = await response.json();

    renderFeedList(getFilteredArticles());
    updateDashboardStatus();

    localStorage.setItem("threatDashboardLastSeen", new Date().toISOString());

  } catch (error) {
    console.error("Unable to load feed data:", error);

    feedList.innerHTML = `
      <p class="loading-message">
        Unable to load threat intelligence feeds.
      </p>
    `;
  }
}


/* Render Article List */
function renderFeedList(items = articles) {
  feedList.innerHTML = "";

  if (!items.length) {
    feedList.innerHTML = `
      <p class="loading-message">
        No articles are currently available.
      </p>
    `;
    return;
  }

  items.forEach((article, index) => {
    const feedItem = document.createElement("article");

    feedItem.className = "feed-item";
    feedItem.tabIndex = 0;

    feedItem.innerHTML = `
    <div class="feed-title">
        ${isNewArticle(article) ? '<span class="new-badge">[*]</span>' : ""}
        ${escapeHTML(article.title)}
    </div>
    <div class="feed-meta">
        ${escapeHTML(article.source)} • ${formatDate(article.date)}
    </div>
    <div class="tag-row">
        ${(article.tags || []).map(tag => `<span class="tag-badge">${escapeHTML(tag)}</span>`).join("")}
    </div>
    <div class="feed-summary">
        ${escapeHTML(article.summary || "No summary available.")}
    </div>
    `;

    feedItem.addEventListener("click", () => openArticle(article));

    feedItem.addEventListener("keydown", (event) => {
      if (event.key === "Enter") {
        openArticle(article);
      }
    });

    feedList.appendChild(feedItem);
  });
}

function getFilteredArticles() {
  if (!activeSearch) {
    return articles;
  }

  const query = activeSearch.toLowerCase();

  return articles.filter((article) => {
    const searchableText = `
      ${article.title || ""}
      ${article.source || ""}
      ${article.summary || ""}
      ${article.content || ""}
      ${(article.tags || []).join(" ")}
    `.toLowerCase();

    return searchableText.includes(query);
  });
}

function isNewArticle(article) {
  const lastSeen = localStorage.getItem("threatDashboardLastSeen");

  if (!lastSeen || !article.date) {
    return false;
  }

  return new Date(article.date) > new Date(lastSeen);
}

/* Open Article */
function openArticle(article) {
  localStorage.setItem("threatDashboardLastSeen", new Date().toISOString());

  const isMobile = window.matchMedia("(max-width: 768px)").matches;

  if (isMobile) {
    openMobileArticle(article);
  } else {
    openDesktopArticle(article);
  }
}


/* Desktop Article */
function openDesktopArticle(article) {
  readerPlaceholder.classList.add("is-hidden");
  desktopArticleCard.classList.remove("is-hidden");

  desktopArticleSource.textContent = article.source || "Unknown source";
  desktopArticleTitle.textContent = article.title || "Untitled";
  desktopArticleDate.textContent = formatDate(article.date);
  desktopArticleSummary.textContent = article.content || article.summary || "No article preview available.";
  desktopArticleLink.href = article.link;
}


/* Mobile Article */
function openMobileArticle(article) {
  mobileArticleSource.textContent = article.source || "Unknown source";
  mobileArticleTitle.textContent = article.title || "Untitled";
  mobileArticleDate.textContent = formatDate(article.date);
  mobileArticleSummary.textContent = article.content || article.summary || "No article preview available.";
  mobileArticleLink.href = article.link;

  mobileArticleModal.classList.remove("is-hidden");
  document.body.style.overflow = "hidden";
}

function closeMobileArticle() {
  mobileArticleModal.classList.add("is-hidden");
  document.body.style.overflow = "";
}


/* Update Dashboard Status */
function updateDashboardStatus() {
  articleCount.textContent = `${articles.length} feed items loaded`;

  const now = new Date();

  lastUpdated.textContent = `Last updated: ${now.toLocaleTimeString([], {
    hour: "2-digit",
    minute: "2-digit"
  })}`;
}


/* Article Date */
function formatDate(dateString) {
  if (!dateString) {
    return "Unknown date";
  }

  const date = new Date(dateString);

  if (Number.isNaN(date.getTime())) {
    return "Unknown date";
  }

  return date.toLocaleDateString([], {
    year: "numeric",
    month: "short",
    day: "numeric"
  });
}


/* Prevents feed content from injecting unwanted markup. */
function escapeHTML(value) {
  return String(value)
    .replaceAll("&", "&")
    .replaceAll("<", "<")
    .replaceAll(">", ">")
    .replaceAll('"', """)
    .replaceAll("'", "'");
}


/* Event Listeners */
if (refreshButton) {
  refreshButton.addEventListener("click", fetchArticles);
}

if (closeModalButton) {
  closeModalButton.addEventListener("click", closeMobileArticle);
}

document.addEventListener("keydown", (event) => {
  if (event.key === "Escape" && mobileArticleModal && !mobileArticleModal.classList.contains("is-hidden")) {
    closeMobileArticle();
  }
});

if (searchInput) {
  searchInput.addEventListener("input", () => {
    activeSearch = searchInput.value.trim();
    renderFeedList(getFilteredArticles());
  });
}


/* Auto Refresh */
setInterval(fetchArticles, REFRESH_INTERVAL);


/* Initial Load */
fetchArticles();
                


Back to Top ↑

Now that the application code is in place, you can create the UI. In your project directory, create a file called index.html. Enter the code below, and save.
Go to Next Step ↓


Back to Top ↑

Everything is almost ready. It is time to give the UI some color and styling. In your project directory, create a file called styles.css. Enter the code below, and save.
Go to Bottom ↓

/* CSS Variables */
/* Shared color palette. */
:root {
  --bg-dark: #240024;
  --panel-main: #490049;
  --panel-alt: #5a045a;
  --panel-deep: #380238;
  --accent: #74006e;
  --text: #ffffff;
  --muted: #f0f0f0;
}

/* Fonts */
@font-face {
  font-family: "lulo";
  src: url("../fonts/lulo.otf") format("opentype");
}

@font-face {
  font-family: "avenir";
  src: url("../fonts/avenir.ttf") format("truetype");
}

/* Global Styles */
html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-dark);
  color: var(--text);
  font-family: "avenir", sans-serif;
}

/* Shell */
.dashboard-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--panel-main);
  border-bottom: 2px solid var(--accent);
}

/* Main dashboard title. */
.dashboard-header h1 {
  font-family: "lulo", sans-serif;
  margin: 0;
  font-size: 20px;
}

.dashboard-header p {
  margin: 5px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.dashboard-status {
  text-align: right;
  font-size: 12px;
}

/* Main Layout */
.dashboard-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left Panel */
.feed-panel {
  width: 35%;
  background: var(--panel-deep);
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--accent);
}

.feed-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: var(--panel-main);
}

.feed-panel-header h2 {
  margin: 0;
  font-size: 14px;
}

.feed-panel-header button {
  background: var(--accent);
  border: none;
  color: white;
  padding: 5px 10px;
  cursor: pointer;
}

.feed-panel-header button:hover {
  background: var(--panel-alt);
}

/* Article list */
.feed-list {
  overflow-y: auto;
  flex: 1;
}

/* Article list items */
.feed-item {
  padding: 10px;
  border-bottom: 1px solid var(--panel-alt);
  cursor: pointer;
}

.feed-item:hover {
  background: var(--panel-main);
}

.feed-title {
  font-weight: bold;
  font-size: 13px;
}

.feed-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

.feed-summary {
  font-size: 12px;
  margin-top: 5px;
}

/* Right Panel */
.reader-panel {
  flex: 1;
  background: rgb(53, 0, 46);
  position: relative;
  overflow: hidden;
}

.reader-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
}

#articleFrame {
  width: 100%;
  height: 100%;
  border: none;
}

/* Fallback information when article content cannot be loaded */
.reader-fallback {
  background: var(--panel-deep);
  border-bottom: 2px solid var(--accent);
  padding: 10px;
  font-size: 13px;
}

.reader-fallback p {
  margin: 0 0 5px;
}

.reader-fallback a {
  color: var(--text);
  text-decoration: underline;
}

.desktop-article-card {
  max-width: 85%;
  margin: 40px auto;
  padding: 25px;
  background: var(--panel-deep);
  border: 2px solid var(--accent);
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.desktop-article-source {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.desktop-article-card h2 {
  margin: 0 0 10px;
  font-family: "lulo", sans-serif;
  font-size: 20px;
}

.desktop-article-date {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
}

.desktop-article-card p {
  font-size: 16px;
  line-height: 2;
}

.desktop-open-link {
  display: inline-block;
  margin-top: 20px;
  background: var(--accent);
  color: var(--text);
  padding: 10px 15px;
  text-decoration: none;
}

.desktop-open-link:hover {
  background: var(--panel-alt);
}

/* Mobile Modal */
.mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-article-card {
  margin: 60px 15px 20px;
  padding: 20px;
  background: var(--panel-deep);
  border: 2px solid var(--accent);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--accent);
  border: none;
  color: white;
  padding: 5px 10px;
  cursor: pointer;
  z-index: 1001;
}

.modal-close:hover {
  background: var(--panel-alt);
}

#mobileArticleFrame {
  width: 100%;
  height: 100%;
  border: none;
}

/* Loading */
.loading-message {
  padding: 15px;
  font-size: 12px;
  color: var(--muted);
}

/* Scrollbar */
.feed-list::-webkit-scrollbar {
  width: 6px;
}

.feed-list::-webkit-scrollbar-thumb {
  background: var(--accent);
}


/* Search */
.search-input {
  width: calc(100% - 20px);
  margin: 10px;
  padding: 8px;
  background: var(--panel-deep);
  border: 1px solid var(--accent);
  color: var(--text);
}

.search-input::placeholder {
  color: var(--muted);
}

/* Unread items */ 
.new-badge {
  color: #ffffff;
  margin-right: 5px;
  font-weight: bold;
}

/* Tags */
.tag-row {
  margin-top: 6px;
}

.tag-badge {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 2px 6px;
  background: var(--accent);
  color: var(--text);
  font-size: 10px;
}

/* Mobile Styles */
@media (max-width: 768px) {

  .dashboard-layout {
    flex-direction: column;
  }

  .feed-panel {
    width: 100%;
    height: 100%;
  }

  .reader-panel {
    display: none;
  }

}

.is-hidden {
  display: none !important;
}


Back to Top ↑

Now that everything is up and running, consider customizing your dashboard. You can add additional feeds, modify how data is processed, or expand tagging and filtering functionality. The code is fully open and designed to be flexible.

Loading...