From 378e7bbfab31121913944bb4a598a9479f02f97d Mon Sep 17 00:00:00 2001 From: "Allen D. Householder" Date: Fri, 15 Sep 2017 11:30:02 -0400 Subject: [PATCH 1/5] Add "activity-cve-id-added" and "activity-nobody-assigned-to-bug" as valid activities. --- h1/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/h1/models.py b/h1/models.py index 81e43e1..2afb858 100644 --- a/h1/models.py +++ b/h1/models.py @@ -491,6 +491,8 @@ class ActivityComment(ActivityBase): class ActivityCommentsClosed(ActivityBase): TYPE = "activity-comments-closed" +class ActivityCveIdAdded(ActivityBase): + TYPE="activity-cve-id-added" class ActivityExternalUserInvitationCancelled(ActivityBase): TYPE = "activity-external-user-invitation-cancelled" @@ -538,6 +540,8 @@ class ActivityManuallyDisclosed(ActivityBase): class ActivityMediationRequested(ActivityBase): TYPE = "activity-mediation-requested" +class ActivityNobodyAssignedToBug(ActivityBase): + TYPE = "activity-nobody-assigned-to-bug" class ActivityNotEligibleForBounty(ActivityBase): TYPE = "activity-not-eligible-for-bounty" From 15c073b8c853326d4fbec34c959f5b3a86de92d2 Mon Sep 17 00:00:00 2001 From: "Allen D. Householder" Date: Fri, 15 Sep 2017 11:43:51 -0400 Subject: [PATCH 2/5] duplicate_report_id appears to be an optional attribute on ActivityExternalUserJoined now. Fix for: Traceback (most recent call last): File "", line 1, in File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/client.py", line 109, in get_resource return rsrc_type.get(self, obj_id) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 171, in get return requester.request_object(cls.make_url(obj_id)) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/client.py", line 85, in request_object return hydrate_object(data, self) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 47, in hydrate_object return hydrator(requester, obj) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 162, in __init__ super(HackerOneResource, self).__init__(requester, raw_data) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 80, in __init__ self._handle_data() File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 93, in _handle_data self._hydrate() File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 294, in _hydrate self._make_relationship("activities", self._hydrate_list_of_objects, []) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 128, in _make_relationship rel_val = hydrator(rel_val["data"]) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 110, in _hydrate_list_of_objects return [self._hydrate_object(x) for x in val] File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 110, in return [self._hydrate_object(x) for x in val] File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 113, in _hydrate_object return hydrate_object(val, self._requester) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 47, in hydrate_object return hydrator(requester, obj) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 80, in __init__ self._handle_data() File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 93, in _handle_data self._hydrate() File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 411, in _hydrate self._activity_hydrate() File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 513, in _activity_hydrate self._make_attribute("duplicate_report_id", self._hydrate_verbatim) File "/Users/adh/anaconda/envs/py36/lib/python3.6/site-packages/h1/models.py", line 120, in _make_attribute attr_val = attrs[attr_name] KeyError: 'duplicate_report_id' --- h1/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h1/models.py b/h1/models.py index 2afb858..e5cc709 100644 --- a/h1/models.py +++ b/h1/models.py @@ -512,7 +512,7 @@ class ActivityExternalUserJoined(ActivityBase): TYPE = "activity-external-user-joined" def _activity_hydrate(self): - self._make_attribute("duplicate_report_id", self._hydrate_verbatim) + self._make_attribute("duplicate_report_id", self._hydrate_verbatim, optional=True) class ActivityExternalUserRemoved(ActivityBase): From 3c1f19370237b1a59ee1723ffe07a3275a5d0935 Mon Sep 17 00:00:00 2001 From: "Allen D. Householder" Date: Mon, 18 Sep 2017 11:20:15 -0400 Subject: [PATCH 3/5] fix code style warnings $ make lint test flake8 h1 tests h1/models.py:494:1: E302 expected 2 blank lines, found 1 h1/models.py:495:9: E225 missing whitespace around operator h1/models.py:497:1: E302 expected 2 blank lines, found 1 h1/models.py:543:1: E302 expected 2 blank lines, found 1 h1/models.py:546:1: E302 expected 2 blank lines, found 1 make: *** [lint] Error 1 --- h1/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/h1/models.py b/h1/models.py index e5cc709..d17ac4f 100644 --- a/h1/models.py +++ b/h1/models.py @@ -491,8 +491,10 @@ class ActivityComment(ActivityBase): class ActivityCommentsClosed(ActivityBase): TYPE = "activity-comments-closed" + class ActivityCveIdAdded(ActivityBase): - TYPE="activity-cve-id-added" + TYPE = "activity-cve-id-added" + class ActivityExternalUserInvitationCancelled(ActivityBase): TYPE = "activity-external-user-invitation-cancelled" @@ -540,9 +542,11 @@ class ActivityManuallyDisclosed(ActivityBase): class ActivityMediationRequested(ActivityBase): TYPE = "activity-mediation-requested" + class ActivityNobodyAssignedToBug(ActivityBase): TYPE = "activity-nobody-assigned-to-bug" + class ActivityNotEligibleForBounty(ActivityBase): TYPE = "activity-not-eligible-for-bounty" From b2c2dc08221bfb5af9172438ba91d09579595323 Mon Sep 17 00:00:00 2001 From: "Allen D. Householder" Date: Mon, 18 Sep 2017 11:31:34 -0400 Subject: [PATCH 4/5] add test case data --- tests/resources/activity-cve-id-added.json | 30 +++++++++++++++++++ .../activity-nobody-assigned-to-bug.json | 30 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/resources/activity-cve-id-added.json create mode 100644 tests/resources/activity-nobody-assigned-to-bug.json diff --git a/tests/resources/activity-cve-id-added.json b/tests/resources/activity-cve-id-added.json new file mode 100644 index 0000000..dd4adbb --- /dev/null +++ b/tests/resources/activity-cve-id-added.json @@ -0,0 +1,30 @@ +{ + "type": "activity-cve-id-added", + "id": "1337", + "attributes": { + "message": "", + "created_at": "2016-02-02T04:05:06.000Z", + "updated_at": "2016-02-02T04:05:06.000Z", + "internal": false + }, + "relationships": { + "actor": { + "data": { + "type": "user", + "id": "1337", + "attributes": { + "username": "api-example", + "name": "API Example", + "disabled": false, + "created_at": "2016-02-02T04:05:06.000Z", + "profile_picture": { + "62x62": "/assets/avatars/default.png", + "82x82": "/assets/avatars/default.png", + "110x110": "/assets/avatars/default.png", + "260x260": "/assets/avatars/default.png" + } + } + } + } + } +} \ No newline at end of file diff --git a/tests/resources/activity-nobody-assigned-to-bug.json b/tests/resources/activity-nobody-assigned-to-bug.json new file mode 100644 index 0000000..896968a --- /dev/null +++ b/tests/resources/activity-nobody-assigned-to-bug.json @@ -0,0 +1,30 @@ +{ + "type": "aactivity-nobody-assigned-to-bug", + "id": "1337", + "attributes": { + "message": "", + "created_at": "2016-02-02T04:05:06.000Z", + "updated_at": "2016-02-02T04:05:06.000Z", + "internal": false + }, + "relationships": { + "actor": { + "data": { + "type": "user", + "id": "1337", + "attributes": { + "username": "api-example", + "name": "API Example", + "disabled": false, + "created_at": "2016-02-02T04:05:06.000Z", + "profile_picture": { + "62x62": "/assets/avatars/default.png", + "82x82": "/assets/avatars/default.png", + "110x110": "/assets/avatars/default.png", + "260x260": "/assets/avatars/default.png" + } + } + } + } + } +} \ No newline at end of file From 0dc7f14e0131f9a77d4881f1ca1e791e335a5a9f Mon Sep 17 00:00:00 2001 From: "Allen D. Householder" Date: Mon, 18 Sep 2017 11:36:33 -0400 Subject: [PATCH 5/5] typo fix --- tests/resources/activity-nobody-assigned-to-bug.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/resources/activity-nobody-assigned-to-bug.json b/tests/resources/activity-nobody-assigned-to-bug.json index 896968a..640876a 100644 --- a/tests/resources/activity-nobody-assigned-to-bug.json +++ b/tests/resources/activity-nobody-assigned-to-bug.json @@ -1,5 +1,5 @@ { - "type": "aactivity-nobody-assigned-to-bug", + "type": "activity-nobody-assigned-to-bug", "id": "1337", "attributes": { "message": "",