Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Handle empty lists in TAXII status responses #81

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions taxii2client/v20/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,19 @@ def _validate_status(self):
msg = "No 'pending_count' in Status for request '{}'"
raise ValidationError(msg.format(self.url))

if len(self.successes) != self.success_count:
if self.successes and len(self.successes) != self.success_count:
msg = "Found successes={}, but success_count={} in status '{}'"
raise ValidationError(msg.format(self.successes,
self.success_count,
self.id))

if len(self.pendings) != self.pending_count:
if self.pendings and len(self.pendings) != self.pending_count:
msg = "Found pendings={}, but pending_count={} in status '{}'"
raise ValidationError(msg.format(self.pendings,
self.pending_count,
self.id))

if len(self.failures) != self.failure_count:
if self.failures and len(self.failures) != self.failure_count:
msg = "Found failures={}, but failure_count={} in status '{}'"
raise ValidationError(msg.format(self.failures,
self.failure_count,
Expand Down
6 changes: 3 additions & 3 deletions taxii2client/v21/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,19 @@ def _validate_status(self):
msg = "No 'pending_count' in Status for request '{}'"
raise ValidationError(msg.format(self.url))

if len(self.successes) != self.success_count:
if self.successes and len(self.successes) != self.success_count:
msg = "Found successes={}, but success_count={} in status '{}'"
raise ValidationError(msg.format(self.successes,
self.success_count,
self.id))

if len(self.pendings) != self.pending_count:
if self.pendings and len(self.pendings) != self.pending_count:
msg = "Found pendings={}, but pending_count={} in status '{}'"
raise ValidationError(msg.format(self.pendings,
self.pending_count,
self.id))

if len(self.failures) != self.failure_count:
if self.failures and len(self.failures) != self.failure_count:
msg = "Found failures={}, but failure_count={} in status '{}'"
raise ValidationError(msg.format(self.failures,
self.failure_count,
Expand Down