{"action":"created","comment":{"url":"https://api.github.com/repos/securestate/king-phisher/pulls/comments/102038775","pull_request_review_id":22776794,"id":102038775,"diff_hunk":"@@ -493,6 +494,63 @@ def rpc_database_insert_row(handler, session, table_name, keys, values):\n \tsession.commit()\n \treturn row.id\n \n+@register_rpc('/db/table/insert/multi', database_access=True)\n+def rpc_database_insert_row_multi(handler, session, table_name, keys, rows, deconflict_ids=False):\n+\t\"\"\"\n+\tInsert multiple new rows into the specified table. If deconflict_ids is true, new id values will be assigned\n+\tto merge the data into the database. This function will fail if contrasts for the table are not meet.\n+\n+\t:param str table_name: The name of the database table to insert data into.\n+\t:param list keys: A list of keys of the column names in order of values to be inserted *values*\n+\t:param list(tuples) rows: A list of tuples, the tuple is the values to be inserted into the row.\n+\t:return: List of ids of the new rows inserted\n+\t:rtype: list\n+\t\"\"\"\n+\tinserted_ids = []\n+\tif not isinstance(keys, list):\n+\t\tkeys = list(keys)\n+\tif not isinstance(rows, list):\n+\t\trows = list(rows)\n+\n+\ttable = database_table_objects.get(table_name)\n+\tif not table:\n+\t\traise errors.KingPhisherAPIError('failed to get table object for: {0}'.format(table_name))\n+\tfor key in keys:\n+\t\tif key not in database_tables[table_name]:\n+\t\t\traise errors.KingPhisherAPIError('column {0} is invalid for table {1}'.format(keys, table_name))\n+\n+\tfor row in rows:\n+\t\tif len(row) != len(keys):\n+\t\t\terrors.KingPhisherAPIError('row is not the same as number of values defined')\n+\t\tif deconflict_ids and 'id' in keys:\n+\t\t\trow_id = row[keys.index('id')]\n+\t\t\tcheck_id = db_manager.get_row_by_id(session, database_table_objects[table_name], row_id)\n+\t\t\twhile check_id is not None:\n+\t\t\t\trow = list(row)\n+\t\t\t\trow_id = row[keys.index('id')]\n+\t\t\t\tif table_name == 'visits':\n+\t\t\t\t\trow_id = utilities.make_visit_uid()\n+\t\t\t\telif table_name == 'messages':\n+\t\t\t\t\trow_id = utilities.make_message_uid()\n+\t\t\t\telif table_name in ('landing_pages', 'credentials'):","path":"king_phisher/server/server_rpc.py","position":50,"original_position":50,"commit_id":"b5b1ffcf4389add2a62a4304463453f4abb3b8c7","original_commit_id":"b5b1ffcf4389add2a62a4304463453f4abb3b8c7","user":{"login":"zeroSteiner","id":2058303,"avatar_url":"https://avatars.githubusercontent.com/u/2058303?v=3","gravatar_id":"","url":"https://api.github.com/users/zeroSteiner","html_url":"https://github.com/zeroSteiner","followers_url":"https://api.github.com/users/zeroSteiner/followers","following_url":"https://api.github.com/users/zeroSteiner/following{/other_user}","gists_url":"https://api.github.com/users/zeroSteiner/gists{/gist_id}","starred_url":"https://api.github.com/users/zeroSteiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeroSteiner/subscriptions","organizations_url":"https://api.github.com/users/zeroSteiner/orgs","repos_url":"https://api.github.com/users/zeroSteiner/repos","events_url":"https://api.github.com/users/zeroSteiner/events{/privacy}","received_events_url":"https://api.github.com/users/zeroSteiner/received_events","type":"User","site_admin":false},"body":"Tables that have their primary key as an integer should have their new row ID set to `None`, the database will automatically assign the next available value. Only primary keys that are strings need to be set manually, like you are already doing for `visits` and `messages`.","created_at":"2017-02-20T15:15:50Z","updated_at":"2017-02-20T15:36:41Z","html_url":"https://github.com/securestate/king-phisher/pull/192#discussion_r102038775","pull_request_url":"https://api.github.com/repos/securestate/king-phisher/pulls/192","_links":{"self":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/comments/102038775"},"html":{"href":"https://github.com/securestate/king-phisher/pull/192#discussion_r102038775"},"pull_request":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/192"}}},"pull_request":{"url":"https://api.github.com/repos/securestate/king-phisher/pulls/192","id":107020134,"html_url":"https://github.com/securestate/king-phisher/pull/192","diff_url":"https://github.com/securestate/king-phisher/pull/192.diff","patch_url":"https://github.com/securestate/king-phisher/pull/192.patch","issue_url":"https://api.github.com/repos/securestate/king-phisher/issues/192","number":192,"state":"open","locked":false,"title":"RPC insert multi","user":{"login":"wolfthefallen","id":9035933,"avatar_url":"https://avatars.githubusercontent.com/u/9035933?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfthefallen","html_url":"https://github.com/wolfthefallen","followers_url":"https://api.github.com/users/wolfthefallen/followers","following_url":"https://api.github.com/users/wolfthefallen/following{/other_user}","gists_url":"https://api.github.com/users/wolfthefallen/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfthefallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfthefallen/subscriptions","organizations_url":"https://api.github.com/users/wolfthefallen/orgs","repos_url":"https://api.github.com/users/wolfthefallen/repos","events_url":"https://api.github.com/users/wolfthefallen/events{/privacy}","received_events_url":"https://api.github.com/users/wolfthefallen/received_events","type":"User","site_admin":false},"body":"This PR will add RPC `/db/table/insert/multi` functionality to insert multiple rows in to a database. Additionally if `deconflict_ids` is true to will generate new ID to add that row into the database. To support this `make_uid` functionality for messages and visits have been moved to `utilities.py` to allow both client and server access to these functions. \r\n\r\n- [ ] Function description for `/db/table/insert/multi` makes since\r\n\r\nTesting:\r\n- [ ] Pull down PR and start King Phisher server and Client utilizing new library\r\n- [ ] Run a test campaign to verify message uids are being generated correctly\r\n- [ ] Visit pages from test campaign to verify visit uids are being generated corrrectly\r\n- [ ] Start RPC Terminal in King Phisher Client\r\n- [ ] use rpc.('/db/table/insert/multi', str(table_name), list(keys), list((values,), (values,))) to insert multiple rows with specified values into target table.\r\n-  [ ] use rpc.('/db/table/insert/multi', str(table_name), list(keys), list((values,), (values,)), deconflict_ids=True) to insert multiple rows with specified values into target table and and deconflict ids of rows.","created_at":"2017-02-20T14:49:05Z","updated_at":"2017-02-20T15:36:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0beb5c15bf5eb92beb4d3b53c9fd7f24be0a0979","assignee":{"login":"zeroSteiner","id":2058303,"avatar_url":"https://avatars.githubusercontent.com/u/2058303?v=3","gravatar_id":"","url":"https://api.github.com/users/zeroSteiner","html_url":"https://github.com/zeroSteiner","followers_url":"https://api.github.com/users/zeroSteiner/followers","following_url":"https://api.github.com/users/zeroSteiner/following{/other_user}","gists_url":"https://api.github.com/users/zeroSteiner/gists{/gist_id}","starred_url":"https://api.github.com/users/zeroSteiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeroSteiner/subscriptions","organizations_url":"https://api.github.com/users/zeroSteiner/orgs","repos_url":"https://api.github.com/users/zeroSteiner/repos","events_url":"https://api.github.com/users/zeroSteiner/events{/privacy}","received_events_url":"https://api.github.com/users/zeroSteiner/received_events","type":"User","site_admin":false},"assignees":[{"login":"zeroSteiner","id":2058303,"avatar_url":"https://avatars.githubusercontent.com/u/2058303?v=3","gravatar_id":"","url":"https://api.github.com/users/zeroSteiner","html_url":"https://github.com/zeroSteiner","followers_url":"https://api.github.com/users/zeroSteiner/followers","following_url":"https://api.github.com/users/zeroSteiner/following{/other_user}","gists_url":"https://api.github.com/users/zeroSteiner/gists{/gist_id}","starred_url":"https://api.github.com/users/zeroSteiner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zeroSteiner/subscriptions","organizations_url":"https://api.github.com/users/zeroSteiner/orgs","repos_url":"https://api.github.com/users/zeroSteiner/repos","events_url":"https://api.github.com/users/zeroSteiner/events{/privacy}","received_events_url":"https://api.github.com/users/zeroSteiner/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/securestate/king-phisher/pulls/192/commits","review_comments_url":"https://api.github.com/repos/securestate/king-phisher/pulls/192/comments","review_comment_url":"https://api.github.com/repos/securestate/king-phisher/pulls/comments{/number}","comments_url":"https://api.github.com/repos/securestate/king-phisher/issues/192/comments","statuses_url":"https://api.github.com/repos/securestate/king-phisher/statuses/b5b1ffcf4389add2a62a4304463453f4abb3b8c7","head":{"label":"wolfthefallen:rpc_insert_multi","ref":"rpc_insert_multi","sha":"b5b1ffcf4389add2a62a4304463453f4abb3b8c7","user":{"login":"wolfthefallen","id":9035933,"avatar_url":"https://avatars.githubusercontent.com/u/9035933?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfthefallen","html_url":"https://github.com/wolfthefallen","followers_url":"https://api.github.com/users/wolfthefallen/followers","following_url":"https://api.github.com/users/wolfthefallen/following{/other_user}","gists_url":"https://api.github.com/users/wolfthefallen/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfthefallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfthefallen/subscriptions","organizations_url":"https://api.github.com/users/wolfthefallen/orgs","repos_url":"https://api.github.com/users/wolfthefallen/repos","events_url":"https://api.github.com/users/wolfthefallen/events{/privacy}","received_events_url":"https://api.github.com/users/wolfthefallen/received_events","type":"User","site_admin":false},"repo":{"id":39632588,"name":"king-phisher","full_name":"wolfthefallen/king-phisher","owner":{"login":"wolfthefallen","id":9035933,"avatar_url":"https://avatars.githubusercontent.com/u/9035933?v=3","gravatar_id":"","url":"https://api.github.com/users/wolfthefallen","html_url":"https://github.com/wolfthefallen","followers_url":"https://api.github.com/users/wolfthefallen/followers","following_url":"https://api.github.com/users/wolfthefallen/following{/other_user}","gists_url":"https://api.github.com/users/wolfthefallen/gists{/gist_id}","starred_url":"https://api.github.com/users/wolfthefallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wolfthefallen/subscriptions","organizations_url":"https://api.github.com/users/wolfthefallen/orgs","repos_url":"https://api.github.com/users/wolfthefallen/repos","events_url":"https://api.github.com/users/wolfthefallen/events{/privacy}","received_events_url":"https://api.github.com/users/wolfthefallen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wolfthefallen/king-phisher","description":"Phishing Campaign Toolkit","fork":true,"url":"https://api.github.com/repos/wolfthefallen/king-phisher","forks_url":"https://api.github.com/repos/wolfthefallen/king-phisher/forks","keys_url":"https://api.github.com/repos/wolfthefallen/king-phisher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wolfthefallen/king-phisher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wolfthefallen/king-phisher/teams","hooks_url":"https://api.github.com/repos/wolfthefallen/king-phisher/hooks","issue_events_url":"https://api.github.com/repos/wolfthefallen/king-phisher/issues/events{/number}","events_url":"https://api.github.com/repos/wolfthefallen/king-phisher/events","assignees_url":"https://api.github.com/repos/wolfthefallen/king-phisher/assignees{/user}","branches_url":"https://api.github.com/repos/wolfthefallen/king-phisher/branches{/branch}","tags_url":"https://api.github.com/repos/wolfthefallen/king-phisher/tags","blobs_url":"https://api.github.com/repos/wolfthefallen/king-phisher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wolfthefallen/king-phisher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wolfthefallen/king-phisher/git/refs{/sha}","trees_url":"https://api.github.com/repos/wolfthefallen/king-phisher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wolfthefallen/king-phisher/statuses/{sha}","languages_url":"https://api.github.com/repos/wolfthefallen/king-phisher/languages","stargazers_url":"https://api.github.com/repos/wolfthefallen/king-phisher/stargazers","contributors_url":"https://api.github.com/repos/wolfthefallen/king-phisher/contributors","subscribers_url":"https://api.github.com/repos/wolfthefallen/king-phisher/subscribers","subscription_url":"https://api.github.com/repos/wolfthefallen/king-phisher/subscription","commits_url":"https://api.github.com/repos/wolfthefallen/king-phisher/commits{/sha}","git_commits_url":"https://api.github.com/repos/wolfthefallen/king-phisher/git/commits{/sha}","comments_url":"https://api.github.com/repos/wolfthefallen/king-phisher/comments{/number}","issue_comment_url":"https://api.github.com/repos/wolfthefallen/king-phisher/issues/comments{/number}","contents_url":"https://api.github.com/repos/wolfthefallen/king-phisher/contents/{+path}","compare_url":"https://api.github.com/repos/wolfthefallen/king-phisher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wolfthefallen/king-phisher/merges","archive_url":"https://api.github.com/repos/wolfthefallen/king-phisher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wolfthefallen/king-phisher/downloads","issues_url":"https://api.github.com/repos/wolfthefallen/king-phisher/issues{/number}","pulls_url":"https://api.github.com/repos/wolfthefallen/king-phisher/pulls{/number}","milestones_url":"https://api.github.com/repos/wolfthefallen/king-phisher/milestones{/number}","notifications_url":"https://api.github.com/repos/wolfthefallen/king-phisher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wolfthefallen/king-phisher/labels{/name}","releases_url":"https://api.github.com/repos/wolfthefallen/king-phisher/releases{/id}","deployments_url":"https://api.github.com/repos/wolfthefallen/king-phisher/deployments","created_at":"2015-07-24T12:44:37Z","updated_at":"2016-01-14T22:18:46Z","pushed_at":"2017-02-20T14:36:23Z","git_url":"git://github.com/wolfthefallen/king-phisher.git","ssh_url":"git@github.com:wolfthefallen/king-phisher.git","clone_url":"https://github.com/wolfthefallen/king-phisher.git","svn_url":"https://github.com/wolfthefallen/king-phisher","homepage":"","size":4140,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"securestate:dev","ref":"dev","sha":"c963818f3acf0b5ff59eaf65f75c8c745602b15d","user":{"login":"securestate","id":3228981,"avatar_url":"https://avatars.githubusercontent.com/u/3228981?v=3","gravatar_id":"","url":"https://api.github.com/users/securestate","html_url":"https://github.com/securestate","followers_url":"https://api.github.com/users/securestate/followers","following_url":"https://api.github.com/users/securestate/following{/other_user}","gists_url":"https://api.github.com/users/securestate/gists{/gist_id}","starred_url":"https://api.github.com/users/securestate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/securestate/subscriptions","organizations_url":"https://api.github.com/users/securestate/orgs","repos_url":"https://api.github.com/users/securestate/repos","events_url":"https://api.github.com/users/securestate/events{/privacy}","received_events_url":"https://api.github.com/users/securestate/received_events","type":"Organization","site_admin":false},"repo":{"id":15592447,"name":"king-phisher","full_name":"securestate/king-phisher","owner":{"login":"securestate","id":3228981,"avatar_url":"https://avatars.githubusercontent.com/u/3228981?v=3","gravatar_id":"","url":"https://api.github.com/users/securestate","html_url":"https://github.com/securestate","followers_url":"https://api.github.com/users/securestate/followers","following_url":"https://api.github.com/users/securestate/following{/other_user}","gists_url":"https://api.github.com/users/securestate/gists{/gist_id}","starred_url":"https://api.github.com/users/securestate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/securestate/subscriptions","organizations_url":"https://api.github.com/users/securestate/orgs","repos_url":"https://api.github.com/users/securestate/repos","events_url":"https://api.github.com/users/securestate/events{/privacy}","received_events_url":"https://api.github.com/users/securestate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/securestate/king-phisher","description":"Phishing Campaign Toolkit","fork":false,"url":"https://api.github.com/repos/securestate/king-phisher","forks_url":"https://api.github.com/repos/securestate/king-phisher/forks","keys_url":"https://api.github.com/repos/securestate/king-phisher/keys{/key_id}","collaborators_url":"https://api.github.com/repos/securestate/king-phisher/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/securestate/king-phisher/teams","hooks_url":"https://api.github.com/repos/securestate/king-phisher/hooks","issue_events_url":"https://api.github.com/repos/securestate/king-phisher/issues/events{/number}","events_url":"https://api.github.com/repos/securestate/king-phisher/events","assignees_url":"https://api.github.com/repos/securestate/king-phisher/assignees{/user}","branches_url":"https://api.github.com/repos/securestate/king-phisher/branches{/branch}","tags_url":"https://api.github.com/repos/securestate/king-phisher/tags","blobs_url":"https://api.github.com/repos/securestate/king-phisher/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/securestate/king-phisher/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/securestate/king-phisher/git/refs{/sha}","trees_url":"https://api.github.com/repos/securestate/king-phisher/git/trees{/sha}","statuses_url":"https://api.github.com/repos/securestate/king-phisher/statuses/{sha}","languages_url":"https://api.github.com/repos/securestate/king-phisher/languages","stargazers_url":"https://api.github.com/repos/securestate/king-phisher/stargazers","contributors_url":"https://api.github.com/repos/securestate/king-phisher/contributors","subscribers_url":"https://api.github.com/repos/securestate/king-phisher/subscribers","subscription_url":"https://api.github.com/repos/securestate/king-phisher/subscription","commits_url":"https://api.github.com/repos/securestate/king-phisher/commits{/sha}","git_commits_url":"https://api.github.com/repos/securestate/king-phisher/git/commits{/sha}","comments_url":"https://api.github.com/repos/securestate/king-phisher/comments{/number}","issue_comment_url":"https://api.github.com/repos/securestate/king-phisher/issues/comments{/number}","contents_url":"https://api.github.com/repos/securestate/king-phisher/contents/{+path}","compare_url":"https://api.github.com/repos/securestate/king-phisher/compare/{base}...{head}","merges_url":"https://api.github.com/repos/securestate/king-phisher/merges","archive_url":"https://api.github.com/repos/securestate/king-phisher/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/securestate/king-phisher/downloads","issues_url":"https://api.github.com/repos/securestate/king-phisher/issues{/number}","pulls_url":"https://api.github.com/repos/securestate/king-phisher/pulls{/number}","milestones_url":"https://api.github.com/repos/securestate/king-phisher/milestones{/number}","notifications_url":"https://api.github.com/repos/securestate/king-phisher/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/securestate/king-phisher/labels{/name}","releases_url":"https://api.github.com/repos/securestate/king-phisher/releases{/id}","deployments_url":"https://api.github.com/repos/securestate/king-phisher/deployments","created_at":"2014-01-02T20:00:55Z","updated_at":"2017-02-19T02:53:17Z","pushed_at":"2017-02-20T14:49:06Z","git_url":"git://github.com/securestate/king-phisher.git","ssh_url":"git@github.com:securestate/king-phisher.git","clone_url":"https://github.com/securestate/king-phisher.git","svn_url":"https://github.com/securestate/king-phisher","homepage":"","size":4980,"stargazers_count":321,"watchers_count":321,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":100,"mirror_url":null,"open_issues_count":1,"forks":100,"open_issues":1,"watchers":321,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/192"},"html":{"href":"https://github.com/securestate/king-phisher/pull/192"},"issue":{"href":"https://api.github.com/repos/securestate/king-phisher/issues/192"},"comments":{"href":"https://api.github.com/repos/securestate/king-phisher/issues/192/comments"},"review_comments":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/192/comments"},"review_comment":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/securestate/king-phisher/pulls/192/commits"},"statuses":{"href":"https://api.github.com/repos/securestate/king-phisher/statuses/b5b1ffcf4389add2a62a4304463453f4abb3b8c7"}}}}
{"actor":{"display_login":"zeroSteiner"}}