mirror of https://github.com/google/oss-fuzz.git
Modernize a bit the pygments fuzzer (#7382)
- Use atheris.instrument_all(), since pygments uses a custom importer - Get rid of the useless main(), to make the two fuzzers similar - Narrow an expected exception type Co-authored-by: Julien Voisin <jvoisin@google.com>
This commit is contained in:
parent
aa99b6f760
commit
4e962ea940
|
@ -15,24 +15,20 @@
|
|||
# limitations under the License.
|
||||
|
||||
import atheris
|
||||
with atheris.instrument_imports():
|
||||
|
||||
import sys
|
||||
import pygments
|
||||
import pygments.lexers
|
||||
import pygments.util
|
||||
|
||||
@atheris.instrument_func
|
||||
def TestOneInput(data: bytes) -> int:
|
||||
try:
|
||||
lexer = pygments.lexers.guess_lexer(str(data))
|
||||
except ValueError:
|
||||
except pygments.util.ClassNotFound:
|
||||
return 0
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
|
||||
atheris.instrument_all()
|
||||
atheris.Setup(sys.argv, TestOneInput)
|
||||
atheris.Fuzz()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
import atheris
|
||||
with atheris.instrument_imports():
|
||||
|
||||
import sys
|
||||
import pygments
|
||||
import pygments.formatters.html
|
||||
|
@ -36,5 +36,6 @@ def TestOneInput(data: bytes) -> int:
|
|||
return 0
|
||||
|
||||
|
||||
atheris.instrument_all()
|
||||
atheris.Setup(sys.argv, TestOneInput)
|
||||
atheris.Fuzz()
|
||||
|
|
Loading…
Reference in New Issue