prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Error while pushing sigma to misp using sigma2misp script
  (venv) hydra@Kaushals-MacBook-Air session2/sigma (master %) » tools/sigma2misp @misp.conf --insecure --same-event --info "Test Event" -r rules/windows/sysmon                                           2 ↵
  Traceback (most recent call last):
    File "tools/sigma2misp", line 57, in <module>
      eventid = create_new_event()
    File "tools/sigma2misp", line 14, in create_new_event
      event = misp.MISPEvent()
  AttributeError: 'PyMISP' object has no attribute 'MISPEvent'
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `tools/sigma/sigma2misp.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 # Import given Sigma rules to MISP
  3 
  4 import argparse
  5 import pathlib
  6 import urllib3
  7 urllib3.disable_warnings()
  8 from pymisp import PyMISP
  9 
  10 def create_new_event(args, misp):
  11     if hasattr(misp, "new_event"):
  12         return misp.new_event(info=args.info)["Event"]["id"]
  13     
  14     event = misp.MISPEvent()
  15     event.info = args.info
  16     return misp.add_event(event)["Event"]["id"]
  17 
  18 
  19 class MISPImportArgumentParser(argparse.ArgumentParser):
  20     def __init__(self, *args, **kwargs):
  21         super().__init__(
  22             description="Import Sigma rules into MISP events",
  23             epilog="Parameters can be read from a file by a @filename parameter. The file should contain one parameter per line. Dashes may be omitted.",
  24             fromfile_prefix_chars="@",
  25         )
  26 
  27     def convert_arg_line_to_args(self, line : str):
  28         return ("--" + line.lstrip("--")).split()
  29 
  30 def main():
  31     argparser = MISPImportArgumentParser()
  32     argparser.add_argument("--url", "-u", default="https://localhost", help="URL of MISP instance")
  33     argparser.add_argument("--key", "-k", required=True, help="API key")
  34     argparser.add_argument("--insecure", "-I", action="store_false", help="Disable TLS certifcate validation.")
  35     argparser.add_argument("--event", "-e", type=int, help="Add Sigma rule to event with this ID. If not set, create new event.")
  36     argparser.add_argument("--same-event", "-s", action="store_true", help="Import all Sigma rules to the same event, if no event is set.")
  37     argparser.add_argument("--info", "-i", default="Sigma import", help="Event Information field for newly created MISP event.")
  38     argparser.add_argument("--recursive", "-r", action="store_true", help="Recursive traversal of directory")
  39     argparser.add_argument("sigma", nargs="+", help="Sigma rule file that should be imported")
  40     args = argparser.parse_args()
  41 
  42     if args.recursive:
  43         paths = [ p for pathname in args.sigma for p in pathlib.Path(pathname).glob("**/*") if p.is_file() ]
  44     else:
  45         paths = [ pathlib.Path(sigma) for sigma in args.sigma ]
  46 
  47     misp = PyMISP(args.url, args.key, args.insecure)
  48     if args.event:
  49         if hasattr(misp, "get"):
  50             eventid = misp.get(args.event)["Event"]["id"]
  51         else:
  52             eventid = misp.get_event(args.event)["Event"]["id"]
  53 
  54     first = True
  55 
  56     for sigma in paths:
  57         if not args.event and (first or not args.same_event):
  58             eventid = create_new_event(args, misp)
  59         print("Importing Sigma rule {} into MISP event {}...".format(sigma, eventid, end=""))
  60         f = sigma.open("rt")
  61 
  62         if hasattr(misp, "add_named_attribute"):
  63             misp.add_named_attribute(eventid, "sigma", f.read())
  64         else:
  65             event = misp.get_event(eventid, pythonify=True)
  66             event.add_attribute("sigma", f.read())
  67             misp.update_event(event)
  68 
  69         f.close()
  70         first = False
  71 
  72 if __name__ == "__main__":
  73     main()
  74
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/tools/sigma/sigma2misp.py b/tools/sigma/sigma2misp.py
  --- a/tools/sigma/sigma2misp.py
  +++ b/tools/sigma/sigma2misp.py
  @@ -5,13 +5,13 @@
   import pathlib
   import urllib3
   urllib3.disable_warnings()
  -from pymisp import PyMISP
  +from pymisp import PyMISP, MISPEvent
   
   def create_new_event(args, misp):
       if hasattr(misp, "new_event"):
           return misp.new_event(info=args.info)["Event"]["id"]
       
  -    event = misp.MISPEvent()
  +    event = MISPEvent()
       event.info = args.info
       return misp.add_event(event)["Event"]["id"]
  
verification_info: {"golden_diff": "diff --git a/tools/sigma/sigma2misp.py b/tools/sigma/sigma2misp.py\n--- a/tools/sigma/sigma2misp.py\n+++ b/tools/sigma/sigma2misp.py\n@@ -5,13 +5,13 @@\n import pathlib\n import urllib3\n urllib3.disable_warnings()\n-from pymisp import PyMISP\n+from pymisp import PyMISP, MISPEvent\n \n def create_new_event(args, misp):\n     if hasattr(misp, \"new_event\"):\n         return misp.new_event(info=args.info)[\"Event\"][\"id\"]\n     \n-    event = misp.MISPEvent()\n+    event = MISPEvent()\n     event.info = args.info\n     return misp.add_event(event)[\"Event\"][\"id\"]\n", "issue": "Error while pushing sigma to misp using sigma2misp script\n(venv) hydra@Kaushals-MacBook-Air session2/sigma (master %) \u00bb tools/sigma2misp @misp.conf --insecure --same-event --info \"Test Event\" -r rules/windows/sysmon                                           2 \u21b5\r\nTraceback (most recent call last):\r\n  File \"tools/sigma2misp\", line 57, in <module>\r\n    eventid = create_new_event()\r\n  File \"tools/sigma2misp\", line 14, in create_new_event\r\n    event = misp.MISPEvent()\r\nAttributeError: 'PyMISP' object has no attribute 'MISPEvent'\n", "before_files": [{"content": "#!/usr/bin/env python3\n# Import given Sigma rules to MISP\n\nimport argparse\nimport pathlib\nimport urllib3\nurllib3.disable_warnings()\nfrom pymisp import PyMISP\n\ndef create_new_event(args, misp):\n    if hasattr(misp, \"new_event\"):\n        return misp.new_event(info=args.info)[\"Event\"][\"id\"]\n    \n    event = misp.MISPEvent()\n    event.info = args.info\n    return misp.add_event(event)[\"Event\"][\"id\"]\n\n\nclass MISPImportArgumentParser(argparse.ArgumentParser):\n    def __init__(self, *args, **kwargs):\n        super().__init__(\n            description=\"Import Sigma rules into MISP events\",\n            epilog=\"Parameters can be read from a file by a @filename parameter. The file should contain one parameter per line. Dashes may be omitted.\",\n            fromfile_prefix_chars=\"@\",\n        )\n\n    def convert_arg_line_to_args(self, line : str):\n        return (\"--\" + line.lstrip(\"--\")).split()\n\ndef main():\n    argparser = MISPImportArgumentParser()\n    argparser.add_argument(\"--url\", \"-u\", default=\"https://localhost\", help=\"URL of MISP instance\")\n    argparser.add_argument(\"--key\", \"-k\", required=True, help=\"API key\")\n    argparser.add_argument(\"--insecure\", \"-I\", action=\"store_false\", help=\"Disable TLS certifcate validation.\")\n    argparser.add_argument(\"--event\", \"-e\", type=int, help=\"Add Sigma rule to event with this ID. If not set, create new event.\")\n    argparser.add_argument(\"--same-event\", \"-s\", action=\"store_true\", help=\"Import all Sigma rules to the same event, if no event is set.\")\n    argparser.add_argument(\"--info\", \"-i\", default=\"Sigma import\", help=\"Event Information field for newly created MISP event.\")\n    argparser.add_argument(\"--recursive\", \"-r\", action=\"store_true\", help=\"Recursive traversal of directory\")\n    argparser.add_argument(\"sigma\", nargs=\"+\", help=\"Sigma rule file that should be imported\")\n    args = argparser.parse_args()\n\n    if args.recursive:\n        paths = [ p for pathname in args.sigma for p in pathlib.Path(pathname).glob(\"**/*\") if p.is_file() ]\n    else:\n        paths = [ pathlib.Path(sigma) for sigma in args.sigma ]\n\n    misp = PyMISP(args.url, args.key, args.insecure)\n    if args.event:\n        if hasattr(misp, \"get\"):\n            eventid = misp.get(args.event)[\"Event\"][\"id\"]\n        else:\n            eventid = misp.get_event(args.event)[\"Event\"][\"id\"]\n\n    first = True\n\n    for sigma in paths:\n        if not args.event and (first or not args.same_event):\n            eventid = create_new_event(args, misp)\n        print(\"Importing Sigma rule {} into MISP event {}...\".format(sigma, eventid, end=\"\"))\n        f = sigma.open(\"rt\")\n\n        if hasattr(misp, \"add_named_attribute\"):\n            misp.add_named_attribute(eventid, \"sigma\", f.read())\n        else:\n            event = misp.get_event(eventid, pythonify=True)\n            event.add_attribute(\"sigma\", f.read())\n            misp.update_event(event)\n\n        f.close()\n        first = False\n\nif __name__ == \"__main__\":\n    main()\n", "path": "tools/sigma/sigma2misp.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n# Import given Sigma rules to MISP\n\nimport argparse\nimport pathlib\nimport urllib3\nurllib3.disable_warnings()\nfrom pymisp import PyMISP, MISPEvent\n\ndef create_new_event(args, misp):\n    if hasattr(misp, \"new_event\"):\n        return misp.new_event(info=args.info)[\"Event\"][\"id\"]\n    \n    event = MISPEvent()\n    event.info = args.info\n    return misp.add_event(event)[\"Event\"][\"id\"]\n\n\nclass MISPImportArgumentParser(argparse.ArgumentParser):\n    def __init__(self, *args, **kwargs):\n        super().__init__(\n            description=\"Import Sigma rules into MISP events\",\n            epilog=\"Parameters can be read from a file by a @filename parameter. The file should contain one parameter per line. Dashes may be omitted.\",\n            fromfile_prefix_chars=\"@\",\n        )\n\n    def convert_arg_line_to_args(self, line : str):\n        return (\"--\" + line.lstrip(\"--\")).split()\n\ndef main():\n    argparser = MISPImportArgumentParser()\n    argparser.add_argument(\"--url\", \"-u\", default=\"https://localhost\", help=\"URL of MISP instance\")\n    argparser.add_argument(\"--key\", \"-k\", required=True, help=\"API key\")\n    argparser.add_argument(\"--insecure\", \"-I\", action=\"store_false\", help=\"Disable TLS certifcate validation.\")\n    argparser.add_argument(\"--event\", \"-e\", type=int, help=\"Add Sigma rule to event with this ID. If not set, create new event.\")\n    argparser.add_argument(\"--same-event\", \"-s\", action=\"store_true\", help=\"Import all Sigma rules to the same event, if no event is set.\")\n    argparser.add_argument(\"--info\", \"-i\", default=\"Sigma import\", help=\"Event Information field for newly created MISP event.\")\n    argparser.add_argument(\"--recursive\", \"-r\", action=\"store_true\", help=\"Recursive traversal of directory\")\n    argparser.add_argument(\"sigma\", nargs=\"+\", help=\"Sigma rule file that should be imported\")\n    args = argparser.parse_args()\n\n    if args.recursive:\n        paths = [ p for pathname in args.sigma for p in pathlib.Path(pathname).glob(\"**/*\") if p.is_file() ]\n    else:\n        paths = [ pathlib.Path(sigma) for sigma in args.sigma ]\n\n    misp = PyMISP(args.url, args.key, args.insecure)\n    if args.event:\n        if hasattr(misp, \"get\"):\n            eventid = misp.get(args.event)[\"Event\"][\"id\"]\n        else:\n            eventid = misp.get_event(args.event)[\"Event\"][\"id\"]\n\n    first = True\n\n    for sigma in paths:\n        if not args.event and (first or not args.same_event):\n            eventid = create_new_event(args, misp)\n        print(\"Importing Sigma rule {} into MISP event {}...\".format(sigma, eventid, end=\"\"))\n        f = sigma.open(\"rt\")\n\n        if hasattr(misp, \"add_named_attribute\"):\n            misp.add_named_attribute(eventid, \"sigma\", f.read())\n        else:\n            event = misp.get_event(eventid, pythonify=True)\n            event.add_attribute(\"sigma\", f.read())\n            misp.update_event(event)\n\n        f.close()\n        first = False\n\nif __name__ == \"__main__\":\n    main()\n", "path": "tools/sigma/sigma2misp.py"}]}