Add option to *not* print out results. Configure tests to there is no print output. This simplifies looking at the error output when the tests fail.

pull/350/head
Christopher K. Hoadley 5 years ago
parent f29cab49e4
commit 8f6938ecb1

@ -185,7 +185,8 @@ def get_response(request_future, error_type, social_network, verbose=False, colo
def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False, def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False,
proxy=None, print_found_only=False, timeout=None, color=True): proxy=None, print_found_only=False, timeout=None, color=True,
print_output=True):
"""Run Sherlock Analysis. """Run Sherlock Analysis.
Checks for existence of username on various social media sites. Checks for existence of username on various social media sites.
@ -198,9 +199,12 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False,
tor -- Boolean indicating whether to use a tor circuit for the requests. tor -- Boolean indicating whether to use a tor circuit for the requests.
unique_tor -- Boolean indicating whether to use a new tor circuit for each request. unique_tor -- Boolean indicating whether to use a new tor circuit for each request.
proxy -- String indicating the proxy URL proxy -- String indicating the proxy URL
print_found_only -- Boolean indicating whether to only print found sites.
timeout -- Time in seconds to wait before timing out request. timeout -- Time in seconds to wait before timing out request.
Default is no timeout. Default is no timeout.
color -- Boolean indicating whether to color terminal output color -- Boolean indicating whether to color terminal output
print_output -- Boolean indicating whether the output should be
printed. Default is True.
Return Value: Return Value:
Dictionary containing results from report. Key of dictionary is the name Dictionary containing results from report. Key of dictionary is the name
@ -215,7 +219,8 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False,
response_text: Text that came back from request. May be None if response_text: Text that came back from request. May be None if
there was an HTTP error when checking for existence. there was an HTTP error when checking for existence.
""" """
print_info("Checking username", username, color) if print_output == True:
print_info("Checking username", username, color)
# Create session based on request methodology # Create session based on request methodology
if tor or unique_tor: if tor or unique_tor:
@ -265,7 +270,7 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False,
regex_check = net_info.get("regexCheck") regex_check = net_info.get("regexCheck")
if regex_check and re.search(regex_check, username) is None: if regex_check and re.search(regex_check, username) is None:
# No need to do the check at the site: this user name is not allowed. # No need to do the check at the site: this user name is not allowed.
if not print_found_only: if (print_output == True) and not print_found_only:
print_invalid(social_network, "Illegal Username Format For This Site!", color) print_invalid(social_network, "Illegal Username Format For This Site!", color)
results_site['status'] = QueryResult(QueryStatus.ILLEGAL) results_site['status'] = QueryResult(QueryStatus.ILLEGAL)
@ -398,20 +403,22 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False,
f"site '{social_network}'") f"site '{social_network}'")
if result.status == QueryStatus.CLAIMED: if print_output == True:
print_found(social_network, url, response_time, verbose, color) #Output to the terminal is desired.
elif result.status == QueryStatus.AVAILABLE: if result.status == QueryStatus.CLAIMED:
if not print_found_only: print_found(social_network, url, response_time, verbose, color)
print_not_found(social_network, response_time, verbose, color) elif result.status == QueryStatus.AVAILABLE:
elif result.status == QueryStatus.UNKNOWN: if not print_found_only:
print_error(social_network, expection_text, error_text, "", verbose, color) print_not_found(social_network, response_time, verbose, color)
elif result.status == QueryStatus.ILLEGAL: elif result.status == QueryStatus.UNKNOWN:
if not print_found_only: print_error(social_network, expection_text, error_text, "", verbose, color)
print_invalid(social_network, "Illegal Username Format For This Site!", color) elif result.status == QueryStatus.ILLEGAL:
else: if not print_found_only:
#It should be impossible to ever get here... print_invalid(social_network, "Illegal Username Format For This Site!", color)
raise ValueError(f"Unknown Query Status '{str(result.status)}' for " else:
f"site '{social_network}'") #It should be impossible to ever get here...
raise ValueError(f"Unknown Query Status '{str(result.status)}' for "
f"site '{social_network}'")
# Save status of request # Save status of request

@ -108,7 +108,9 @@ class SherlockBaseTest(unittest.TestCase):
verbose=self.verbose, verbose=self.verbose,
tor=self.tor, tor=self.tor,
unique_tor=self.unique_tor, unique_tor=self.unique_tor,
timeout=self.timeout timeout=self.timeout,
color=False,
print_output=False
) )
for site, result in results.items(): for site, result in results.items():
with self.subTest(f"Checking Username '{username}' " with self.subTest(f"Checking Username '{username}' "

Loading…
Cancel
Save