kira2040k / php_code_analysis

MIT License
94 stars 22 forks source link

File seen as folder #1

Closed mdaxido closed 3 years ago

mdaxido commented 3 years ago

Hi, Running a scan on a Wordpress site, some files are misinterpreted as folders.

Traceback (most recent call last): File "/root/_Tools/php_code_analysis/code.py", line 38, in <module> scan_files_in_folder(argv[1]) File "/root/_Tools/php_code_analysis/code.py", line 23, in scan_files_in_folder scan_files_in_folder(f"{path}/{i}") File "/root/_Tools/php_code_analysis/code.py", line 23, in scan_files_in_folder scan_files_in_folder(f"{path}/{i}") File "/root/_Tools/php_code_analysis/code.py", line 23, in scan_files_in_folder scan_files_in_folder(f"{path}/{i}") [Previous line repeated 4 more times] File "/root/_Tools/php_code_analysis/code.py", line 7, in scan_files_in_folder folders = listdir(path) NotADirectoryError: [Errno 20] Not a directory: '/srv/www/htdocs/wordpress/wp-content/plugins/wp-user-avatar/vendor/symfony/css-selector/LICENSE'

This is indeed a file : -rw-rwxr--+ 1 www-data www-data 1065 May 23 02:01 /srv/www/htdocs/wordpress/wp-content/plugins/wp-user-avatar/vendor/symfony/css-selector/LICENSE

Regards, M

mdaxido commented 3 years ago

Ok, got it. for i in folders: if ("." not in i): scan_files_in_folder(f"{path}/{i}") --> Not all files do have extensions ...

mdaxido commented 3 years ago

One might use (line 22) if os.path.isdir(f"{path}/{i}"): With import os

mdaxido commented 3 years ago

Pull request created ;)