google / fuzzbench

FuzzBench - Fuzzer benchmarking as a service.
https://google.github.io/fuzzbench/
Apache License 2.0
1.11k stars 269 forks source link

lint failed while running “make presubmit” #818

Open realwatch opened 4 years ago

realwatch commented 4 years ago

when I run make presubmitor make lint ,there is always be a lint failed.

make lint

source .venv/bin/activate && python3 presubmit.py lint  
************* Module presubmit

then the error occurs

Your code has been rated at 9.95/10 (previous run: 9.95/10, +0.00)  
ERROR: lint failed, see errors above.
Failed.
Makefile:69: recipe for target 'lint' failed
make: *** [lint] Error 1

but there is some differences between this error and #555 in the information printed by pylint ,there is no E reported but only R and I debugged presubmit.py with Pycharm . It shows value of returncode = subprocess.run(command, check=False).returncode is 8 and I can't find what this value means in python official documents. My python version is 3.7.5 My system version is Ubuntu 18.04 LTS

jonathanmetzman commented 4 years ago

Thanks for reporting this issue.

Are you including the full output of make lint? can you provide it please? I can't really tell what the issue is.

While this may be inconvenient for your, it probably shouldn't block any fuzzbench development. As long as presubmit passes on CI we will land code (but I'll still try to fix this if you provide more details).

realwatch commented 4 years ago

Thanks for your help. The full output of make lint is

source .venv/bin/activate && python3 presubmit.py lint
************* Module presubmit
presubmit.py:1:0: R0801: Similar lines in 2 files
==aflcc.fuzzer:65
==klee.fuzzer:155
    if is_benchmark('systemd'):
        shutil.copy('/libAFL.a', '/usr/lib/libFuzzingEngine.a')
        ld_flags = ['-lpthread']
        utils.append_flags('LDFLAGS', ld_flags)

def add_compilation_cflags():
    """Add custom flags for certain benchmarks"""
    if is_benchmark('openthread'):
        openthread_flags = openthread_suppress_error_flags()
        utils.append_flags('CFLAGS', openthread_flags)
        utils.append_flags('CXXFLAGS', openthread_flags)

    elif is_benchmark('php'):
        php_flags = ['-D__builtin_cpu_supports\\(x\\)=0']
        utils.append_flags('CFLAGS', php_flags)
        utils.append_flags('CXXFLAGS', php_flags)

    # For some benchmarks, we also tell the compiler
    # to ignore unresolved symbols. This is useful when we cannot change
    # the build process to add a shared library for linking
    # (which contains mocked functions: libAflccMock.so).
    # Note that some functions are only defined post-compilation
    # during the LLVM passes.
    elif is_benchmark('bloaty') or is_benchmark('openssl') or is_benchmark(
            'systemd'):
        unresolved_flags = ['-Wl,--warn-unresolved-symbols']
        utils.append_flags('CFLAGS', unresolved_flags)
        utils.append_flags('CXXFLAGS', unresolved_flags)

    elif is_benchmark('curl'):
        dl_flags = ['-ldl', '-lpsl']
        utils.append_flags('CFLAGS', dl_flags)
        utils.append_flags('CXXFLAGS', dl_flags)

 (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==fastcgs_lm.fuzzer:15
==mopt.fuzzer:15
from fuzzers.afl import fuzzer as afl_fuzzer

def build():
    """Build benchmark."""
    afl_fuzzer.build()

def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""
    afl_fuzzer.prepare_fuzz_environment(input_corpus)

    afl_fuzzer.run_afl_fuzz(
        input_corpus,
        output_corpus,
        target_binary,
        additional_flags=[
            # Enable Mopt mutator with pacemaker fuzzing mode at first. This
            # is also recommended in a short-time scale evaluation.
            '-L',
            '0',
        ]) (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==aflplusplus_memcache.fuzzer:22
==aflplusplus_memcache_inf.fuzzer:22
==aflplusplus_nocycles.fuzzer:22
from fuzzers.aflplusplus import fuzzer as aflplusplus_fuzzer

def build():  # pylint: disable=too-many-branches,too-many-statements
    """Build benchmark."""
    aflplusplus_fuzzer.build()

def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""
    run_options = []

    aflplusplus_fuzzer.fuzz(input_corpus,
                            output_corpus,
                            target_binary,
                            flags=(run_options)) (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==afl.fuzzer:31
==lafintel.fuzzer:45
    os.environ['FUZZER_LIB'] = '/libAFL.a'

def build():
    """Build benchmark."""
    prepare_build_environment()

    utils.build_benchmark()

    print('[post_build] Copying afl-fuzz to $OUT directory')
    # Copy out the afl-fuzz binary as a build artifact.
    shutil.copy('/afl/afl-fuzz', os.environ['OUT'])

 (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==afl.fuzzer:89
==aflcc.fuzzer:263
    ]
    if additional_flags:
        command.extend(additional_flags)
    dictionary_path = utils.get_dictionary_path(target_binary)
    if dictionary_path:
        command.extend(['-x', dictionary_path])
    command += [
        '--',
        target_binary,
        # Pass INT_MAX to afl the maximize the number of persistent loops it
        # performs.
        '2147483647'
    ] (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==automatic_run_experiment:64
==test_automatic_run_experiment:82
        'freetype2-2017',
        'harfbuzz-1.3.2',
        'lcms-2017-03-21',
        'libjpeg-turbo-07-2017',
        'libpng-1.2.56',
        'libxml2-v2.9.2',
        'openthread-2019-12-23',
        'proj4-2017-08-14',
        're2-2014-12-09',
        'vorbis-2017-12-11',
        'woff2-2016-05-06',
    ] (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==aflfast.fuzzer:15
==fastcgs_lm.fuzzer:15
==mopt.fuzzer:15
from fuzzers.afl import fuzzer as afl_fuzzer

def build():
    """Build benchmark."""
    afl_fuzzer.build()

def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""
    afl_fuzzer.prepare_fuzz_environment(input_corpus)
 (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 10 files
==afl_fast_32.fuzzer:22
==afl_fast_branches.fuzzer:22
==afl_fast_late_32.fuzzer:22
==afl_fast_nohandicap_late_32.fuzzer:22
==afl_fast_nohits_srsly.fuzzer:22
==afl_fast_spliceless.fuzzer:22
==afl_fast_spliceless2.fuzzer:22
==afl_fast_xxh3.fuzzer:22
==afl_nohandicap_spliceless.fuzzer:22
==afl_nohandicap_spliceless2.fuzzer:22
from fuzzers.afl import fuzzer as afl_fuzzer

def build():  # pylint: disable=too-many-branches,too-many-statements
    """Build benchmark."""
    afl_fuzzer.build()

def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""

    afl_fuzzer.fuzz(input_corpus, output_corpus, target_binary) (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==automatic_run_experiment:64
==build_and_test_run_fuzzer_benchmarks:45
==test_automatic_run_experiment:82
        'freetype2-2017',
        'harfbuzz-1.3.2',
        'lcms-2017-03-21',
        'libjpeg-turbo-07-2017',
        'libpng-1.2.56',
        'libxml2-v2.9.2',
        'openthread-2019-12-23',
        'proj4-2017-08-14',
        're2-2014-12-09',
        'vorbis-2017-12-11',
        'woff2-2016-05-06', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==honggfuzz.fuzzer:15
==honggfuzz_qemu.fuzzer:15
import os
import shutil
import subprocess

from fuzzers import utils

def build():
    """Build benchmark."""
    # honggfuzz doesn't need additional libraries when code is compiled
    # with hfuzz-clang(++) (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==gsutil:65
==local_filestore:64
def rsync(  # pylint: disable=too-many-arguments
        source,
        destination,
        delete=True,
        recursive=True,
        gsutil_options=None,  # pylint: disable=unused-argument
        options=None,
        parallel=False):  # pylint: disable=unused-argument
    """Does local_filestore rsync from |source| to |destination| using sane
    defaults that can be overriden."""
    # Add check to behave like `gsutil.rsync`. (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==aflcc.fuzzer:31
==klee.fuzzer:80
def openthread_suppress_error_flags():
    """Suppress errors for openthread"""
    return [
        '-Wno-error=embedded-directive',
        '-Wno-error=gnu-zero-variadic-macro-arguments',
        '-Wno-error=overlength-strings', '-Wno-error=c++11-long-long',
        '-Wno-error=c++11-extensions', '-Wno-error=variadic-macros'
    ]

 (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==filestore_utils:64
==gsutil:65
==local_filestore:64
def rsync(  # pylint: disable=too-many-arguments
        source,
        destination,
        delete=True,
        recursive=True,
        gsutil_options=None,
        options=None,
        parallel=False):
    """Syncs |source| and |destination| folders. |gsutil_options| and |parallel|
    are only used by the gsutil implementation.""" (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==honggfuzz.fuzzer:37
==honggfuzz_qemu.fuzzer:40
def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""
    # Honggfuzz needs the output directory to exist.
    if not os.path.exists(output_corpus):
        os.makedirs(output_corpus)

    print('[fuzz] Running target with honggfuzz')
    command = [
        './honggfuzz', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==honggfuzz.fuzzer:15
==honggfuzz_qemu.fuzzer:15
==weizz_qemu.fuzzer:15
import os
import shutil
import subprocess

from fuzzers import utils

def build():
    """Build benchmark.""" (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==coverage.fuzzer:23
==libfuzzer.fuzzer:27
    utils.append_flags('CFLAGS', cflags)
    utils.append_flags('CXXFLAGS', cflags)

    os.environ['CC'] = 'clang'
    os.environ['CXX'] = 'clang++'
    os.environ['FUZZER_LIB'] = '/usr/lib/libFuzzer.a'

    utils.build_benchmark() (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==automatic_run_experiment:50
==test_automatic_run_experiment:72
    'bloaty_fuzz_target',
    'curl_curl_fuzzer_http',
    'jsoncpp_jsoncpp_fuzzer',
    'libpcap_fuzz_both',
    'libxslt_xpath',
    'mbedtls_fuzz_dtlsclient',
    'openssl_x509', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==afl.fuzzer:75
==aflcc.fuzzer:254
    command = [
        './afl-fuzz',
        '-i',
        input_corpus,
        '-o',
        output_corpus,
        # Use deterministic mode as it does best when we don't have (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==aflcc.fuzzer:297
==aflcc_no_orig_dict.fuzzer:35
        args=(input_corpus, output_corpus,
              '{target}-original'.format(target=target_binary),
              ['-S', 'slave-original']))
    afl_fuzz_thread1.start()

    print('[run_fuzzer] Running AFL for normalized and optimized dictionary')
    afl_fuzz_thread2 = threading.Thread( (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==honggfuzz.fuzzer:47
==honggfuzz_qemu.fuzzer:49
        '--rlimit_rss',
        '2048',
        '--sanitizers_del_report=true',
        '--input',
        input_corpus,
        '--output',
        output_corpus, (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==test_dispatcher:15
==test_experiment_changes:15
import os
from unittest import mock

import pytest

from database import models
from database import utils as db_utils (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 4 files
==generate_makefile:46
==test_generate_makefile:103
==test_generate_makefile:119
==test_generate_makefile:87
\tdocker run \\\n\
\t--cpus=1 \\\n\
\t--cap-add SYS_NICE \\\n\
\t--cap-add SYS_PTRACE \\\n\
\t-e FUZZ_OUTSIDE_EXPERIMENT=1 \\\n\
\t-e FORCE_LOCAL=1 \\\n\
\t-e TRIAL_ID=1 \\\n\ (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==afl.fuzzer:25
==libaflfuzzer.fuzzer:26
    cflags = ['-fsanitize-coverage=trace-pc-guard']
    utils.append_flags('CFLAGS', cflags)
    utils.append_flags('CXXFLAGS', cflags)

    os.environ['CC'] = 'clang'
    os.environ['CXX'] = 'clang++' (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 4 files
==aflplusplus_memcache.fuzzer:32
==aflplusplus_memcache_inf.fuzzer:32
==aflplusplus_nocycles.fuzzer:32
==aflplusplus_optimal.fuzzer:87
        run_options = []

    aflplusplus_fuzzer.fuzz(input_corpus,
                            output_corpus,
                            target_binary,
                            flags=(run_options)) (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==aflcc.fuzzer:305
==aflcc_no_orig_dict.fuzzer:43
        args=(input_corpus, output_corpus,
              '{target}-normalized-none-nopt'.format(target=target_binary),
              ['-S', 'slave-normalized-nopt']))
    afl_fuzz_thread2.start()

    print('[run_fuzzer] Running AFL for FBSP and optimized dictionary') (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==entropic.fuzzer:34
==entropic_magicbytes.fuzzer:24
def fuzz(input_corpus, output_corpus, target_binary):
    """Run fuzzer."""
    libfuzzer_fuzzer.run_fuzzer(input_corpus,
                                output_corpus,
                                target_binary,
                                extra_flags=[ (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==entropic.fuzzer:23
==libfuzzer.fuzzer:26
    cflags = ['-fsanitize=fuzzer-no-link']
    utils.append_flags('CFLAGS', cflags)
    utils.append_flags('CXXFLAGS', cflags)

    os.environ['CC'] = 'clang'
    os.environ['CXX'] = 'clang++' (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==measurer:31
==reporter:19
from common import experiment_utils
from common import experiment_path as exp_path
from common import filesystem
from common import filestore_utils
from common import logs
from common import utils (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==build_and_test_run_fuzzer_benchmarks:37
==test_automatic_run_experiment:77
        'mbedtls_fuzz_dtlsclient',
        'openssl_x509',
        'sqlite3_ossfuzz',
        'systemd_fuzz-link-parser',
        'zlib_zlib_uncompress_fuzzer', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 3 files
==automatic_run_experiment:50
==build_and_test_run_fuzzer_benchmarks:31
==test_automatic_run_experiment:72
    'bloaty_fuzz_target',
    'curl_curl_fuzzer_http',
    'jsoncpp_jsoncpp_fuzzer',
    'libpcap_fuzz_both',
    'libxslt_xpath', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==gcloud:53
==test_gcloud:48
    command = [
        'gcloud',
        'compute',
        'instances',
        'create', (duplicate-code)
presubmit.py:1:0: R0801: Similar lines in 2 files
==gsutil:54
==local_filestore:56
    command = ['rm', path]
    if recursive:
        command.insert(1, '-r')
    if force:
        command.insert(1, '-f') (duplicate-code)

------------------------------------------------------------------
Your code has been rated at 9.95/10 (previous run: 9.95/10, +0.00)

ERROR: lint failed, see errors above.
Failed.
Makefile:69: recipe for target 'lint' failed
make: *** [lint] Error 1

Hope it's not a big problem.

jonathanmetzman commented 4 years ago

I don't think we want to fix the errors this reported. So the question is how can we get your setup to stop reporting them. What is the output of pylint --version? For me it is:

pylint --version
pylint 2.4.4
astroid 2.3.3
Python 3.7.7 (default, May 20 2020, 19:38:38) 
[GCC 9.3.0]
realwatch commented 4 years ago

my pylint version information is:

pylint 2.4.4
astroid 2.3.3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0]

It seems like related to the python version. Should I update to python3.7.7 and try again?

jonathanmetzman commented 4 years ago

my pylint version information is:

pylint 2.4.4
astroid 2.3.3
Python 3.7.5 (default, Nov  7 2019, 10:50:52) 
[GCC 8.3.0]

It seems like related to the python version. Should I update to python3.7.7 and try again?

That might help. But I'd be somewhat surprised if that is the issue.

realwatch commented 4 years ago

I have updated both python and GCC but it didn't work.

pylint 2.4.4
astroid 2.3.3
Python 3.7.7 (default, Oct 14 2020, 15:02:00) 
[GCC 8.4.0]

So the only clue is the returncode 8 which meaning is not clear for now. I think I could just ignore it and go for next step. If it block something else , I will contact you in the future. Thanks again.

jonathanmetzman commented 4 years ago

Maybe you have some kind of dotfile for pylint that is overriding the values we set. I don't use pycharm but maybe it is doing this somehow.