TAXIIProject / django-taxii-services

Installable taxii_services
http://taxiiproject.github.io/
BSD 3-Clause "New" or "Revised" License
20 stars 13 forks source link

TAXII Services should display helpful (for humans) HTTP Responses #41

Open MarkDavidson opened 9 years ago

MarkDavidson commented 9 years ago

Right now, attempts to access TAXII Services result in an HTTP 406 (or similar) error, which isn't entirely useful for a human operator, especially one who is new to TAXII/django-taxii-services.

Perhaps a more useful HTTP response could be displayed - something along the lines of "This is a TAXII Service and it looks like you're attempting to access it with a browser. That's not going to work!" (Would detection based on the user-agent string be useful? I'm not sure - just throwing stuff out there).

-Mark

gtback commented 9 years ago

Can we customize the body of the HTTP response in the case of an HTTP 406? I wouldn't try to mess with user-agent detection.

MarkDavidson commented 9 years ago

Current Behavior

Doing a quick triage of HTTP Status Codes and what django-taxii-services responds with. Note that this describes current behavior, not ideal or target behavior.

More discussion

It looks like django-taxii-services doesn't really do header validation the way the Specifications describe.

For certain types of errors (e.g., an unacceptable X-TAXII-Accept header), the TAXII Specification doesn't prescribe a behavior. I feel this is a gap in the TAXII Specifications, and have added an issue: https://github.com/TAXIIProject/TAXII-Specifications/issues/49. However, that leaves us to decide what to do about the following situations:

[1] https://github.com/TAXIIProject/django-taxii-services/blob/master/taxii_services/middleware.py#L38

gtback commented 9 years ago

I realize that the TAXII specifications state that TAXII errors should in general always be 200 messages, but I still disagree that This means everything "worked" at the HTTP/HTTPS layer is the right interpretation for how to use HTTP response status codes. TAXII error conditions (regardless of whether they are caused by HTTP headers or TAXII payload) should be 4XX errors, or possibly 5XX errors in some cases. In any case, the TAXII status message can be returned in the HTTP response body. </rant>

For now, I would say the best thing to do is return a 400 (Bad Request) for any invalid TAXII headers (the items that still need discussion). After that, we can discuss if more specific 4XX error codes are more appropriate.