Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash if .py file is a broken link #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions creosote.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ def scan(directory):
# glob only uses "/", this breaks for windows so we need to replace with the os sep
filename = filename.replace("/", os.sep)

# open the file and try to read, sometimes fails due to illegal characters in the file
with open(filename, "r") as f:
try:
try:
# open the file and try to read, sometimes fails due to illegal characters in the file
with open(filename, "r") as f:
text = f.read()

# if it fails, catch the exception and print out the error message and filename
except Exception as e:
tabbed_print("Error reading file:" + filename, 2)
tabbed_print(str(e), 3)
continue
# if tarfile is in the source code then analyze the source
if "tarfile" in text:

# create an analyzer for the file
analyzer = Analyzer(filename, text)

# if tarfile is in the source code then analyze the source
if "tarfile" in text:

# create an analyzer for the file
analyzer = Analyzer(filename, text)
# if there were any results, add the file to the list
if analyzer.has_results():
files_with_vulns.append(analyzer)

# if there were any results, add the file to the list
if analyzer.has_results():
files_with_vulns.append(analyzer)
# if it fails, catch the exception and print out the error message and filename
except Exception as e:
tabbed_print("Error reading file:" + filename, 2)
tabbed_print(str(e), 3)
continue

# give the user an update when the run is complete
tabbed_print("Scan Completed", 2)
Expand Down Expand Up @@ -223,4 +223,4 @@ def main():

# call main
if __name__ == "__main__":
main()
main()