Skip to content

Crash in binary_pattern_matching due to missing ELF path #12

@krpandrei05

Description

@krpandrei05
  • The generate command using the binary_pattern_matching heuristic crashes with a TypeError when the required --elf option is omitted.
  • The CLI should validate the presence of this argument and provide a clear error message instead of failing or producing an empty result.
  • The result is:
$ poetry run attack_surface_approximation generate --heuristic binary_pattern_matching --output examples/dictionaries/ex3.txt 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation_original/attack_surface_approximation/cli.py", line 194, in main
    cli(prog_name="attack_surface_approximation")
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation/.venv/lib/python3.12/site-packages/click/core.py", line 1514, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation/.venv/lib/python3.12/site-packages/click/core.py", line 1435, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation/.venv/lib/python3.12/site-packages/click/core.py", line 1902, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation/.venv/lib/python3.12/site-packages/click/core.py", line 1298, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation/.venv/lib/python3.12/site-packages/click/core.py", line 853, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation_original/attack_surface_approximation/cli.py", line 58, in generate
    generator.generate(heuristic, elf)
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation_original/attack_surface_approximation/dictionaries_generators/generator.py", line 63, in generate
    self.arguments = heuristic_module.generate(elf)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/krpandrei/andreiOpenCRS/attack_surface_approximation_original/attack_surface_approximation/dictionaries_generators/heuristics/binary_pattern_matching.py", line 8, in generate
    content = open(elf, "rb").read()
              ^^^^^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions