yeti icon indicating copy to clipboard operation
yeti copied to clipboard

Run testrun.py error message

Open capy-pl opened this issue 7 years ago • 3 comments
trafficstars

Description

After I started a local Yeti server on my computer, I tried to run testrun.py file. I got an error message.

Environment

Question Answer
Git commit 705ba1e453cc94cfbe593342fa3c7e2e4c53f62a
OS version macOS 10.13.4
Browser Chrome 56.0.2924.87

Steps to Reproduce

  1. git clone the repo
  2. cd yeti
  3. pip install -r
  4. start my local mongodb
  5. ./yeti.py webserver
  6. python2 testrun.py

Expected behavior

It should successfully run through the file.

Actual behavior

It instead produced the following error message:

Traceback (most recent call last):
  File "testrun.py", line 214, in <module>
    print {"type": type, "link": l.info(), "node": node.info()}
  File "/Users/phil/Desktop/Projects/yeti/yeti/core/entities/malware.py", line 34, in info
    i = Entity.info(self)
  File "/Users/phil/Desktop/Projects/yeti/yeti/core/entities/entity.py", line 88, in info
    i['url'] = url_for("api.Entity:post", id=str(self.id), _external=True)
  File "/Users/phil/homebrew/lib/python2.7/site-packages/flask/helpers.py", line 294, in url_for
    'Attempted to generate a URL without the application context being'
RuntimeError: Attempted to generate a URL without the application context being pushed. This has to be executed when application context is available.

capy-pl avatar Jul 12 '18 02:07 capy-pl

Could indeed be that testrun.py is outdated (unfortunate, I know); I need to check this. Have you had trouble running the app itself?

tomchop avatar Jul 25 '18 15:07 tomchop

I just encountered this myself.

Architectural question?

Is there an architectural question here? Is the proper approach:

  1. To dummy up a Flask app context?
  2. try -block the url_for() calls which rely on it?

Feeds don't operate with Flask context, do they? It doesn't look like this test script is doing anything more than attempting to print out entity info. Specifically, it is calling .info().

m3047 avatar May 14 '19 19:05 m3047

All sourcefiles which define a info() method and also reference url_for():

m3047@sophia:/opt/yeti/yeti> grep -l url_for $(grep -l 'def *info(' `find * -name '*.py'`)
core/entities/entity.py
core/exports/export.py
core/indicators/indicator.py
core/observables/observable.py
core/user.py

m3047 avatar May 14 '19 19:05 m3047