Repository: smicallef/spiderfoot
File: modules/sfp_threatjammer.py (Python)

Code before:
                "Navigate to https://threatjammer.com/keys",
                "The API Keys are listed under 'API Key' column"
            ],
            'favIcon': "https://threatjammer.com/favicon.ico",
            'logo': "https://threatjammer.com/threatjammer-risk-score.png",
            'description': "Threat Jammer is a service to access high-quality threat intelligence"
            " data from a variety of sources, and integrate it into their applications with the"
            " sole purpose of detecting and blocking malicious activity."
        }
    }

    opts = {
        'api_key': '',
        "risk_score_min": 35,
        'checkaffiliates': True,
    }

    optdescs = {
        'api_key': "ThreatJammer.com API key.",
        "risk_score_min": "Minimum Threat Jammer risk score.",
        'checkaffiliates': "Apply checks to affiliates?",
    }

    results = None

    def setup(self, sfc, userOpts=dict()):
        self.sf = sfc
        self.results = self.tempStorage()

        for opt in list(userOpts.keys()):
            self.opts[opt] = userOpts[opt]

    def watchedEvents(self):
        return [
            "IP_ADDRESS",
            "IPV6_ADDRESS",
            "AFFILIATE_IPADDR",
            "AFFILIATE_IPV6_ADDRESS",
        ]

    def producedEvents(self):
        return [
            "BLACKLISTED_IPADDR",
            "BLACKLISTED_AFFILIATE_IPADDR",
            "MALICIOUS_IPADDR",
            "MALICIOUS_AFFILIATE_IPADDR",
        ]

    def queryIp(self, ip):
        """Query API for an IPv4 or IPv6 address.


Review comment (suggestion):
```suggestion
    results = None
    errorState = False
```

Code after:
                "Navigate to https://threatjammer.com/keys",
                "The API Keys are listed under 'API Key' column"
            ],
            'favIcon': "https://threatjammer.com/favicon.ico",
            'logo': "https://threatjammer.com/threatjammer-risk-score.png",
            'description': "Threat Jammer is a service to access high-quality threat intelligence"
            " data from a variety of sources, and integrate it into their applications with the"
            " sole purpose of detecting and blocking malicious activity."
        }
    }

    opts = {
        'api_key': "",
        'api_hostname': "dublin.api.threatjammer.com",
        'risk_score_min': 35,
        'checkaffiliates': True,
    }

    optdescs = {
        'api_key': "API key",
        'api_hostname': "User API hostname",
        'risk_score_min': "Minimum Threat Jammer risk score",
        'checkaffiliates': "Apply checks to affiliates?",
    }

    results = None
    errorState = False

    def setup(self, sfc, userOpts=dict()):
        self.sf = sfc
        self.results = self.tempStorage()
        self.errorState = False

        for opt in list(userOpts.keys()):
            self.opts[opt] = userOpts[opt]

    def watchedEvents(self):
        return [
            "IP_ADDRESS",
            "IPV6_ADDRESS",
            "AFFILIATE_IPADDR",
            "AFFILIATE_IPV6_ADDRESS",
        ]

    def producedEvents(self):
        return [
            "BLACKLISTED_IPADDR",
            "BLACKLISTED_AFFILIATE_IPADDR",
            "MALICIOUS_IPADDR",
            "MALICIOUS_AFFILIATE_IPADDR",
        ]