How to use the pyhibp.get_pastes function in pyhibp

To help you get started, we’ve selected a few pyhibp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github matamorphosis / Scrummage / lib / plugins / Have_I_Been_Pwned.py View on Github external
pyhibp.set_api_key(key=Load_Configuration())

        except:
            logging.warning(f"{General.Date()} - {__name__.strip('plugins.')} - Failed to set API key, make sure it is set in the configuration file.")

        Query_List = General.Convert_to_List(Query_List)

        if Type_of_Query == "email":
            Local_Plugin_Name = Plugin_Name + "-" + Type_of_Query
            Cached_Data = General.Get_Cache(Directory, Local_Plugin_Name)

            if not Cached_Data:
                Cached_Data = []

            for Query in Query_List:
                Query_Response = pyhibp.get_pastes(email_address=Query)
                logging.info(Query_Response)

                if Query_Response:
                    Domain = Query_Response[0]["Source"]
                    ID = Query_Response[0]["Id"]
                    Link = "https://www." + Domain + ".com/" + ID
                    JSON_Query_Response = json.dumps(Query_Response, indent=4, sort_keys=True)

                    if Link not in Cached_Data and Link not in Data_to_Cache:
                        Output_file = General.Create_Query_Results_Output_File(Directory, Query, Plugin_Name, JSON_Query_Response, "email", The_File_Extension)

                        if Output_file:
                            Output_Connections = General.Connections(Query, Local_Plugin_Name, "haveibeenpwned.com", "Data Leakage", Task_ID, Local_Plugin_Name.lower())
                            Output_Connections.Output([Output_file], Link, General.Get_Title(Link), Concat_Plugin_Name)

                        Data_to_Cache.append(Link)

pyhibp

An interface to Troy Hunt's 'Have I Been Pwned' public API

AGPL-3.0
Latest version published 3 years ago

Package Health Score

33 / 100
Full package analysis