crits / crits_services

CRITs Services Collection
182 stars 130 forks source link

Can't Import STIX package - KeyError: None #340

Open packet-rat opened 6 years ago

packet-rat commented 6 years ago

After initial load of STIX Package, import fails when selecting [Import Selected and keep/delete others]. Failures occur across a full suite of Test STIX Packages that have loaded previously without issue.

FWIW: username is not equal to 'analyst'

self.updates[self.imported[id_][1]].save(username=analyst)
[Fri Mar 30 15:53:42.856387 2018] [wsgi:error] [pid 23154:tid 139743874414336] 1684932 ERROR: None
[Fri Mar 30 15:53:42.857479 2018] [wsgi:error] [pid 23154:tid 139743874414336] Traceback (most recent call last):
[Fri Mar 30 15:53:42.857486 2018] [wsgi:error] [pid 23154:tid 139743874414336]   File "/data/crits_services/taxii_service/handlers.py", line 2158, in import_standards_doc
[Fri Mar 30 15:53:42.857491 2018] [wsgi:error] [pid 23154:tid 139743874414336]     parser.relate_objects()
[Fri Mar 30 15:53:42.857495 2018] [wsgi:error] [pid 23154:tid 139743874414336]   File "/data/crits_services/taxii_service/parsers.py", line 1392, in relate_objects
[Fri Mar 30 15:53:42.857500 2018] [wsgi:error] [pid 23154:tid 139743874414336]     self.updates[self.imported[id_][1]].save(username=analyst)
[Fri Mar 30 15:53:42.857504 2018] [wsgi:error] [pid 23154:tid 139743874414336] KeyError: None
ERROR 2018-03-30 15:53:42,856 crits.taxii_service.handlers None
Traceback (most recent call last):
  File "/data/crits_services/taxii_service/handlers.py", line 2158, in import_standards_doc
    parser.relate_objects()
  File "/data/crits_services/taxii_service/parsers.py", line 1392, in relate_objects
    self.updates[self.imported[id_][1]].save(username=analyst)
KeyError: None
$ git status
HEAD detached at 6f29560
nothing to commit, working directory clean
ubuntu@crits:/data/crits$ cd ../crits_services/
ubuntu@crits:/data/crits_services$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    deleted:    carbonblack_service/DEPENDENCIES
    deleted:    carbonblack_service/README
    deleted:    carbonblack_service/__init__.py
    deleted:    carbonblack_service/bootstrap
    deleted:    carbonblack_service/forms.py
    deleted:    carbonblack_service/requirements.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    joesandbox_crits/

no changes added to commit (use "git add" and/or "git commit -a")
brlogan commented 6 years ago

I have a theory about why you might be seeing this error, but I have not been able to confirm. The error seems to be saying that self.imported[id_][1] evaluates to None, but this should only happen when you're requesting a preview, not actually importing. However, when someone added RBAC support to the TAXII service, they modified the code in such a way that if one doesn't have the necessary access, the code treats that component as a preview, resulting in the None value.

So, first thing to try is ensure your user has full access rights for everything and see if that makes a difference.