-
Notifications
You must be signed in to change notification settings - Fork 65
Issue with running tram.py #60
Comments
This at face value appears to be the same issue as Issue 59 |
I am also having the same issue: CRITICAL:root:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! During handling of the above exception, another exception occurred: Traceback (most recent call last): How to fix it?? Please help. |
I found the solutions here. It needs to change the code in /service/data_svc.py file as given in the below link: https://github.com/jecarr/tram/commit/060b4f2152cf7692aa5c76851a86b441247e4645 |
that workes for me aswell, but now the analyze content doesn't render iike in this post https://github.com/mitre-attack/tram/issues/67 and loading just one file of my queue takes up to 20 minutes |
I found that error as below, but I changed my data_svc.py as that link INFO:root:Welcome to TRAM |
Hi @jecarr, with the latest commit 5321499 I still have the same issue as mentioned above #60 (comment). Many thanks in advance! |
Hey @buyushan - thanks for the feedback. It looks like my fix didn't work for you because you've specified the config to build the database locally (and not online). So my forked repo and commit doesn't hit
(to quote from your stack trace). Without any fixes applied, KeyErrors therefore will occur:
@buyushan, given this you should now notice a slight difference between your error stack trace and those that have been pasted earlier in this issue by others (i.e. different culprit 'insert_' methods) I realise @GoldBigDragon came across the same scenario as you and created #79. You should be able to take their branch as is or apply solely GoldBigDragon/tram@321e156 to fix your issue. For completeness of my branch, I've also updated my PR to include this fix (jecarr/tram@7d357fd). I would be keen to know the local json file you specified in the config because the config currently points to an It would be good to know how you triggered the error so we can make insert_attack_json_data() more resilient in the future. |
Hi @MarleenSteinhoff - apologies if this doesn't answer your question and/or I'm stating things you already know. Feel free to let me know if so: Is this still a valid solution? For the given error you are facing (KeyError), this is a valid solution. This is because the code is at a point where it is trying to go through attack data. For a single attack entry in this attack data, it attempts to read the description of that attack. Let's take a look at the error stack trace from the beginning of this issue:
You mentioned you applied the code and tram was able to run. Let's see what is actually applied there; to quote from that commit, it is this:
In Python, this is a ternary operator assignment. It's a shorthand for assigning a variable based on a condition. For example, I could have Back to the line: As for the fix: this if statement is checking if the attack ( Because this is a KeyError, there are different approaches to this fix so someone might check 'description' in object Do I break something with this code change? No, this enables tram to finish loading the attack data so will not break anything. You may come across errors whilst using tram - refer to other existing issues here - but (unless they involve the description in some way) it will not be the fault of this fix. Definitions of a 'breaking change' may change from person to person. For this repo, it could be a fix that raises a new error is a breaking change. Other repos may have tests for you to run to check your code is fine (and doesn't break other parts). You can see an example in a different repo here codelucas/newspaper#885 where there are green ticks and red crosses next to commits which informs me of breaking something. Back to tram, there are no tests (at time of writing) to tell me if something breaks therefore I trust in having tram loaded to tell me it's not breaking anything. However, this code change is not included in the latest commit... Short answer: It's not included because these are changes applied after that commit. You can see the timestamp for 5321499 is earlier than the timestamp for jecarr/tram@060b4f2. Longer answer: This is to do with the use of a different branch. What are branches? These are different versions of the code you may have for a repo. You usually have branches when you want to make code changes without affecting a default or different version of the repo. You can see the tram repo's branches here: All repositories have a default branch, tram's repo has a default branch of To go beyond branches, I'll briefly mention forked repositories. This is where there is an original repository but a user wants to own a copy. For example, if you go here, in the top left below the repo name, it is stated my jecarr/tram repo is When I use my default branch of jecarr/tram, I face the KeyError you faced. I want to apply my fix. So I created an Where it says With this separate branch Now that I have a separate branch, it is down to me to maintain it. Future commits may occur in mitre-attack/tram:master. I'll then need to ensure my forked repo and its attack-keyerror branch includes such commits. As someone who wants to verify this, you could check the latest commit in the default branch of mitre-attack/tram (as you have done, it being 5321499 at time of writing). You can then view my attack-keyerror branch and see if it is behind master (missing commits) or is even with it (as we saw earlier). Whilst viewing the attack-keyerror branch (left), you are told it is ahead of mitre-attack/tram:master by 7 commits. That means in addition to being even with the master branch, there have been more commits. If you click the '102 commits' hyperlink, you can see the timeline of commits and can see the 5321499 is present. Therefore my fix is not included in the latest commit because it is from a forked repo. It is also committed later than the latest commit for the mitre-attack/tram master branch and is pending a merge via the linked pull request. Hope that helps! |
Hello @kyozen and thank you for the bug report. TRAM has moved to https://github.com/center-for-threat-informed-defense/tram and the bug has been fixed in that repository so I am closing this issue. Thank you! |
COULD NOT CONNECT TO TAXII SERVERS: 'description'
PLEASE UTILIZE THE OFFLINE CAPABILITY FLAG "-FF" FOR OFFLINE DATABASE BUILDING
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<background_tasks() done, defined at tram.py:21> exception=SystemExit()>
Traceback (most recent call last):
File "tram.py", line 34, in background_tasks
await data_svc.insert_attack_stix_data()
data_svc.py", line 54, in insert_attack_stix_data
"description": i['description'].replace('
', '').replace('
', '').replace(python3.7/site-packages/stix2/base.py", line 195, in getitem
return self._inner[key]
KeyError: 'description'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 571, in run_until_complete
self.run_forever()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
self._run_once()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
handle._run()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "tram.py", line 40, in background_tasks
sys.exit()
SystemExit
Please help, having issues solving this...
The text was updated successfully, but these errors were encountered: