from fluidasserts.lang import python from fluidasserts.lang import docker from fluidasserts.sca import pypi ASSERTS_DIRS = ['fluidasserts', 'test'] DOCKERFILES = ['Dockerfile.builder', 'Dockerfile.base', 'Dockerfile.runner'] EXCLUDED_DIRS = ['test/static'] for adir in ASSERTS_DIRS: python.swallows_exceptions(adir, EXCLUDED_DIRS) python.has_generic_exceptions(adir, EXCLUDED_DIRS) for dockerfile in DOCKERFILES: docker.not_pinned(dockerfile) pypi.project_has_vulnerabilities('.')
#!/usr/bin/python3 from fluidasserts.lang import python from fluidasserts.lang import javascript from fluidasserts.sca import pypi from fluidasserts.sca import npm import os try: project_dir = os.environ["CI_PROJECT_DIR"] except KeyError: project_dir = os.getcwd() py_dest = project_dir python.swallows_exceptions(py_dest) python.has_generic_exceptions(py_dest) js_dest = project_dir + '/app/assets/app' javascript.has_switch_without_default(js_dest) javascript.swallows_exceptions(js_dest) javascript.has_insecure_randoms(js_dest) javascript.uses_console_log(js_dest) dep_cont = project_dir + '/deploy/containers/deps/' pypi.project_has_vulnerabilities(dep_cont) front = project_dir + '/front/' npm.project_has_vulnerabilities(front)
import sys from fluidasserts.lang import python python.has_generic_exceptions(sys.modules['fluidasserts'].__path__[0])
def test_has_generic_exceptions_close(): """Code uses generic exceptions.""" assert not python.has_generic_exceptions(SECURE_CODE) assert not python.has_generic_exceptions(NON_EXISTANT_CODE) assert not python.has_generic_exceptions(CODE_DIR, exclude=['test'])
def test_has_generic_exceptions_in_dir_open(): """Code uses generic exceptions.""" assert python.has_generic_exceptions(CODE_DIR)
def test_has_generic_exceptions_open(): """Code uses generic exceptions.""" assert python.has_generic_exceptions(INSECURE_CODE)