{"action":"created","comment":{"url":"https://api.github.com/repos/IBM/chiffre/pulls/comments/209039121","pull_request_review_id":144975994,"id":209039121,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwOTAzOTEyMQ==","diff_hunk":"@@ -48,15 +48,17 @@ class ScanChainUtils(implicit opt: Arguments) {\n \n   private def bind(f: ScanField, name: String)(implicit opt: Arguments): ScanField = try {\n     f match {\n-        case x: ScanField if x.value.nonEmpty => throw new ScanChainException(\n-          s\"Tried to rebind already bound ScanField $f (name: $name)\")\n-        case x: Seed        => x.bind(BigInt(x.width, rand))\n-        case x: Difficulty  => x.bind(opt.probability)\n-        case x: Mask        => x.bind(opt.mask)\n-        case x: StuckAt     => x.bind(opt.stuckAt)\n-        case x: Cycle       => x.bind(opt.cycle)\n-        case x: CycleInject => x.bind(opt.cycleInject)\n-        case _              => throw new ScanChainException(s\"Unimplemented binding for ScanField $f\")\n+      case x: ScanField if x.value.nonEmpty =>\n+        if (opt.errorIfBound) {\n+          throw new ScanChainException(s\"Tried to rebind already bound ScanField $f (name: $name)\") }\n+        x\n+      case x: Seed        => x.bind(BigInt(x.width, rand))\n+      case x: Difficulty  => x.bind(opt.probability)\n+      case x: Mask        => x.bind(opt.mask)\n+      case x: StuckAt     => x.bind(opt.stuckAt)\n+      case x: Cycle       => x.bind(opt.cycle)\n+      case x: CycleInject => x.bind(opt.cycleInject)\n+      case _              => throw new ScanChainException(s\"Unimplemented binding for ScanField $f\")","path":"src/main/scala/chiffre/util/ScanChainConfig.scala","position":43,"original_position":43,"commit_id":"cd64be49341570b7523c22a0fc3150e2f69b199e","original_commit_id":"fb2d12a0ce924dd293a3d6e2545e89354c26a43c","user":{"login":"seldridge","id":1018530,"node_id":"MDQ6VXNlcjEwMTg1MzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1018530?v=4","gravatar_id":"","url":"https://api.github.com/users/seldridge","html_url":"https://github.com/seldridge","followers_url":"https://api.github.com/users/seldridge/followers","following_url":"https://api.github.com/users/seldridge/following{/other_user}","gists_url":"https://api.github.com/users/seldridge/gists{/gist_id}","starred_url":"https://api.github.com/users/seldridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seldridge/subscriptions","organizations_url":"https://api.github.com/users/seldridge/orgs","repos_url":"https://api.github.com/users/seldridge/repos","events_url":"https://api.github.com/users/seldridge/events{/privacy}","received_events_url":"https://api.github.com/users/seldridge/received_events","type":"User","site_admin":false},"body":"There are two ways of binding values in a scan field provided by this PR with decreasing precedence:\r\n\r\n  1. A user manually updates values in the JSON\r\n  2. Any unbound value in the scan chain can get a default value provided via a command line argument\r\n\r\nThat first case will cause a bound value to never be overwritten by one of the CLI arguments (though I should simplify it to `case x: ScanField if x.isBound =>`). It would be clearer if I updated the CLI API to be `--default-mask`, etc.\r\n\r\nFor this reason, I think that this enables what you need with #19, though there currently exists no CLI API that lets you bind a specific scan field instance (only all scan field types). If the user wants this behavior, they need to go and edit the JSON.\r\n\r\nDoes that make sense to you?","created_at":"2018-08-09T18:44:59Z","updated_at":"2018-08-09T18:45:00Z","html_url":"https://github.com/IBM/chiffre/pull/21#discussion_r209039121","pull_request_url":"https://api.github.com/repos/IBM/chiffre/pulls/21","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/comments/209039121"},"html":{"href":"https://github.com/IBM/chiffre/pull/21#discussion_r209039121"},"pull_request":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/21"}},"in_reply_to_id":208919656},"pull_request":{"url":"https://api.github.com/repos/IBM/chiffre/pulls/21","id":207165487,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA3MTY1NDg3","html_url":"https://github.com/IBM/chiffre/pull/21","diff_url":"https://github.com/IBM/chiffre/pull/21.diff","patch_url":"https://github.com/IBM/chiffre/pull/21.patch","issue_url":"https://api.github.com/repos/IBM/chiffre/issues/21","number":21,"state":"open","locked":false,"title":"Serialize ScanFields and their bound/unbound values","user":{"login":"seldridge","id":1018530,"node_id":"MDQ6VXNlcjEwMTg1MzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1018530?v=4","gravatar_id":"","url":"https://api.github.com/users/seldridge","html_url":"https://github.com/seldridge","followers_url":"https://api.github.com/users/seldridge/followers","following_url":"https://api.github.com/users/seldridge/following{/other_user}","gists_url":"https://api.github.com/users/seldridge/gists{/gist_id}","starred_url":"https://api.github.com/users/seldridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seldridge/subscriptions","organizations_url":"https://api.github.com/users/seldridge/orgs","repos_url":"https://api.github.com/users/seldridge/repos","events_url":"https://api.github.com/users/seldridge/events{/privacy}","received_events_url":"https://api.github.com/users/seldridge/received_events","type":"User","site_admin":false},"body":"This adds custom serializers for `ScanField` and `InjectorInfo` that will include all scan fields and their bound/unbound values in scan chain JSON. Bound fields are serialized as a number (mapping to a `BigInt` in Scala) and unbound fields will show up as the String `null`.\r\n\r\nSummary of changes:\r\n  - Add InjectorInfo.unbind method to unbind all fields\r\n  - Add equality methods for InjectorInfo and ScanField\r\n  - Add InjectorInfo, ScanField serializers/deserializers\r\n  - Change behavior of ScanChain.bind(BigInt) to bind None without error\r\n  - Includes documentation of JsonProtocol\r\n  - Causes ScanChainConfig utility to not override bound fields, but will error if requested (via command line argument)\r\n\r\nAn example of JSON output is below. The `Mask` is bound to 1 and the `StuckAt` is unbound:\r\n```json\r\n{\r\n  \"id-0\":[\r\n    {\r\n      \"name\":\"Top.Top.a\",\r\n      \"injector\":{\r\n        \"class\":\"chiffre.inject.StuckAtInjectorInfo\",\r\n        \"bitWidth\":5,\r\n        \"fields\":[\r\n          {\r\n            \"class\":\"chiffre.inject.Mask\",\r\n            \"width\":5,\r\n            \"value\":1\r\n          },\r\n          {\r\n            \"class\":\"chiffre.inject.StuckAt\",\r\n            \"width\":5,\r\n            \"value\":null\r\n          }\r\n        ]\r\n      }\r\n    }\r\n  ]\r\n}\r\n```","created_at":"2018-08-08T23:32:43Z","updated_at":"2018-08-09T18:45:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5c58255decf2bf5cebf6f59fb05f1169e762c916","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/IBM/chiffre/pulls/21/commits","review_comments_url":"https://api.github.com/repos/IBM/chiffre/pulls/21/comments","review_comment_url":"https://api.github.com/repos/IBM/chiffre/pulls/comments{/number}","comments_url":"https://api.github.com/repos/IBM/chiffre/issues/21/comments","statuses_url":"https://api.github.com/repos/IBM/chiffre/statuses/cd64be49341570b7523c22a0fc3150e2f69b199e","head":{"label":"seldridge:serialize-scan-fields","ref":"serialize-scan-fields","sha":"cd64be49341570b7523c22a0fc3150e2f69b199e","user":{"login":"seldridge","id":1018530,"node_id":"MDQ6VXNlcjEwMTg1MzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1018530?v=4","gravatar_id":"","url":"https://api.github.com/users/seldridge","html_url":"https://github.com/seldridge","followers_url":"https://api.github.com/users/seldridge/followers","following_url":"https://api.github.com/users/seldridge/following{/other_user}","gists_url":"https://api.github.com/users/seldridge/gists{/gist_id}","starred_url":"https://api.github.com/users/seldridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seldridge/subscriptions","organizations_url":"https://api.github.com/users/seldridge/orgs","repos_url":"https://api.github.com/users/seldridge/repos","events_url":"https://api.github.com/users/seldridge/events{/privacy}","received_events_url":"https://api.github.com/users/seldridge/received_events","type":"User","site_admin":false},"repo":{"id":138644290,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg2NDQyOTA=","name":"chiffre","full_name":"seldridge/chiffre","owner":{"login":"seldridge","id":1018530,"node_id":"MDQ6VXNlcjEwMTg1MzA=","avatar_url":"https://avatars0.githubusercontent.com/u/1018530?v=4","gravatar_id":"","url":"https://api.github.com/users/seldridge","html_url":"https://github.com/seldridge","followers_url":"https://api.github.com/users/seldridge/followers","following_url":"https://api.github.com/users/seldridge/following{/other_user}","gists_url":"https://api.github.com/users/seldridge/gists{/gist_id}","starred_url":"https://api.github.com/users/seldridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seldridge/subscriptions","organizations_url":"https://api.github.com/users/seldridge/orgs","repos_url":"https://api.github.com/users/seldridge/repos","events_url":"https://api.github.com/users/seldridge/events{/privacy}","received_events_url":"https://api.github.com/users/seldridge/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/seldridge/chiffre","description":"A fault-injection framework using Chisel and FIRRTL","fork":true,"url":"https://api.github.com/repos/seldridge/chiffre","forks_url":"https://api.github.com/repos/seldridge/chiffre/forks","keys_url":"https://api.github.com/repos/seldridge/chiffre/keys{/key_id}","collaborators_url":"https://api.github.com/repos/seldridge/chiffre/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/seldridge/chiffre/teams","hooks_url":"https://api.github.com/repos/seldridge/chiffre/hooks","issue_events_url":"https://api.github.com/repos/seldridge/chiffre/issues/events{/number}","events_url":"https://api.github.com/repos/seldridge/chiffre/events","assignees_url":"https://api.github.com/repos/seldridge/chiffre/assignees{/user}","branches_url":"https://api.github.com/repos/seldridge/chiffre/branches{/branch}","tags_url":"https://api.github.com/repos/seldridge/chiffre/tags","blobs_url":"https://api.github.com/repos/seldridge/chiffre/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/seldridge/chiffre/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/seldridge/chiffre/git/refs{/sha}","trees_url":"https://api.github.com/repos/seldridge/chiffre/git/trees{/sha}","statuses_url":"https://api.github.com/repos/seldridge/chiffre/statuses/{sha}","languages_url":"https://api.github.com/repos/seldridge/chiffre/languages","stargazers_url":"https://api.github.com/repos/seldridge/chiffre/stargazers","contributors_url":"https://api.github.com/repos/seldridge/chiffre/contributors","subscribers_url":"https://api.github.com/repos/seldridge/chiffre/subscribers","subscription_url":"https://api.github.com/repos/seldridge/chiffre/subscription","commits_url":"https://api.github.com/repos/seldridge/chiffre/commits{/sha}","git_commits_url":"https://api.github.com/repos/seldridge/chiffre/git/commits{/sha}","comments_url":"https://api.github.com/repos/seldridge/chiffre/comments{/number}","issue_comment_url":"https://api.github.com/repos/seldridge/chiffre/issues/comments{/number}","contents_url":"https://api.github.com/repos/seldridge/chiffre/contents/{+path}","compare_url":"https://api.github.com/repos/seldridge/chiffre/compare/{base}...{head}","merges_url":"https://api.github.com/repos/seldridge/chiffre/merges","archive_url":"https://api.github.com/repos/seldridge/chiffre/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/seldridge/chiffre/downloads","issues_url":"https://api.github.com/repos/seldridge/chiffre/issues{/number}","pulls_url":"https://api.github.com/repos/seldridge/chiffre/pulls{/number}","milestones_url":"https://api.github.com/repos/seldridge/chiffre/milestones{/number}","notifications_url":"https://api.github.com/repos/seldridge/chiffre/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/seldridge/chiffre/labels{/name}","releases_url":"https://api.github.com/repos/seldridge/chiffre/releases{/id}","deployments_url":"https://api.github.com/repos/seldridge/chiffre/deployments","created_at":"2018-06-25T20:06:54Z","updated_at":"2018-06-25T20:06:56Z","pushed_at":"2018-08-09T18:31:19Z","git_url":"git://github.com/seldridge/chiffre.git","ssh_url":"git@github.com:seldridge/chiffre.git","clone_url":"https://github.com/seldridge/chiffre.git","svn_url":"https://github.com/seldridge/chiffre","homepage":"","size":11647,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"IBM:master","ref":"master","sha":"73164868a03ac410365cf011c838a32a28788fab","user":{"login":"IBM","id":1459110,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0NTkxMTA=","avatar_url":"https://avatars0.githubusercontent.com/u/1459110?v=4","gravatar_id":"","url":"https://api.github.com/users/IBM","html_url":"https://github.com/IBM","followers_url":"https://api.github.com/users/IBM/followers","following_url":"https://api.github.com/users/IBM/following{/other_user}","gists_url":"https://api.github.com/users/IBM/gists{/gist_id}","starred_url":"https://api.github.com/users/IBM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IBM/subscriptions","organizations_url":"https://api.github.com/users/IBM/orgs","repos_url":"https://api.github.com/users/IBM/repos","events_url":"https://api.github.com/users/IBM/events{/privacy}","received_events_url":"https://api.github.com/users/IBM/received_events","type":"Organization","site_admin":false},"repo":{"id":119565036,"node_id":"MDEwOlJlcG9zaXRvcnkxMTk1NjUwMzY=","name":"chiffre","full_name":"IBM/chiffre","owner":{"login":"IBM","id":1459110,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0NTkxMTA=","avatar_url":"https://avatars0.githubusercontent.com/u/1459110?v=4","gravatar_id":"","url":"https://api.github.com/users/IBM","html_url":"https://github.com/IBM","followers_url":"https://api.github.com/users/IBM/followers","following_url":"https://api.github.com/users/IBM/following{/other_user}","gists_url":"https://api.github.com/users/IBM/gists{/gist_id}","starred_url":"https://api.github.com/users/IBM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/IBM/subscriptions","organizations_url":"https://api.github.com/users/IBM/orgs","repos_url":"https://api.github.com/users/IBM/repos","events_url":"https://api.github.com/users/IBM/events{/privacy}","received_events_url":"https://api.github.com/users/IBM/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/IBM/chiffre","description":"A fault-injection framework using Chisel and FIRRTL","fork":false,"url":"https://api.github.com/repos/IBM/chiffre","forks_url":"https://api.github.com/repos/IBM/chiffre/forks","keys_url":"https://api.github.com/repos/IBM/chiffre/keys{/key_id}","collaborators_url":"https://api.github.com/repos/IBM/chiffre/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/IBM/chiffre/teams","hooks_url":"https://api.github.com/repos/IBM/chiffre/hooks","issue_events_url":"https://api.github.com/repos/IBM/chiffre/issues/events{/number}","events_url":"https://api.github.com/repos/IBM/chiffre/events","assignees_url":"https://api.github.com/repos/IBM/chiffre/assignees{/user}","branches_url":"https://api.github.com/repos/IBM/chiffre/branches{/branch}","tags_url":"https://api.github.com/repos/IBM/chiffre/tags","blobs_url":"https://api.github.com/repos/IBM/chiffre/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/IBM/chiffre/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/IBM/chiffre/git/refs{/sha}","trees_url":"https://api.github.com/repos/IBM/chiffre/git/trees{/sha}","statuses_url":"https://api.github.com/repos/IBM/chiffre/statuses/{sha}","languages_url":"https://api.github.com/repos/IBM/chiffre/languages","stargazers_url":"https://api.github.com/repos/IBM/chiffre/stargazers","contributors_url":"https://api.github.com/repos/IBM/chiffre/contributors","subscribers_url":"https://api.github.com/repos/IBM/chiffre/subscribers","subscription_url":"https://api.github.com/repos/IBM/chiffre/subscription","commits_url":"https://api.github.com/repos/IBM/chiffre/commits{/sha}","git_commits_url":"https://api.github.com/repos/IBM/chiffre/git/commits{/sha}","comments_url":"https://api.github.com/repos/IBM/chiffre/comments{/number}","issue_comment_url":"https://api.github.com/repos/IBM/chiffre/issues/comments{/number}","contents_url":"https://api.github.com/repos/IBM/chiffre/contents/{+path}","compare_url":"https://api.github.com/repos/IBM/chiffre/compare/{base}...{head}","merges_url":"https://api.github.com/repos/IBM/chiffre/merges","archive_url":"https://api.github.com/repos/IBM/chiffre/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/IBM/chiffre/downloads","issues_url":"https://api.github.com/repos/IBM/chiffre/issues{/number}","pulls_url":"https://api.github.com/repos/IBM/chiffre/pulls{/number}","milestones_url":"https://api.github.com/repos/IBM/chiffre/milestones{/number}","notifications_url":"https://api.github.com/repos/IBM/chiffre/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/IBM/chiffre/labels{/name}","releases_url":"https://api.github.com/repos/IBM/chiffre/releases{/id}","deployments_url":"https://api.github.com/repos/IBM/chiffre/deployments","created_at":"2018-01-30T16:45:57Z","updated_at":"2018-08-06T19:58:54Z","pushed_at":"2018-08-09T18:31:20Z","git_url":"git://github.com/IBM/chiffre.git","ssh_url":"git@github.com:IBM/chiffre.git","clone_url":"https://github.com/IBM/chiffre.git","svn_url":"https://github.com/IBM/chiffre","homepage":"","size":11637,"stargazers_count":1,"watchers_count":1,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":6,"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":2,"open_issues":6,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/21"},"html":{"href":"https://github.com/IBM/chiffre/pull/21"},"issue":{"href":"https://api.github.com/repos/IBM/chiffre/issues/21"},"comments":{"href":"https://api.github.com/repos/IBM/chiffre/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/IBM/chiffre/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/IBM/chiffre/statuses/cd64be49341570b7523c22a0fc3150e2f69b199e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"seldridge"}}