How to use the dlint.linters function in dlint

To help you get started, we’ve selected a few dlint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github duo-labs / dlint / tests / test_bad_urllib3_kwarg_use.py View on Github external
from ssl import CERT_NONE

            urllib3.PoolManager(cert_reqs="CERT_NONE")
            urllib3.ProxyManager(cert_reqs="CERT_NONE")
            urllib3.HTTPSConnectionPool(cert_reqs="NONE")
            urllib3.connection_from_url(cert_reqs=ssl.CERT_NONE)
            urllib3.proxy_from_url(cert_reqs=CERT_NONE)
            """
        )

        linter = dlint.linters.BadUrllib3KwargUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=7,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=8,
                col_offset=0,
                message=dlint.linters.BadUrllib3KwargUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=9,
github duo-labs / dlint / tests / test_bad_requests_use.py View on Github external
linter = dlint.linters.BadRequestsUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.BadRequestsUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=5,
                col_offset=0,
                message=dlint.linters.BadRequestsUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=dlint.linters.BadRequestsUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=7,
                col_offset=0,
                message=dlint.linters.BadRequestsUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=8,
                col_offset=0,
                message=dlint.linters.BadRequestsUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=9,
github duo-labs / dlint / tests / test_bad_pickle_use.py View on Github external
python_node = self.get_ast_node(
            """
            import pickle

            var = 'test'

            pickle.loads(var)

            with open('data.pickle', 'r') as f:
                pickle.load(f)
                up = pickle.Unpickler(f)
                up.load()
            """
        )

        linter = dlint.linters.BadPickleUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=6,
                col_offset=0,
                message=dlint.linters.BadPickleUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=9,
                col_offset=4,
                message=dlint.linters.BadPickleUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=10,
github duo-labs / dlint / tests / test_twisted / test_inlinecallbacks_yield_statement.py View on Github external
                @defer.inlineCallbacks
                def inner_func():
                    return

                yield 'foo'
                return
            """
        )

        linter = dlint.linters.InlineCallbacksYieldStatementLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=9 if IS_PYTHON_3_8 else 8,
                col_offset=4,
                message=dlint.linters.InlineCallbacksYieldStatementLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_gl_use.py View on Github external
def test_bad_gl_usage(self):
        python_node = self.get_ast_node(
            """
            import gl
            """
        )

        linter = dlint.linters.BadGlUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=2,
                col_offset=0,
                message=dlint.linters.BadGlUseLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_onelogin_module_attribute_use.py View on Github external
def test_bad_onelogin_module_attribute_usage_from_import(self):
        python_node = self.get_ast_node(
            """
            from onelogin.saml2.utils import OneLogin_Saml2_Constants

            OneLogin_Saml2_Constants.SHA1
            OneLogin_Saml2_Constants.RSA_SHA1
            OneLogin_Saml2_Constants.DSA_SHA1
            OneLogin_Saml2_Constants.TRIPLEDES_CBC
            """
        )

        linter = dlint.linters.BadOneLoginModuleAttributeUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=4,
                col_offset=0,
                message=dlint.linters.BadOneLoginModuleAttributeUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=5,
                col_offset=0,
                message=dlint.linters.BadOneLoginModuleAttributeUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=6,
github duo-labs / dlint / tests / test_bad_dl_use.py View on Github external
def test_bad_dl_usage(self):
        python_node = self.get_ast_node(
            """
            import dl
            """
        )

        linter = dlint.linters.BadDlUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=2,
                col_offset=0,
                message=dlint.linters.BadDlUseLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_commands_use.py View on Github external
def test_bad_commands_usage(self):
        python_node = self.get_ast_node(
            """
            import commands
            """
        )

        linter = dlint.linters.BadCommandsUseLinter()
        linter.visit(python_node)

        result = linter.get_results()
        expected = [
            dlint.linters.base.Flake8Result(
                lineno=2,
                col_offset=0,
                message=dlint.linters.BadCommandsUseLinter._error_tmpl
            )
        ]

        assert result == expected
github duo-labs / dlint / tests / test_bad_os_use.py View on Github external
message=dlint.linters.BadOSUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=10,
                col_offset=0,
                message=dlint.linters.BadOSUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=11,
                col_offset=0,
                message=dlint.linters.BadOSUseLinter._error_tmpl
            ),
            dlint.linters.base.Flake8Result(
                lineno=12,
                col_offset=0,
                message=dlint.linters.BadOSUseLinter._error_tmpl
            ),
        ]

        assert result == expected