yeti
yeti copied to clipboard
Run testrun.py error message
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
- git clone the repo
- cd yeti
- pip install -r
- start my local mongodb
- ./yeti.py webserver
- 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.
Could indeed be that testrun.py is outdated (unfortunate, I know); I need to check this. Have you had trouble running the app itself?
I just encountered this myself.
Architectural question?
Is there an architectural question here? Is the proper approach:
- To dummy up a Flask app context?
try-block theurl_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().
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