From 608fa9690b6961b237b9e38fc6ec7c0916f92d1b Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 2 Apr 2019 20:45:55 +0200 Subject: Add support for blocking files Files are blocked if blocked_reason is non-NULL. This value is currently not exposed publicly, instead a 404 will be returned. Files are scanned using virustotal.com's public API if scanned is False. Scans are performed by the fbin-scanner.py script. If a match is found, blocked_reason is set to the payload received. Files that are not in VT's database will be automatically submitted and the script will wait for the scan to complete before continuing. --- fbin/db.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'fbin/db.py') diff --git a/fbin/db.py b/fbin/db.py index 58bf8ab..2bf153b 100644 --- a/fbin/db.py +++ b/fbin/db.py @@ -4,7 +4,7 @@ import mimetypes import os from flask import current_app -from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, Index, ForeignKey, Boolean +from sqlalchemy import create_engine, Column, Integer, String, DateTime, Text, Index, ForeignKey, Boolean, JSON from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker, relation, backref from sqlalchemy.orm.exc import NoResultFound @@ -52,6 +52,8 @@ class File(Base): user_id = Column(Integer, ForeignKey('users.id'), nullable = True) ip = Column(String) accessed = Column(DateTime) + scanned = Column(Boolean, nullable=False, default=False) + blocked_reason = Column(JSON) def __init__(self, hash, filename, date, user_id = None, ip = None): self.hash = hash -- cgit v1.2.3