8000 Implement method to check, if vulnerability alerts are enabled by ihrigb · Pull Request #1923 · hub4j/github-api · GitHub
[go: up one dir, main page]

Skip to content

Implement method to check, if vulnerability alerts are enabled #1923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement method to check, if vulnerability alerts are enabled
  • Loading branch information
ihrigb committed Sep 3, 2024
commit 4e54c97fa5380e849c71859498f10366bc99fba5
24 changes: 21 additions & 3 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,12 @@ public Map<String, Long> listLanguages() throws IOException {
* @return the owner name
*/
public String getOwnerName() {
// consistency of the GitHub API is super... some serialized forms of GHRepository populate
// a full GHUser while others populate only the owner and email. This later form is super helpful
// in putting the login in owner.name not owner.login... thankfully we can easily identify this
// consistency of the GitHub API is super... some serialized forms of
// GHRepository populate
// a full GHUser while others populate only the owner and email. This later form
// is super helpful
// in putting the login in owner.name not owner.login... thankfully we can
// easily identify this
// second set because owner.login will be null
return owner.login != null ? owner.login : owner.name;
}
Expand Down Expand Up @@ -3685,6 +3688,21 @@ public PagedIterable<GHRepositoryRule> listRulesForBranch(String branch) throws
.toIterable(GHRepositoryRule[].class, null);
}

/**
* Check, if vulnerability alerts are enabled for this repository
* (https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-vulnerability-alerts-are-enabled-for-a-repository).
*
* @return true, if vulnerability alerts are enabled
* @throws IOException
* the io exception
*/
public boolean isVulnerabilityAlertsEnabled() throws IOException {
return root().createRequest()
.method("GET")
.withUrlPath(getApiTailUrl("/vulnerability-alerts"))
.fetchHttpStatusCode() == 204;
}

/**
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
*
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/org/kohsuke/github/GHRepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,17 @@ public void testGetRulesForBranch() throws Exception {
assertThat(rule.getParameter(GHRepositoryRule.Parameters.REQUIRE_CODE_OWNER_REVIEW).get(), is(equalTo(false)));
}

/**
* Test getVulnerabilityAlerts.
*
* @throws Exception
*/
@Test
public void testIsVulnerabilityAlertsEnabled() throws Exception {
GHRepository repository = gitHub.getRepository("ihrigb/node-doorbird");
assertThat(repository.isVulnerabilityAlertsEnabled(), is(true));
}

private void verifyEmptyResult(PagedSearchIterable<GHPullRequest> searchResult) {
assertThat(searchResult.getTotalCount(), is(0));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"login": "ihrigb",
"id": 3423161,
"node_id": "MDQ6VXNlcjM0MjMxNjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/3423161?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ihrigb",
"html_url": "https://github.com/ihrigb",
"followers_url": "https://api.github.com/users/ihrigb/followers",
"following_url": "https://api.github.com/users/ihrigb/following{/other_user}",
"gists_url": "https://api.github.com/users/ihrigb/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ihrigb/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ihrigb/subscriptions",
"organizations_url": "https://api.github.com/users/ihrigb/orgs",
"repos_url": "https://api.github.com/users/ihrigb/repos",
"events_url": "https://api.github.com/users/ihrigb/events{/privacy}",
"received_events_url": "https://api.github.com/users/ihrigb/received_events",
"type": "User",
"site_admin": false,
"name": "Benjamin Ihrig",
"company": "SAP SE",
"blog": "",
"location": "Germany",
"email": null,
"hireable": null,
"bio": "Working at @SAP.\r\nDoing software projects for a volunteer fire brigade in free time. Smart home enthusiast. Scuba diving instructor.",
"twitter_username": null,
"notification_email": null,
"public_repos": 27,
"public_gists": 1,
"followers": 5,
"following": 20,
"created_at": "2013-01-30T02:20:16Z",
"updated_at": "2024-08-12T12:00:08Z"
}
A93C
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
{
"id": 404133501,
"node_id": "MDEwOlJlcG9zaXRvcnk0MDQxMzM1MDE=",
"name": "node-doorbird",
"full_name": "ihrigb/node-doorbird",
"private": false,
"owner": {
"login": "ihrigb",
"id": 3423161,
"node_id": "MDQ6VXNlcjM0MjMxNjE=",
"avatar_url": "https://avatars.githubusercontent.com/u/3423161?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/ihrigb",
"html_url": "https://github.com/ihrigb",
"followers_url": "https://api.github.com/users/ihrigb/followers",
"following_url": "https://api.github.com/users/ihrigb/following{/other_user}",
"gists_url": "https://api.github.com/users/ihrigb/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ihrigb/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ihrigb/subscriptions",
"organizations_url": "https://api.github.com/users/ihrigb/orgs",
"repos_url": "https://api.github.com/users/ihrigb/repos",
"events_url": "https://api.github.com/users/ihrigb/events{/privacy}",
"received_events_url": "https://api.github.com/users/ihrigb/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/ihrigb/node-doorbird",
"description": "Node client library for Doorbird's HTTP API.",
"fork": false,
"url": "https://api.github.com/repos/ihrigb/node-doorbird",
"forks_url": "https://api.github.com/repos/ihrigb/node-doorbird/forks",
"keys_url": "https://api.github.com/repos/ihrigb/node-doorbird/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/ihrigb/node-doorbird/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/ihrigb/node-doorbird/teams",
"hooks_url": "https://api.github.com/repos/ihrigb/node-doorbird/hooks",
"issue_events_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues/events{/number}",
"events_url": "https://api.github.com/repos/ihrigb/node-doorbird/events",
"assignees_url": "https://api.github.com/repos/ihrigb/node-doorbird/assignees{/user}",
"branches_url": "https://api.github.com/repos/ihrigb/node-doorbird/branches{/branch}",
"tags_url": "https://api.github.com/repos/ihrigb/node-doorbird/tags",
"blobs_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/ihrigb/node-doorbird/statuses/{sha}",
"languages_url": "https://api.github.com/repos/ihrigb/node-doorbird/languages",
"stargazers_url": "https://api.github.com/repos/ihrigb/node-doorbird/stargazers",
"contributors_url": "https://api.github.com/repos/ihrigb/node-doorbird/contributors",
"subscribers_url": "https://api.github.com/repos/ihrigb/node-doorbird/subscribers",
"subscription_url": "https://api.github.com/repos/ihrigb/node-doorbird/subscription",
"commits_url": "https://api.github.com/repos/ihrigb/node-doorbird/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/ihrigb/node-doorbird/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/ihrigb/node-doorbird/contents/{+path}",
"compare_url": "https://api.github.com/repos/ihrigb/node-doorbird/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/ihrigb/node-doorbird/merges",
"archive_url": "https://api.github.com/repos/ihrigb/node-doorbird/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/ihrigb/node-doorbird/downloads",
"issues_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues{/number}",
"pulls_url": "https://api.github.com/repos/ihrigb/node-doorbird/pulls{/number}",
"milestones_url": "https://api.github.com/repos/ihrigb/node-doorbird/milestones{/number}",
"notifications_url": "https://api.github.com/repos/ihrigb/node-doorbird/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/ihrigb/node-doorbird/labels{/name}",
"releases_url": "https://api.github.com/repos/ihrigb/node-doorbird/releases{/id}",
"deployments_url": "https://api.github.com/repos/ihrigb/node-doorbird/deployments",
"created_at": "2021-09-07T21:58:15Z",
"updated_at": "2024-07-01T18:54:00Z",
"pushed_at": "2024-09-03T07:44:00Z",
"git_url": "git://github.com/ihrigb/node-doorbird.git",
"ssh_url": "git@github.com:ihrigb/node-doorbird.git",
"clone_url": "https://github.com/ihrigb/node-doorbird.git",
"svn_url": "https://github.com/ihrigb/node-doorbird",
"homepage": "",
"size": 1066,
"stargazers_count": 4,
"watchers_count": 4,
"language": "TypeScript",
"has_issues": true,
"has_projects": false,
"has_downloads": true,
"has_wiki": false,
"has_pages": false,
"has_discussions": false,
"forks_count": 2,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 9,
"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="
},
"allow_forking": true,
"is_template": false,
"web_commit_signoff_required": false,
"topics": [
"client-library",
"doorbell",
"doorbird",
"library",
"smarthome"
],
"visibility": "public",
"forks": 2,
"open_issues": 9,
"watchers": 4,
"default_branch": "main",
"permissions": {
"admin": true,
"maintain": true,
"push": true,
"triage": true,
"pull": true
},
"temp_clone_token": "",
"allow_squash_merge": true,
"allow_merge_commit": true,
"allow_rebase_merge": true,
"allow_auto_merge": false,
"delete_branch_on_merge": false,
"allow_update_branch": false,
"use_squash_pr_title_as_default": false,
"squash_merge_commit_message": "COMMIT_MESSAGES",
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"merge_commit_message": "PR_TITLE",
"merge_commit_title": "MERGE_MESSAGE",
"security_and_analysis": {
"secret_scanning": {
"status": "disabled"
},
"secret_scanning_push_protection": {
"status": "disabled"
},
"dependabot_security_updates": {
"status": "disabled"
},
"secret_scanning_non_provider_patterns": {
"status": "disabled"
},
"secret_scanning_validity_checks": {
"status": "disabled"
}
},
"network_count": 2,
"subscribers_count": 6
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "057181f4-19fc-497e-bc79-78485c3fbb4b",
"name": "user",
"request": {
"url": "/user",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "1-user.json",
"headers": {
"Date": "Tue, 03 Sep 2024 14:40:21 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
"ETag": "W/\"feef28d57fd914d7e1936fb4ddd2616ea7a4fe2cf5be3eb97ce9b82e603eeaac\"",
"Last-Modified": "Mon, 12 Aug 2024 12:00:08 GMT",
"X-OAuth-Scopes": "admin:org, repo",
"X-Accepted-OAuth-Scopes": "",
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4995",
"X-RateLimit-Reset": "1725376444",
"X-RateLimit-Used": "5",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "D968:3A978A:64638FE:6586262:66D71FD4"
}
},
"uuid": "057181f4-19fc-497e-bc79-78485c3fbb4b",
"persistent": true,
"insertionIndex": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"id": "d075c001-c9f2-4b76-9493-6d70164c8226",
"name": "repos_ihrigb_node-doorbird",
"request": {
"url": "/repos/ihrigb/node-doorbird",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 200,
"bodyFileName": "2-r_i_node-doorbird.json",
"headers": {
"Date": "Tue, 03 Sep 2024 14:40:21 GMT",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "private, max-age=60, s-maxage=60",
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
"ETag": "W/\"b3bb65178f0f4bfb02d44a277db22b6ea92fa8fc50b4bd6577ca997f31474424\"",
"Last-Modified": "Mon, 01 Jul 2024 18:54:00 GMT",
"X-OAuth-Scopes": "admin:org, repo",
"X-Accepted-OAuth-Scopes": "repo",
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4993",
"X-RateLimit-Reset": "1725376444",
"X-RateLimit-Used": "7",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Server": "github.com",
"X-GitHub-Request-Id": "6888:328A84:5D538DD:5E63CD4:66D71FD5"
}
},
"uuid": "d075c001-c9f2-4b76-9493-6d70164c8226",
"persistent": true,
"insertionIndex": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"id": "fd134a9f-b379-4cce-9eed-4f11d181ec3b",
"name": "repos_ihrigb_node-doorbird_vulnerability-alerts",
"request": {
"url": "/repos/ihrigb/node-doorbird/vulnerability-alerts",
"method": "GET",
"headers": {
"Accept": {
"equalTo": "application/vnd.github+json"
}
}
},
"response": {
"status": 204,
"headers": {
"Date": "Tue, 03 Sep 2024 14:40:22 GMT",
"X-OAuth-Scopes": "admin:org, repo",
"X-Accepted-OAuth-Scopes": "repo",
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
"X-GitHub-Media-Type": "github.v3; format=json",
"x-github-api-version-selected": "2022-11-28",
"X-RateLimit-Limit": "5000",
"X-RateLimit-Remaining": "4992",
"X-RateLimit-Reset": "1725376444",
"X-RateLimit-Used": "8",
"X-RateLimit-Resource": "core",
"Access-Control-Expose-Headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset",
"Access-Control-Allow-Origin": "*",
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
"X-Frame-Options": "deny",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "0",
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
"Content-Security-Policy": "default-src 'none'",
"Vary": "Accept-Encoding, Accept, X-Requested-With",
"Server": "github.com",
"X-GitHub-Request-Id": "F915:364E9B:17BDCA1:17F450B:66D71FD5"
}
},
"uuid": "fd134a9f-b379-4cce-9eed-4f11d181ec3b",
"persistent": true,
"insertionIndex": 3
}
Loading
0