Closed c-x closed 10 years ago
@c-x ,
Thank you for the report. I am able to duplicate what you're seeing (aka I think I know what TAXII Server you are using).
In terms of TAXII, this response is technically correct (e.g., the Content Binding ID matches the Content's format), but a "more correct" response might be to not have any Content Blocks in the response since there isn't any information to return.
I'll reach out to the owners of the server and see if it's actually their server and what (if any) comment they might have on this.
In the meantime, can you expand on what you mean by "identify" the behavior? I'm not sure I understand what you mean.
Thank you. -Mark
fixed. ^_^ (no, it was not a libtaxii bug)
Maybe we can have a flag like content_block.only_headers=True
or content_block.has_data=True
? I've no solution to provide you, it's more a feature request :-)
In my code I simply used the following function:
def taxii_message_is_empty(self, content):
if re.search("^<stix:STIX_Package\s+[^>]+>$", content) :
return True
return False
no, it should not have a content block in this case. the self-terminating stix_package is a side effect that I need to clear up.
@benjamin9999, thanks for the update!
@c-x, I'd like to explore what you're asking for a little more to determine if it's something we should add to libtaxii. Regarding the function you mention (content_block.only_headers / content_block.has_data
), I have a couple thoughts:
content_block.has_data
property should always be True
, since ContentBlocks contain data. The content
field within ContentBlock
is required for this reason.What do you think? Would that function only apply to the one (now addressed) case you ran into, or would it have broader utility?
Thank you. -Mark
@MarkDavidson:
I understood that content_block
are data
. To me, data is something which is either empty or either something containing a header and a real content. In other words, I should have the ability, if the content only contains the headers, to know that my real data is actually None (because I just have the headers). Today I can't know that directly (I had to use the regex I showed you).
Presently, libtaxii has stayed away from "knowing" anything about the data that is contained in a ContentBlock other than how to serialize/deserialize it.
Yes, but people writing application using libtaxii need to know, one way or the other, that the message they receive is only composed of headers without any real data.
I agree with you regarding the fact that libtaxii should stick to the protocol definition, but maybe the protocol should evolve to handle that particular case ?
@c-x,
Some thoughts so far (no real conclusions):
My biggest concern with this kind of functionality is that it would only work for Content Bindings that libtaxii "knows" about, and the application that calls libtaxii would have to be prepared for cases where libtaxii doesn't "know" about the Content Binding. e.g.,:
content_block = get_content_block_from_somwhere()
if libtaxii.can_check_content_binding(content_block.content_binding): #Test to see if libtaxii "knows" about the Content Binding
if content_block.is_content_empty:
pass # Nothing to do here
else:
process(content_block)
else:
process(content_block) # ... maybe?
This could be partially mitigated by allowing libtaxii users to register their own is_content_empty
checks for certain Content Bindings.
Out of curiosity, how do you parse your STIX documents? Maybe this is a feature that the python-stix library could implement?
-Mark
As we agreed in an offline conversation, this issue is actually a TAXII Provider issue. This issue can be closed.
I wrote a simple test_client just like the example you provide in the script directory using libtaxii11.
When I run this client without time filters, I can see events returned and that's great. However, when I filter to have no events returned, I still have a PollResponse Message with no events in it but having the stix headers.
How can I identify this behavior (a response only containing headers) ?