#   Copyright 2014-present PUNCH Cyber Analytics Group
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.

"""
Overview
========

Extract and normalize Indicators of Compromise (IOC) from payloads

"""

import os
import re
import socket
import requests
from pathlib import Path
from urllib.parse import urlsplit
from configparser import ConfigParser
from typing import Dict, Set, Optional, List
from ipaddress import ip_address, ip_network
from inspect import currentframe, getframeinfo
from bs4 import UnicodeDammit

from stoq.plugins import WorkerPlugin
from stoq.helpers import StoqConfigParser
from stoq import Payload, Request, WorkerResponse


class IOCExtract(WorkerPlugin):
    """
    IOCExtract

    """

    def __init__(self, config: StoqConfigParser) -> None:
        super().__init__(config)

        self.whitelist_file = config.getlist(
            'options', 'whitelist_file', fallback=['whitelist.txt']
        )