laramies / theHarvester

E-mails, subdomains and names Harvester - OSINT
http://www.edge-security.com/
11.04k stars 1.98k forks source link

[Other] Problem Installing theHarvester on AWS Cloud9 #1558

Closed sohaibrahman64 closed 9 months ago

sohaibrahman64 commented 11 months ago

I have cloned this repo on AWS Cloud9. Ran docker build -t the-harvester-image . to build the docker and ran the below command. ec2-user:~/environment/theHarvester (master) $ docker run the-harvester-image The result is as below: Traceback (most recent call last): File "/app/restfulHarvest.py", line 37, in <module> uvicorn.run( File "/usr/lib/python3.11/site-packages/uvicorn/main.py", line 587, in run server.run() File "/usr/lib/python3.11/site-packages/uvicorn/server.py", line 61, in run return asyncio.run(self.serve(sockets=sockets)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete File "/usr/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve config.load() File "/usr/lib/python3.11/site-packages/uvicorn/config.py", line 467, in load self.loaded_app = import_from_string(self.app) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string module = importlib.import_module(module_str) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "<frozen importlib._bootstrap>", line 1204, in _gcd_import File "<frozen importlib._bootstrap>", line 1176, in _find_and_load File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/app/theHarvester/lib/api/api.py", line 40, in <module> @app.get("/", response_class=HTMLResponse) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/fastapi/routing.py", line 704, in decorator self.add_api_route( File "/usr/lib/python3.11/site-packages/fastapi/routing.py", line 643, in add_api_route route = route_class( ^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/fastapi/routing.py", line 448, in __init__ self.response_field = create_response_field( ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/fastapi/utils.py", line 101, in create_response_field raise fastapi.exceptions.FastAPIError( fastapi.exceptions.FastAPIError: Invalid args for response field! Hint: check that typing.Union[starlette.responses.RedirectResponse, str] is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/.

Kindly let me know what I am missing? What I am doing wrong?

dbfreem commented 9 months ago

I was looking at this too and it looks like it is because of the RedirectResponse used in the api.py. FastAPI is requiring a valid Pydantic model on the response type and RedirectResponse is not a valid Pydantic model.

I was able to get it working all be it without fully testing it with something like the below. @L1ghtn1ng if you are ok with this I can make a similar change to the other FastAPI endpoints that have this issue.

@app.get("/")
async def root(*, user_agent: str = Header(None)) -> Response:

Here is the FastAPI docs on this

L1ghtn1ng commented 9 months ago

Yeah go for it👍

On 13 Nov 2023, at 01:42, Don Freeman @.***> wrote:



I was looking at this too and it looks like it is because of the RedirectResponse used in the api.pyhttps://github.com/laramies/theHarvester/blob/master/theHarvester/lib/api/api.py#L41. FastAPI is requiring a valid Pydantic model on the response type and RedirectResponse is not a valid Pydantic model.

I was able to get it working all be it without fully testing it with something like the below. @L1ghtn1nghttps://github.com/L1ghtn1ng if you are ok with this I can make a similar change to the other FastAPI endpoints that have this issue.

@app.get("/") async def root(*, user_agent: str = Header(None)) -> Response:

Here is the FastAPI docshttps://fastapi.tiangolo.com/tutorial/response-model/#other-return-type-annotations on this

— Reply to this email directly, view it on GitHubhttps://github.com/laramies/theHarvester/issues/1558#issuecomment-1807352946, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AA3V2QQ5RFVP3S3GCXTOZBTYEF3IBAVCNFSM6AAAAAA5TCGWCCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBXGM2TEOJUGY. You are receiving this because you were mentioned.Message ID: @.***>

dbfreem commented 9 months ago

PR #1586 created