{"action":"created","comment":{"url":"https://api.github.com/repos/goharbor/harbor/pulls/comments/219424034","pull_request_review_id":157596268,"id":219424034,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxOTQyNDAzNA==","diff_hunk":"@@ -0,0 +1,141 @@\n+// Copyright 2018 The Harbor Authors\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//    http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+\n+package scan\n+\n+import (\n+\t\"bytes\"\n+\t\"fmt\"\n+\t\"io/ioutil\"\n+\n+\t\"net/http\"\n+\t\"os\"\n+\t\"strings\"\n+\n+\t\"github.com/goharbor/harbor/src/common\"\n+\t\"github.com/goharbor/harbor/src/common/dao\"\n+\t\"github.com/goharbor/harbor/src/jobservice/env\"\n+\t\"github.com/goharbor/harbor/src/jobservice/job/impl/utils\"\n+)\n+\n+// All query the DB and Registry for all image and tags,\n+// then call Harbor's API to scan each of them.\n+type All struct {\n+\tregistryURL          string\n+\tsecret               string\n+\ttokenServiceEndpoint string\n+\tharborAPIEndpoint    string\n+\tcoreClient           *http.Client\n+}\n+\n+// MaxFails implements the interface in job/Interface\n+func (sa *All) MaxFails() uint {\n+\treturn 1\n+}\n+\n+// ShouldRetry implements the interface in job/Interface\n+func (sa *All) ShouldRetry() bool {\n+\treturn false\n+}\n+\n+// Validate implements the interface in job/Interface\n+func (sa *All) Validate(params map[string]interface{}) error {\n+\tif len(params) > 0 {\n+\t\treturn fmt.Errorf(\"the parms should be empty for scan all job\")\n+\t}\n+\treturn nil\n+}\n+\n+// Run implements the interface in job/Interface\n+func (sa *All) Run(ctx env.JobContext, params map[string]interface{}) error {\n+\tlogger := ctx.GetLogger()\n+\tlogger.Info(\"Scanning all the images in the registry\")\n+\terr := sa.init(ctx)\n+\tif err != nil {\n+\t\tlogger.Errorf(\"Failed to initialize the job handler, error: %v\", err)\n+\t\treturn err\n+\t}\n+\n+\trepos, err := dao.GetRepositories()\n+\tif err != nil {\n+\t\tlogger.Errorf(\"Failed to get the list of repositories, error: %v\", err)\n+\t\treturn err\n+\t}\n+\n+\tfor _, r := range repos {\n+\t\trepoClient, err := utils.NewRepositoryClientForJobservice(r.Name, sa.registryURL, sa.secret, sa.tokenServiceEndpoint)\n+\t\tif err != nil {\n+\t\t\tlogger.Errorf(\"Failed to get repo client for repo: %s, error: %v\", r.Name, err)\n+\t\t\tcontinue\n+\t\t}\n+\t\ttags, err := repoClient.ListTag()\n+\t\tif err != nil {\n+\t\t\tlogger.Errorf(\"Failed to get tags for repo: %s, error: %v\", r.Name, err)\n+\t\t\tcontinue\n+\t\t}\n+\t\tfor _, t := range tags {\n+\t\t\tlogger.Infof(\"Calling harbor-core API to scan image, %s:%s\", r.Name, t)","path":"src/jobservice/job/impl/scan/all.go","position":88,"original_position":88,"commit_id":"7baee7847cd8e788d77a653226a8a68dca02bcff","original_commit_id":"7baee7847cd8e788d77a653226a8a68dca02bcff","user":{"login":"reasonerjt","id":2390463,"node_id":"MDQ6VXNlcjIzOTA0NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false},"body":"This is the logger of the particular job execution so we should put it in.","created_at":"2018-09-21T08:43:32Z","updated_at":"2018-09-21T08:43:32Z","html_url":"https://github.com/goharbor/harbor/pull/5934#discussion_r219424034","pull_request_url":"https://api.github.com/repos/goharbor/harbor/pulls/5934","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/comments/219424034"},"html":{"href":"https://github.com/goharbor/harbor/pull/5934#discussion_r219424034"},"pull_request":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/5934"}},"in_reply_to_id":219376245},"pull_request":{"url":"https://api.github.com/repos/goharbor/harbor/pulls/5934","id":216969690,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE2OTY5Njkw","html_url":"https://github.com/goharbor/harbor/pull/5934","diff_url":"https://github.com/goharbor/harbor/pull/5934.diff","patch_url":"https://github.com/goharbor/harbor/pull/5934.patch","issue_url":"https://api.github.com/repos/goharbor/harbor/issues/5934","number":5934,"state":"open","locked":false,"title":"Add Scan All job to job service","user":{"login":"reasonerjt","id":2390463,"node_id":"MDQ6VXNlcjIzOTA0NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false},"body":"This commit adds the job to scan all images on registry.\r\nAlso make necessary change to Secret based security context, to\r\njob service has higher permission to call the API of core service.\r\n\r\nSigned-off-by: Daniel Jiang <jiangd@vmware.com>","created_at":"2018-09-20T13:21:38Z","updated_at":"2018-09-21T08:43:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4404626b423416418ad956e985cf1302e9bb240a","assignee":{"login":"wy65701436","id":2841473,"node_id":"MDQ6VXNlcjI4NDE0NzM=","avatar_url":"https://avatars3.githubusercontent.com/u/2841473?v=4","gravatar_id":"","url":"https://api.github.com/users/wy65701436","html_url":"https://github.com/wy65701436","followers_url":"https://api.github.com/users/wy65701436/followers","following_url":"https://api.github.com/users/wy65701436/following{/other_user}","gists_url":"https://api.github.com/users/wy65701436/gists{/gist_id}","starred_url":"https://api.github.com/users/wy65701436/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wy65701436/subscriptions","organizations_url":"https://api.github.com/users/wy65701436/orgs","repos_url":"https://api.github.com/users/wy65701436/repos","events_url":"https://api.github.com/users/wy65701436/events{/privacy}","received_events_url":"https://api.github.com/users/wy65701436/received_events","type":"User","site_admin":false},"assignees":[{"login":"wy65701436","id":2841473,"node_id":"MDQ6VXNlcjI4NDE0NzM=","avatar_url":"https://avatars3.githubusercontent.com/u/2841473?v=4","gravatar_id":"","url":"https://api.github.com/users/wy65701436","html_url":"https://github.com/wy65701436","followers_url":"https://api.github.com/users/wy65701436/followers","following_url":"https://api.github.com/users/wy65701436/following{/other_user}","gists_url":"https://api.github.com/users/wy65701436/gists{/gist_id}","starred_url":"https://api.github.com/users/wy65701436/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wy65701436/subscriptions","organizations_url":"https://api.github.com/users/wy65701436/orgs","repos_url":"https://api.github.com/users/wy65701436/repos","events_url":"https://api.github.com/users/wy65701436/events{/privacy}","received_events_url":"https://api.github.com/users/wy65701436/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/goharbor/harbor/pulls/5934/commits","review_comments_url":"https://api.github.com/repos/goharbor/harbor/pulls/5934/comments","review_comment_url":"https://api.github.com/repos/goharbor/harbor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/goharbor/harbor/issues/5934/comments","statuses_url":"https://api.github.com/repos/goharbor/harbor/statuses/7baee7847cd8e788d77a653226a8a68dca02bcff","head":{"label":"reasonerjt:scan-all-jobsvc","ref":"scan-all-jobsvc","sha":"7baee7847cd8e788d77a653226a8a68dca02bcff","user":{"login":"reasonerjt","id":2390463,"node_id":"MDQ6VXNlcjIzOTA0NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false},"repo":{"id":66886901,"node_id":"MDEwOlJlcG9zaXRvcnk2Njg4NjkwMQ==","name":"harbor","full_name":"reasonerjt/harbor","private":false,"owner":{"login":"reasonerjt","id":2390463,"node_id":"MDQ6VXNlcjIzOTA0NjM=","avatar_url":"https://avatars0.githubusercontent.com/u/2390463?v=4","gravatar_id":"","url":"https://api.github.com/users/reasonerjt","html_url":"https://github.com/reasonerjt","followers_url":"https://api.github.com/users/reasonerjt/followers","following_url":"https://api.github.com/users/reasonerjt/following{/other_user}","gists_url":"https://api.github.com/users/reasonerjt/gists{/gist_id}","starred_url":"https://api.github.com/users/reasonerjt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reasonerjt/subscriptions","organizations_url":"https://api.github.com/users/reasonerjt/orgs","repos_url":"https://api.github.com/users/reasonerjt/repos","events_url":"https://api.github.com/users/reasonerjt/events{/privacy}","received_events_url":"https://api.github.com/users/reasonerjt/received_events","type":"User","site_admin":false},"html_url":"https://github.com/reasonerjt/harbor","description":"An enterprise-class container registry server based on Docker Distribution","fork":true,"url":"https://api.github.com/repos/reasonerjt/harbor","forks_url":"https://api.github.com/repos/reasonerjt/harbor/forks","keys_url":"https://api.github.com/repos/reasonerjt/harbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/reasonerjt/harbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/reasonerjt/harbor/teams","hooks_url":"https://api.github.com/repos/reasonerjt/harbor/hooks","issue_events_url":"https://api.github.com/repos/reasonerjt/harbor/issues/events{/number}","events_url":"https://api.github.com/repos/reasonerjt/harbor/events","assignees_url":"https://api.github.com/repos/reasonerjt/harbor/assignees{/user}","branches_url":"https://api.github.com/repos/reasonerjt/harbor/branches{/branch}","tags_url":"https://api.github.com/repos/reasonerjt/harbor/tags","blobs_url":"https://api.github.com/repos/reasonerjt/harbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/reasonerjt/harbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/reasonerjt/harbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/reasonerjt/harbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/reasonerjt/harbor/statuses/{sha}","languages_url":"https://api.github.com/repos/reasonerjt/harbor/languages","stargazers_url":"https://api.github.com/repos/reasonerjt/harbor/stargazers","contributors_url":"https://api.github.com/repos/reasonerjt/harbor/contributors","subscribers_url":"https://api.github.com/repos/reasonerjt/harbor/subscribers","subscription_url":"https://api.github.com/repos/reasonerjt/harbor/subscription","commits_url":"https://api.github.com/repos/reasonerjt/harbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/reasonerjt/harbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/reasonerjt/harbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/reasonerjt/harbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/reasonerjt/harbor/contents/{+path}","compare_url":"https://api.github.com/repos/reasonerjt/harbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/reasonerjt/harbor/merges","archive_url":"https://api.github.com/repos/reasonerjt/harbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/reasonerjt/harbor/downloads","issues_url":"https://api.github.com/repos/reasonerjt/harbor/issues{/number}","pulls_url":"https://api.github.com/repos/reasonerjt/harbor/pulls{/number}","milestones_url":"https://api.github.com/repos/reasonerjt/harbor/milestones{/number}","notifications_url":"https://api.github.com/repos/reasonerjt/harbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/reasonerjt/harbor/labels{/name}","releases_url":"https://api.github.com/repos/reasonerjt/harbor/releases{/id}","deployments_url":"https://api.github.com/repos/reasonerjt/harbor/deployments","created_at":"2016-08-29T22:59:08Z","updated_at":"2018-09-10T12:43:22Z","pushed_at":"2018-09-20T16:29:03Z","git_url":"git://github.com/reasonerjt/harbor.git","ssh_url":"git@github.com:reasonerjt/harbor.git","clone_url":"https://github.com/reasonerjt/harbor.git","svn_url":"https://github.com/reasonerjt/harbor","homepage":"http://vmware.github.io/harbor/","size":107242,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"goharbor:master","ref":"master","sha":"6c84a3dc4f5783ebec43a16e01ffb71eb388a8af","user":{"login":"goharbor","id":40275816,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwMjc1ODE2","avatar_url":"https://avatars1.githubusercontent.com/u/40275816?v=4","gravatar_id":"","url":"https://api.github.com/users/goharbor","html_url":"https://github.com/goharbor","followers_url":"https://api.github.com/users/goharbor/followers","following_url":"https://api.github.com/users/goharbor/following{/other_user}","gists_url":"https://api.github.com/users/goharbor/gists{/gist_id}","starred_url":"https://api.github.com/users/goharbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goharbor/subscriptions","organizations_url":"https://api.github.com/users/goharbor/orgs","repos_url":"https://api.github.com/users/goharbor/repos","events_url":"https://api.github.com/users/goharbor/events{/privacy}","received_events_url":"https://api.github.com/users/goharbor/received_events","type":"Organization","site_admin":false},"repo":{"id":50613991,"node_id":"MDEwOlJlcG9zaXRvcnk1MDYxMzk5MQ==","name":"harbor","full_name":"goharbor/harbor","private":false,"owner":{"login":"goharbor","id":40275816,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwMjc1ODE2","avatar_url":"https://avatars1.githubusercontent.com/u/40275816?v=4","gravatar_id":"","url":"https://api.github.com/users/goharbor","html_url":"https://github.com/goharbor","followers_url":"https://api.github.com/users/goharbor/followers","following_url":"https://api.github.com/users/goharbor/following{/other_user}","gists_url":"https://api.github.com/users/goharbor/gists{/gist_id}","starred_url":"https://api.github.com/users/goharbor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goharbor/subscriptions","organizations_url":"https://api.github.com/users/goharbor/orgs","repos_url":"https://api.github.com/users/goharbor/repos","events_url":"https://api.github.com/users/goharbor/events{/privacy}","received_events_url":"https://api.github.com/users/goharbor/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/goharbor/harbor","description":"An open source trusted cloud native registry project that stores, signs, and scans content.","fork":false,"url":"https://api.github.com/repos/goharbor/harbor","forks_url":"https://api.github.com/repos/goharbor/harbor/forks","keys_url":"https://api.github.com/repos/goharbor/harbor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/goharbor/harbor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/goharbor/harbor/teams","hooks_url":"https://api.github.com/repos/goharbor/harbor/hooks","issue_events_url":"https://api.github.com/repos/goharbor/harbor/issues/events{/number}","events_url":"https://api.github.com/repos/goharbor/harbor/events","assignees_url":"https://api.github.com/repos/goharbor/harbor/assignees{/user}","branches_url":"https://api.github.com/repos/goharbor/harbor/branches{/branch}","tags_url":"https://api.github.com/repos/goharbor/harbor/tags","blobs_url":"https://api.github.com/repos/goharbor/harbor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/goharbor/harbor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/goharbor/harbor/git/refs{/sha}","trees_url":"https://api.github.com/repos/goharbor/harbor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/goharbor/harbor/statuses/{sha}","languages_url":"https://api.github.com/repos/goharbor/harbor/languages","stargazers_url":"https://api.github.com/repos/goharbor/harbor/stargazers","contributors_url":"https://api.github.com/repos/goharbor/harbor/contributors","subscribers_url":"https://api.github.com/repos/goharbor/harbor/subscribers","subscription_url":"https://api.github.com/repos/goharbor/harbor/subscription","commits_url":"https://api.github.com/repos/goharbor/harbor/commits{/sha}","git_commits_url":"https://api.github.com/repos/goharbor/harbor/git/commits{/sha}","comments_url":"https://api.github.com/repos/goharbor/harbor/comments{/number}","issue_comment_url":"https://api.github.com/repos/goharbor/harbor/issues/comments{/number}","contents_url":"https://api.github.com/repos/goharbor/harbor/contents/{+path}","compare_url":"https://api.github.com/repos/goharbor/harbor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/goharbor/harbor/merges","archive_url":"https://api.github.com/repos/goharbor/harbor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/goharbor/harbor/downloads","issues_url":"https://api.github.com/repos/goharbor/harbor/issues{/number}","pulls_url":"https://api.github.com/repos/goharbor/harbor/pulls{/number}","milestones_url":"https://api.github.com/repos/goharbor/harbor/milestones{/number}","notifications_url":"https://api.github.com/repos/goharbor/harbor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/goharbor/harbor/labels{/name}","releases_url":"https://api.github.com/repos/goharbor/harbor/releases{/id}","deployments_url":"https://api.github.com/repos/goharbor/harbor/deployments","created_at":"2016-01-28T21:10:28Z","updated_at":"2018-09-21T08:31:34Z","pushed_at":"2018-09-21T07:59:53Z","git_url":"git://github.com/goharbor/harbor.git","ssh_url":"git@github.com:goharbor/harbor.git","clone_url":"https://github.com/goharbor/harbor.git","svn_url":"https://github.com/goharbor/harbor","homepage":"https://goharbor.io/","size":107750,"stargazers_count":5412,"watchers_count":5412,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1508,"mirror_url":null,"archived":false,"open_issues_count":495,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":1508,"open_issues":495,"watchers":5412,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/5934"},"html":{"href":"https://github.com/goharbor/harbor/pull/5934"},"issue":{"href":"https://api.github.com/repos/goharbor/harbor/issues/5934"},"comments":{"href":"https://api.github.com/repos/goharbor/harbor/issues/5934/comments"},"review_comments":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/5934/comments"},"review_comment":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/goharbor/harbor/pulls/5934/commits"},"statuses":{"href":"https://api.github.com/repos/goharbor/harbor/statuses/7baee7847cd8e788d77a653226a8a68dca02bcff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"reasonerjt"}}