Inappropriate ioctl for device

I am trying to run Qark Security Scan on my apk using the Script Step. In the bash script I run a python command:

python ${source_dir}/build/qark/qark/qarkMain.py -s 1 -p ${path_to_apk}/${FILE_NAME} -e 1 -d 10 -b ${ANDROID_HOME}

I get this error:

Traceback (most recent call last):
  File "/bitrise/src/build/qark/qark/qarkMain.py", line 1281, in <module>
    nonAutomatedParseArgs()
  File "/bitrise/src/build/qark/qark/qarkMain.py", line 462, in nonAutomatedParseArgs
    main()
  File "/bitrise/src/build/qark/qark/qarkMain.py", line 790, in main
    unpackAPK.decompile(common.pathToDEX)
  File "/bitrise/src/build/qark/qark/modules/unpackAPK.py", line 162, in decompile
    with common.term.cbreak():
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
    return self.gen.next()
  File "/bitrise/src/build/qark/qark/lib/blessed/terminal.py", line 572, in cbreak
    save_mode = termios.tcgetattr(self.keyboard_fd)
termios.error: (25, 'Inappropriate ioctl for device')

I think the hint is in line Inappropriate ioctl for device. When I do set | grep TERM, I get dumb and I think that means the Terminal running the script is very limited. How do I get over this issue?

Edit 1:
I found that the script is waiting for button to be pressed if user wants to cancel.

Decompilation may hang/take too long (usually happens when the source is obfuscated).
At any time,Press C to continue and QARK will attempt to run SCA on whatever was decompiled.

This is why it’s failing. Can it be resolved from bitrise end?

Hi @accolademobile,

The terminal is indeed very limited, so much so that you don’t have interactive input at all :wink: It’s running in non-interactive mode, because during a build you can’t just stop and wait for a user input, that would defeat the purpose of the automation.

From the logs it seems that might cause your issue, that your script might expect interactive input from a user - can that be?

Yes I found the cause. I really don’t want to fork the Qark library. Is there a way to a way around this?

You should ask that from Qark, it depends on the tool. From our side, as this is a non-interactive environment, there’s no way to make it to be one, as there’s no user interaction is possible during the build.

I forked the library and disabled the code that was causing issue. Now I am hit with new issue explained here Python issue: Couldn't find a tree builder with the features you requested

1 Like