Beispiel #1
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        # Invocation examples
        _process("bash_curl", lexers.BashLexer())
        _process("bash_wget", lexers.BashLexer())
        _process("browser", lexers.JavascriptLexer())
        _process("crontab", lexers.BashLexer())
        _process("node", lexers.JavascriptLexer())
        _process("python_urllib2", lexers.PythonLexer())
        _process("python_requests", lexers.PythonLexer())
        _process("php", lexers.PhpLexer())
        _process("powershell", lexers.shell.PowerShellLexer())
        _process("powershell_inline", lexers.shell.BashLexer())
        _process("ruby", lexers.RubyLexer())

        # API examples
        _process("list_checks_request", lexers.BashLexer())
        _process("list_checks_response", lexers.JsonLexer())
        _process("create_check_request_a", lexers.BashLexer())
        _process("create_check_request_b", lexers.BashLexer())
        _process("update_check_request_a", lexers.BashLexer())
        _process("update_check_request_b", lexers.BashLexer())
        _process("create_check_response", lexers.JsonLexer())
        _process("pause_check_request", lexers.BashLexer())
        _process("pause_check_response", lexers.JsonLexer())
        _process("delete_check_request", lexers.BashLexer())
Beispiel #2
0
 def handle(self, *args, **options):
     _process("bash.txt", "bash.html", lexers.BashLexer())
     _process("browser.txt", "browser.html", lexers.JavascriptLexer())
     _process("crontab.txt", "crontab.html", lexers.BashLexer())
     _process("python.txt", "python.html", lexers.PythonLexer())
     _process("php.txt", "php.html", lexers.PhpLexer())
     _process("node.txt", "node.html", lexers.JavascriptLexer())
Beispiel #3
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires the Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        # Invocation examples
        _process("bash_curl", lexers.BashLexer())
        _process("bash_wget", lexers.BashLexer())
        _process("browser", lexers.JavascriptLexer())
        _process("crontab", lexers.BashLexer())
        _process("cs", lexers.CSharpLexer())
        _process("node", lexers.JavascriptLexer())
        _process("go", lexers.GoLexer())
        _process("python_urllib2", lexers.PythonLexer())
        _process("python_requests", lexers.PythonLexer())
        _process("python_requests_fail", lexers.PythonLexer())
        _process("python_requests_start", lexers.PythonLexer())
        _process("python_requests_payload", lexers.PythonLexer())
        _process("php", lexers.PhpLexer())
        _process("powershell", lexers.shell.PowerShellLexer())
        _process("powershell_inline", lexers.shell.BashLexer())
        _process("ruby", lexers.RubyLexer())
Beispiel #4
0
def main(binary):
    file_path = data_dir + binary + json_ext
    if os.path.isfile(file_path):
        print(info.safe_substitute(text="Supplied binary: " + binary))
        print(info.safe_substitute(text="Please wait, loading data ... "))
        with open(file_path) as source:
            data = source.read()

        json_data = json.loads(data)
        if 'description' in json_data:
            print('\n' + description.safe_substitute(
                description=json_data['description']))

        for vector in json_data['functions']:
            print(title.safe_substitute(title=str(vector).upper()))
            index = 0
            for code in json_data['functions'][vector]:
                index = index + 1
                if 'description' in code:
                    print(
                        description.safe_substitute(
                            description=code['description']) + '\n')
                print(
                    highlight(
                        code['code'], lexers.BashLexer(),
                        formatters.TerminalTrueColorFormatter(
                            style='igor')).strip())
                if index != len(json_data['functions'][vector]):
                    print(divider)

        print('\n' + info.safe_substitute(text="Goodbye, friend."))
    else:
        print(
            fail.safe_substitute(text="Sorry, couldn't find anything for " +
                                 binary))
Beispiel #5
0
def _get_lexer(codesyntax):
    if codesyntax in ("cpp", "javascript"):
        return lexers.JavascriptLexer()
    elif codesyntax == "python":
        return lexers.PythonLexer()
    elif codesyntax == "json":
        return lexers.JsonLexer()
    elif codesyntax == "xml" or codesyntax == "html":
        return lexers.HtmlLexer()
    elif codesyntax == "yml" or codesyntax == "yaml":
        return lexers.YamlLexer()
    elif codesyntax == "css":
        return lexers.CssLexer()
    elif codesyntax == "sql":
        return lexers.SqlLexer()
    elif codesyntax == "bash" or codesyntax == "sh":
        return lexers.BashLexer()
    elif codesyntax == "go":
        return lexers.GoLexer()
    elif codesyntax == "diff":
        return lexers.DiffLexer()
    elif codesyntax == "emacslisp":
        return lexers.EmacsLispLexer()
    elif codesyntax == "lisp":
        return lexers.CommonLispLexer()
    elif codesyntax == "rust":
        return lexers.RustLexer()
    elif codesyntax == "jsx":
        return BabylonLexer()
    elif codesyntax:
        raise NotImplementedError(codesyntax)
    else:
        return lexers.TextLexer()
Beispiel #6
0
    def handle(self, *args, **options):

        try:
            from pygments import lexers
        except ImportError:
            self.stdout.write("This command requires Pygments package.")
            self.stdout.write("Please install it with:\n\n")
            self.stdout.write("  pip install Pygments\n\n")
            return

        _process("bash.txt", "bash.html", lexers.BashLexer())
        _process("browser.txt", "browser.html", lexers.JavascriptLexer())
        _process("crontab.txt", "crontab.html", lexers.BashLexer())
        _process("python.txt", "python.html", lexers.PythonLexer())
        _process("php.txt", "php.html", lexers.PhpLexer())
        _process("powershell.txt", "powershell.html",
                 lexers.shell.PowerShellLexer())
        _process("node.txt", "node.html", lexers.JavascriptLexer())