oasis-open / cti-python-stix2

OASIS TC Open Repository: Python APIs for STIX 2
https://stix2.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
364 stars 119 forks source link

Add MemoryStore.load_from_url() #552

Open jondricek opened 2 years ago

jondricek commented 2 years ago

tl;dr

The MemoryStore object currently allows you to load_from_file() from JSON files - which is great. What would be even better would be to add an option for load_from_url()!

Use Case

Sometimes you just really want to load some STIX content into memory, and find the perfect dataset is available online. Sure, you could download it and load_from_file(), but what if you just don't have time for that? What if you really, really just want it now? Enter load_from_url(), the perfect solution to this problem! I don't know how exactly it would work or be implemented, but it sure beats my attempt at adding requests.get(url) myself, then deciding whether or not to save it to a file and use it as FileSystemStore or just use it in memory. I'd much rather have the stix library handle that for me! Win, win (somehow)!

You might ask, "well what about TAXII? that was designed to transport STIX over the network, not STIX itself. you shouldn't do that."

Great question! I'll counter that with, "turns out that not every STIX dataset is hosted on a TAXII server, but sometimes fully available on, e.g. GitHub. or in the case of some TAXII servers (like the one I help manage) it goes down often and I still want to access the raw STIX since that's always around"

Anyway, hopefully this helps paint a picture of why I believe that load_from_url() makes sense as an addition to MemoryStore objects. Please, by all means let me know if you have other plans in mind. Thank you!