403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.144.115.154
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/prospector/tools/dodgy/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/opt/cloudlinux/venv/lib64/python3.11/site-packages/prospector/tools/dodgy//__init__.py
import mimetypes
from pathlib import Path

from dodgy.checks import check_file_contents

from prospector.encoding import CouldNotHandleEncoding, read_py_file
from prospector.finder import FileFinder
from prospector.message import Location, Message
from prospector.tools.base import ToolBase


def module_from_path(path: Path):
    # TODO hacky...
    return ".".join(path.parts[1:-1] + (path.stem,))


class DodgyTool(ToolBase):
    def configure(self, prospector_config, found_files):
        # empty: just implementing to satisfy the ABC contract
        pass

    def run(self, found_files: FileFinder):
        warnings = []
        for filepath in found_files.files:
            mimetype = mimetypes.guess_type(str(filepath.absolute()))
            if mimetype[0] is None or not mimetype[0].startswith("text/") or mimetype[1] is not None:
                continue
            try:
                contents = read_py_file(filepath)
            except CouldNotHandleEncoding:
                continue
            for line, code, message in check_file_contents(contents):
                warnings.append({"line": line, "code": code, "message": message, "path": filepath})

        messages = []
        for warning in warnings:
            path = warning["path"]
            loc = Location(path, module_from_path(path), "", warning["line"], 0)
            msg = Message("dodgy", warning["code"], loc, warning["message"])
            messages.append(msg)

        return messages

Youez - 2016 - github.com/yon3zu
LinuXploit