nodejsscan icon indicating copy to clipboard operation
nodejsscan copied to clipboard

RuntimeError: Cannot add child handler, the child watcher does not have a loop attached

Open toastyghost opened this issue 3 years ago • 4 comments

I'm using the official image off of DockerHub, running the pull and run commands exactly as they appear in the readme. This has been working for a long time, suddenly it doesn't. Full error output is below. Please advise.

Exception on /upload/ [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1517, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1503, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/src/nodejsscan/nodejsscan/app.py", line 89, in upload
    return handle_upload(app, request)
  File "/usr/src/nodejsscan/web/upload.py", line 85, in handle_upload
    results = nodejsscan.scan(app_dir)
  File "/usr/src/nodejsscan/nodejsscan/nodejsscan.py", line 71, in scan
    result = call_njsscan(node_source)
  File "/usr/src/nodejsscan/nodejsscan/nodejsscan.py", line 50, in call_njsscan
    return scanner.scan()
  File "/usr/local/lib/python3.7/dist-packages/njsscan/njsscan.py", line 44, in scan
    result = scanner.scan()
  File "/usr/local/lib/python3.7/dist-packages/libsast/scanner.py", line 65, in scan
    self.options).scan(valid_paths)
  File "/usr/local/lib/python3.7/dist-packages/libsast/core_sgrep/semantic_sgrep.py", line 40, in scan
    sgrep_out = invoke_semgrep(paths, self.scan_rules)
  File "/usr/local/lib/python3.7/dist-packages/libsast/core_sgrep/helpers.py", line 59, in invoke_semgrep
    **kwargs,
  File "/usr/local/lib/python3.7/dist-packages/semgrep/semgrep_main.py", line 369, in main
    deep,
  File "/usr/local/lib/python3.7/dist-packages/semgrep/semgrep_main.py", line 155, in run_rules
    target_manager, filtered_rules, dump_command_for_core, deep
  File "/usr/local/lib/python3.7/dist-packages/semgrep/core_runner.py", line 759, in invoke_semgrep
    rules, target_manager, dump_command_for_core, deep
  File "/usr/local/lib/python3.7/dist-packages/semgrep/core_runner.py", line 703, in _run_rules_direct_to_semgrep_core
    returncode = runner.execute()
  File "/usr/local/lib/python3.7/dist-packages/semgrep/core_runner.py", line 283, in execute
    rc = asyncio.run(self._stream_subprocess())
  File "/usr/lib/python3.7/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.7/dist-packages/semgrep/core_runner.py", line 246, in _stream_subprocess
    preexec_fn=setrlimits_preexec_fn,
  File "/usr/lib/python3.7/asyncio/subprocess.py", line 217, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/usr/lib/python3.7/asyncio/base_events.py", line 1533, in subprocess_exec
    bufsize, **kwargs)
  File "/usr/lib/python3.7/asyncio/unix_events.py", line 193, in _make_subprocess_transport
    self._child_watcher_callback, transp)
  File "/usr/lib/python3.7/asyncio/unix_events.py", line 924, in add_child_handler
    "Cannot add child handler, "
RuntimeError: Cannot add child handler, the child watcher does not have a loop attached

toastyghost avatar Jul 28 '22 00:07 toastyghost

Seems related https://github.com/ajinabraham/njsscan/issues/95

The issue comes from semgrep. You might want to bump on the upstream issue.

ajinabraham avatar Jul 28 '22 00:07 ajinabraham

Seeing this also. Workaround is to run the older docker image: docker run -it -p 9090:9090 opensecurity/nodejsscan:v4.6

wmhartl avatar Aug 01 '22 13:08 wmhartl

It looks like the Flask update might have been what caused it? Possible to just revert Flask (or bisect and get the latest version that works since it was I think a multiple-version bump?)

toastyghost avatar Aug 01 '22 13:08 toastyghost

I don't think it's related to Flask, we also see this exception from njsscan which does not use Flask.

ajinabraham avatar Aug 01 '22 19:08 ajinabraham

I got the same issue with :latest tag .

Ko-kn3t avatar Dec 09 '22 08:12 Ko-kn3t

Should be addressed in semgrep. Closing this.

ajinabraham avatar Sep 02 '23 04:09 ajinabraham