intelmq.bots.parsers.shodan package

Submodules

intelmq.bots.parsers.shodan.parser module

Shodan Stream Parser

Copyright (C) 2018 by nic.at GmbH

intelmq.bots.parsers.shodan.parser.BOT

alias of ShodanParserBot

exception intelmq.bots.parsers.shodan.parser.NoValueException(msg: str | None = None)

Bases: Exception

Raised in a conversion function in case the value cannot be used, e.g when trying to get the first item of an empty list

msg: str | None
class intelmq.bots.parsers.shodan.parser.ShodanParserBot(*args, **kwargs)

Bases: ParserBot

Parse Shodan data collected via the Shodan API

apply_mapping(mapping: Dict[str, Any], data: Dict[str, Any], key_path: Tuple[str, ...] = ()) Dict[str, Any]
ignore_errors = True
minimal_mode = False
process() None
intelmq.bots.parsers.shodan.parser._dict_dict_to_obj_list(x: Dict[str, Dict[str, Any]], identifier: str = 'identifier') List[Dict[str, Any]]

convert e.g {‘OuterKey1’: {‘InnerKey1’: ‘Value1’}, ‘OuterKey2’: {‘InnerKey2’: ‘Value2’}} to [{‘identifier’: ‘OuterKey1’, ‘InnerKey’: ‘Value1}, {‘identifier’: ‘OuterKey2’, ‘InnerKey’: ‘Value2’}}]

intelmq.bots.parsers.shodan.parser._get_first(variable: List[Any]) Any

get first element from list, if the list has any; raise NoValueException otherwise

intelmq.bots.parsers.shodan.parser._get_first_fqdn(variable: List[str]) str

get first valid FQDN from a list of strings

intelmq.bots.parsers.shodan.parser._keys_conversion(x: Dict[str, Any]) List[str]

extracts object keys to a list, for cases where the values they map to are empty/irrelevant

intelmq.bots.parsers.shodan.parser._maybe_single_to_list(x: Any) List[Any]

converts non-list objects to lists with a single item and leaves lists as-is, used to harmonize fields which avoid lists when a single value is given

Module contents