{"action":"opened","number":782,"pull_request":{"url":"https://api.github.com/repos/CTFd/CTFd/pulls/782","id":236140768,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM2MTQwNzY4","html_url":"https://github.com/CTFd/CTFd/pull/782","diff_url":"https://github.com/CTFd/CTFd/pull/782.diff","patch_url":"https://github.com/CTFd/CTFd/pull/782.patch","issue_url":"https://api.github.com/repos/CTFd/CTFd/issues/782","number":782,"state":"open","locked":false,"title":"Fix divison-by-zero when adding requirement to dynamic challenge","user":{"login":"ptr0x01","id":5557407,"node_id":"MDQ6VXNlcjU1NTc0MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5557407?v=4","gravatar_id":"","url":"https://api.github.com/users/ptr0x01","html_url":"https://github.com/ptr0x01","followers_url":"https://api.github.com/users/ptr0x01/followers","following_url":"https://api.github.com/users/ptr0x01/following{/other_user}","gists_url":"https://api.github.com/users/ptr0x01/gists{/gist_id}","starred_url":"https://api.github.com/users/ptr0x01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptr0x01/subscriptions","organizations_url":"https://api.github.com/users/ptr0x01/orgs","repos_url":"https://api.github.com/users/ptr0x01/repos","events_url":"https://api.github.com/users/ptr0x01/events{/privacy}","received_events_url":"https://api.github.com/users/ptr0x01/received_events","type":"User","site_admin":false},"body":"I noticed that when I wanted to add a pre-requisite challenge to a dynamic challenge, I received a divison-by-zero error.\r\n\r\nDuring a requirement addition, only the new required challenge id is sent. Because the initial, minimum and decay values are not set, the update path in the __init.py set them to a default 0. \r\nLater on, when a calculation takes place with these values, a divison-by-zero happens before anything gets committed to the database.\r\n\r\nI've added a simple check before other calculations to check if data received from client includes a requirements (is not None). If there is data there, it means the request is a requirement addition so we can just commit those changes and return. At the same time, updating values and other data will not include a requirement field so everything else will work as it does currently.","created_at":"2018-12-05T11:33:50Z","updated_at":"2018-12-05T11:33:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/CTFd/CTFd/pulls/782/commits","review_comments_url":"https://api.github.com/repos/CTFd/CTFd/pulls/782/comments","review_comment_url":"https://api.github.com/repos/CTFd/CTFd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CTFd/CTFd/issues/782/comments","statuses_url":"https://api.github.com/repos/CTFd/CTFd/statuses/1ef30ab8b61c1a7337a8d613f9b6c3facc75ba75","head":{"label":"ptr0x01:master","ref":"master","sha":"1ef30ab8b61c1a7337a8d613f9b6c3facc75ba75","user":{"login":"ptr0x01","id":5557407,"node_id":"MDQ6VXNlcjU1NTc0MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5557407?v=4","gravatar_id":"","url":"https://api.github.com/users/ptr0x01","html_url":"https://github.com/ptr0x01","followers_url":"https://api.github.com/users/ptr0x01/followers","following_url":"https://api.github.com/users/ptr0x01/following{/other_user}","gists_url":"https://api.github.com/users/ptr0x01/gists{/gist_id}","starred_url":"https://api.github.com/users/ptr0x01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptr0x01/subscriptions","organizations_url":"https://api.github.com/users/ptr0x01/orgs","repos_url":"https://api.github.com/users/ptr0x01/repos","events_url":"https://api.github.com/users/ptr0x01/events{/privacy}","received_events_url":"https://api.github.com/users/ptr0x01/received_events","type":"User","site_admin":false},"repo":{"id":160506316,"node_id":"MDEwOlJlcG9zaXRvcnkxNjA1MDYzMTY=","name":"CTFd","full_name":"ptr0x01/CTFd","private":false,"owner":{"login":"ptr0x01","id":5557407,"node_id":"MDQ6VXNlcjU1NTc0MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5557407?v=4","gravatar_id":"","url":"https://api.github.com/users/ptr0x01","html_url":"https://github.com/ptr0x01","followers_url":"https://api.github.com/users/ptr0x01/followers","following_url":"https://api.github.com/users/ptr0x01/following{/other_user}","gists_url":"https://api.github.com/users/ptr0x01/gists{/gist_id}","starred_url":"https://api.github.com/users/ptr0x01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ptr0x01/subscriptions","organizations_url":"https://api.github.com/users/ptr0x01/orgs","repos_url":"https://api.github.com/users/ptr0x01/repos","events_url":"https://api.github.com/users/ptr0x01/events{/privacy}","received_events_url":"https://api.github.com/users/ptr0x01/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ptr0x01/CTFd","description":"CTFs as you need them","fork":true,"url":"https://api.github.com/repos/ptr0x01/CTFd","forks_url":"https://api.github.com/repos/ptr0x01/CTFd/forks","keys_url":"https://api.github.com/repos/ptr0x01/CTFd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ptr0x01/CTFd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ptr0x01/CTFd/teams","hooks_url":"https://api.github.com/repos/ptr0x01/CTFd/hooks","issue_events_url":"https://api.github.com/repos/ptr0x01/CTFd/issues/events{/number}","events_url":"https://api.github.com/repos/ptr0x01/CTFd/events","assignees_url":"https://api.github.com/repos/ptr0x01/CTFd/assignees{/user}","branches_url":"https://api.github.com/repos/ptr0x01/CTFd/branches{/branch}","tags_url":"https://api.github.com/repos/ptr0x01/CTFd/tags","blobs_url":"https://api.github.com/repos/ptr0x01/CTFd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ptr0x01/CTFd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ptr0x01/CTFd/git/refs{/sha}","trees_url":"https://api.github.com/repos/ptr0x01/CTFd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ptr0x01/CTFd/statuses/{sha}","languages_url":"https://api.github.com/repos/ptr0x01/CTFd/languages","stargazers_url":"https://api.github.com/repos/ptr0x01/CTFd/stargazers","contributors_url":"https://api.github.com/repos/ptr0x01/CTFd/contributors","subscribers_url":"https://api.github.com/repos/ptr0x01/CTFd/subscribers","subscription_url":"https://api.github.com/repos/ptr0x01/CTFd/subscription","commits_url":"https://api.github.com/repos/ptr0x01/CTFd/commits{/sha}","git_commits_url":"https://api.github.com/repos/ptr0x01/CTFd/git/commits{/sha}","comments_url":"https://api.github.com/repos/ptr0x01/CTFd/comments{/number}","issue_comment_url":"https://api.github.com/repos/ptr0x01/CTFd/issues/comments{/number}","contents_url":"https://api.github.com/repos/ptr0x01/CTFd/contents/{+path}","compare_url":"https://api.github.com/repos/ptr0x01/CTFd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ptr0x01/CTFd/merges","archive_url":"https://api.github.com/repos/ptr0x01/CTFd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ptr0x01/CTFd/downloads","issues_url":"https://api.github.com/repos/ptr0x01/CTFd/issues{/number}","pulls_url":"https://api.github.com/repos/ptr0x01/CTFd/pulls{/number}","milestones_url":"https://api.github.com/repos/ptr0x01/CTFd/milestones{/number}","notifications_url":"https://api.github.com/repos/ptr0x01/CTFd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ptr0x01/CTFd/labels{/name}","releases_url":"https://api.github.com/repos/ptr0x01/CTFd/releases{/id}","deployments_url":"https://api.github.com/repos/ptr0x01/CTFd/deployments","created_at":"2018-12-05T11:11:42Z","updated_at":"2018-12-05T11:29:10Z","pushed_at":"2018-12-05T11:29:08Z","git_url":"git://github.com/ptr0x01/CTFd.git","ssh_url":"git@github.com:ptr0x01/CTFd.git","clone_url":"https://github.com/ptr0x01/CTFd.git","svn_url":"https://github.com/ptr0x01/CTFd","homepage":"https://ctfd.io","size":10458,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CTFd:master","ref":"master","sha":"473acdbdc3457f4fd778fbd692ae353c531804ba","user":{"login":"CTFd","id":18561578,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTYxNTc4","avatar_url":"https://avatars0.githubusercontent.com/u/18561578?v=4","gravatar_id":"","url":"https://api.github.com/users/CTFd","html_url":"https://github.com/CTFd","followers_url":"https://api.github.com/users/CTFd/followers","following_url":"https://api.github.com/users/CTFd/following{/other_user}","gists_url":"https://api.github.com/users/CTFd/gists{/gist_id}","starred_url":"https://api.github.com/users/CTFd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CTFd/subscriptions","organizations_url":"https://api.github.com/users/CTFd/orgs","repos_url":"https://api.github.com/users/CTFd/repos","events_url":"https://api.github.com/users/CTFd/events{/privacy}","received_events_url":"https://api.github.com/users/CTFd/received_events","type":"Organization","site_admin":false},"repo":{"id":28681142,"node_id":"MDEwOlJlcG9zaXRvcnkyODY4MTE0Mg==","name":"CTFd","full_name":"CTFd/CTFd","private":false,"owner":{"login":"CTFd","id":18561578,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NTYxNTc4","avatar_url":"https://avatars0.githubusercontent.com/u/18561578?v=4","gravatar_id":"","url":"https://api.github.com/users/CTFd","html_url":"https://github.com/CTFd","followers_url":"https://api.github.com/users/CTFd/followers","following_url":"https://api.github.com/users/CTFd/following{/other_user}","gists_url":"https://api.github.com/users/CTFd/gists{/gist_id}","starred_url":"https://api.github.com/users/CTFd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CTFd/subscriptions","organizations_url":"https://api.github.com/users/CTFd/orgs","repos_url":"https://api.github.com/users/CTFd/repos","events_url":"https://api.github.com/users/CTFd/events{/privacy}","received_events_url":"https://api.github.com/users/CTFd/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/CTFd/CTFd","description":"CTFs as you need them","fork":false,"url":"https://api.github.com/repos/CTFd/CTFd","forks_url":"https://api.github.com/repos/CTFd/CTFd/forks","keys_url":"https://api.github.com/repos/CTFd/CTFd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CTFd/CTFd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CTFd/CTFd/teams","hooks_url":"https://api.github.com/repos/CTFd/CTFd/hooks","issue_events_url":"https://api.github.com/repos/CTFd/CTFd/issues/events{/number}","events_url":"https://api.github.com/repos/CTFd/CTFd/events","assignees_url":"https://api.github.com/repos/CTFd/CTFd/assignees{/user}","branches_url":"https://api.github.com/repos/CTFd/CTFd/branches{/branch}","tags_url":"https://api.github.com/repos/CTFd/CTFd/tags","blobs_url":"https://api.github.com/repos/CTFd/CTFd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CTFd/CTFd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CTFd/CTFd/git/refs{/sha}","trees_url":"https://api.github.com/repos/CTFd/CTFd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CTFd/CTFd/statuses/{sha}","languages_url":"https://api.github.com/repos/CTFd/CTFd/languages","stargazers_url":"https://api.github.com/repos/CTFd/CTFd/stargazers","contributors_url":"https://api.github.com/repos/CTFd/CTFd/contributors","subscribers_url":"https://api.github.com/repos/CTFd/CTFd/subscribers","subscription_url":"https://api.github.com/repos/CTFd/CTFd/subscription","commits_url":"https://api.github.com/repos/CTFd/CTFd/commits{/sha}","git_commits_url":"https://api.github.com/repos/CTFd/CTFd/git/commits{/sha}","comments_url":"https://api.github.com/repos/CTFd/CTFd/comments{/number}","issue_comment_url":"https://api.github.com/repos/CTFd/CTFd/issues/comments{/number}","contents_url":"https://api.github.com/repos/CTFd/CTFd/contents/{+path}","compare_url":"https://api.github.com/repos/CTFd/CTFd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CTFd/CTFd/merges","archive_url":"https://api.github.com/repos/CTFd/CTFd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CTFd/CTFd/downloads","issues_url":"https://api.github.com/repos/CTFd/CTFd/issues{/number}","pulls_url":"https://api.github.com/repos/CTFd/CTFd/pulls{/number}","milestones_url":"https://api.github.com/repos/CTFd/CTFd/milestones{/number}","notifications_url":"https://api.github.com/repos/CTFd/CTFd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CTFd/CTFd/labels{/name}","releases_url":"https://api.github.com/repos/CTFd/CTFd/releases{/id}","deployments_url":"https://api.github.com/repos/CTFd/CTFd/deployments","created_at":"2015-01-01T05:36:55Z","updated_at":"2018-12-05T08:53:47Z","pushed_at":"2018-12-05T05:18:16Z","git_url":"git://github.com/CTFd/CTFd.git","ssh_url":"git@github.com:CTFd/CTFd.git","clone_url":"https://github.com/CTFd/CTFd.git","svn_url":"https://github.com/CTFd/CTFd","homepage":"https://ctfd.io","size":10458,"stargazers_count":1552,"watchers_count":1552,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":594,"mirror_url":null,"archived":false,"open_issues_count":85,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":594,"open_issues":85,"watchers":1552,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CTFd/CTFd/pulls/782"},"html":{"href":"https://github.com/CTFd/CTFd/pull/782"},"issue":{"href":"https://api.github.com/repos/CTFd/CTFd/issues/782"},"comments":{"href":"https://api.github.com/repos/CTFd/CTFd/issues/782/comments"},"review_comments":{"href":"https://api.github.com/repos/CTFd/CTFd/pulls/782/comments"},"review_comment":{"href":"https://api.github.com/repos/CTFd/CTFd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CTFd/CTFd/pulls/782/commits"},"statuses":{"href":"https://api.github.com/repos/CTFd/CTFd/statuses/1ef30ab8b61c1a7337a8d613f9b6c3facc75ba75"}},"author_association":"NONE","merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":2,"additions":6,"deletions":3,"changed_files":1}}
{"actor":{"display_login":"ptr0x01"}}