Remove severity and quality scoring, classifier is extraction-only
This commit is contained in:
+4
-35
@@ -47,19 +47,11 @@ class ThreatIntelBot:
|
||||
self,
|
||||
token: str,
|
||||
subscribers_file: str = "subscribers.json",
|
||||
min_quality_score: int = 0,
|
||||
allowed_severities: str = "critical,high,medium,low",
|
||||
):
|
||||
self.token = token
|
||||
self.subscribers_file = subscribers_file
|
||||
self.subscribers: Dict[str, Dict[str, Any]] = {}
|
||||
self.classifier = ContentClassifier()
|
||||
self.min_quality_score = max(0, min(min_quality_score, 100))
|
||||
self.allowed_severities = {
|
||||
value.strip().lower()
|
||||
for value in allowed_severities.split(",")
|
||||
if value.strip()
|
||||
} or {"critical", "high", "medium", "low"}
|
||||
self.application = None
|
||||
self.monitoring_task = None
|
||||
self.load_subscribers()
|
||||
@@ -442,29 +434,17 @@ class ThreatIntelBot:
|
||||
batch_seen_content.add(content_key)
|
||||
unique_articles.append(article)
|
||||
|
||||
# Send alerts for new articles
|
||||
# Classify and send all unique articles
|
||||
sent_count = 0
|
||||
filtered_articles = []
|
||||
for article in unique_articles:
|
||||
classified = self.classifier.classify_article(article)
|
||||
if classified.get("quality_score", 0) < self.min_quality_score:
|
||||
continue
|
||||
if classified.get("severity", "low") not in self.allowed_severities:
|
||||
continue
|
||||
filtered_articles.append(classified)
|
||||
|
||||
for article in filtered_articles:
|
||||
sent = await self.send_alert(article)
|
||||
sent = await self.send_alert(classified)
|
||||
if sent:
|
||||
sent_count += 1
|
||||
# Small delay to avoid rate limiting
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if unique_articles:
|
||||
logger.info(
|
||||
f"Processed {len(unique_articles)} unique new articles; "
|
||||
f"after filters {len(filtered_articles)}; delivered {sent_count}"
|
||||
)
|
||||
logger.info(f"Processed {len(unique_articles)} unique articles, delivered {sent_count}")
|
||||
else:
|
||||
logger.info("No new articles found")
|
||||
|
||||
@@ -571,18 +551,7 @@ def main():
|
||||
logger.info("2. Create .env file with: BOT_TOKEN=your_token")
|
||||
return
|
||||
|
||||
# Create and run bot
|
||||
try:
|
||||
min_quality_score = int(os.getenv("MIN_QUALITY_SCORE", "0"))
|
||||
except ValueError:
|
||||
logger.warning("Invalid MIN_QUALITY_SCORE; defaulting to 0")
|
||||
min_quality_score = 0
|
||||
allowed_severities = os.getenv("ALLOWED_SEVERITIES", "critical,high,medium,low")
|
||||
bot = ThreatIntelBot(
|
||||
bot_token,
|
||||
min_quality_score=min_quality_score,
|
||||
allowed_severities=allowed_severities,
|
||||
)
|
||||
bot = ThreatIntelBot(bot_token)
|
||||
|
||||
try:
|
||||
asyncio.run(bot.run())
|
||||
|
||||
Reference in New Issue
Block a user