flipkart-incubator / Astra

Automated Security Testing For REST API's
Apache License 2.0
2.46k stars 393 forks source link

Recursive import failing: "ImportError: cannot import name main" #93

Open pwna5aurus opened 5 years ago

pwna5aurus commented 5 years ago

The API/api.py is importing * from astra which recursively imports API/api.py, and the logic to skip the import on iterative imports:

if os.getcwd().split('/')[-1] != 'API':
    from API.api import main

isn't working. Here's the trace-back:

Traceback (most recent call last):
  File "astra.py", line 38, in <module>
    from API.api import main
  File "C:\Pentest\Astra\API\api.py", line 38, in <module>
    from astra import *
  File "C:\Pentest\Astra\astra.py", line 38, in <module>
    from API.api import main
ImportError: cannot import name main
sagarpo commented 5 years ago

@pwna5aurus: Will look into this. BDW I have noticed from your comment that you are using windows box to run astra. We have not tested it in windows so we are not sure if that will work. I would recommend to use it linux or mac. Also, ImportError mentioned in your comment is limited to CLI version so you can use web interface of Astra to run the scan.

brianonn commented 5 years ago

Same problem on OS X with python 2.7.15 . I'll try the web interface as well

coffee-cat-007 commented 5 years ago

I have tried with couple of versions 2.7.14 & 2.7.15 on OSX still no luck.

sagarpo commented 5 years ago

@brianonn : Are you able to access through web interface?

sagarpo commented 5 years ago

@coffee-cat-007 : Try through web interface.

CreativeWolf commented 5 years ago

Heya,

OS: Ubuntu 16.04 Python version 2.7

Here's the traceback while trying to run the web interface

Traceback (most recent call last): File "api.py", line 38, in from astra import File "../astra.py", line 14, in from core.zapscan import ImportError: No module named zapscan

While there is zapscan.py inside the directory core, looks like the path is not read

kashaziz commented 4 years ago

Commenting out line 38 in api.py works with web interface. '# from astra import *'

lisa50loves commented 4 years ago

I have to try this

true-hero commented 4 years ago

astra.py has to be launched from directory /app/API, like this: /app/API # python /app/astra.py --help

NelsonGaleano commented 3 years ago

A mi me funciono de la siguiente manera:

cd Astra/API/
python ../astra.py --help

y listo! Gracias @true-hero por la idea!