Skip to content

Commit e62a7aa

Browse files
authored
Implement method to check, if vulnerability alerts are enabled (#1923)
* Implement method to check, if vulnerability alerts are enabled * Revert unintended format changes * fix javadoc issue
1 parent 338de9a commit e62a7aa

File tree

7 files changed

+351
-0
lines changed

7 files changed

+351
-0
lines changed

src/main/java/org/kohsuke/github/GHRepository.java

+15
Original file line numberDiff line numberDiff line change
@@ -3685,6 +3685,21 @@ public PagedIterable<GHRepositoryRule> listRulesForBranch(String branch) throws
36853685
.toIterable(GHRepositoryRule[].class, null);
36863686
}
36873687

3688+
/**
3689+
* Check, if vulnerability alerts are enabled for this repository
3690+
* (https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#check-if-vulnerability-alerts-are-enabled-for-a-repository).
3691+
*
3692+
* @return true, if vulnerability alerts are enabled
3693+
* @throws IOException
3694+
* the io exception
3695+
*/
3696+
public boolean isVulnerabilityAlertsEnabled() throws IOException {
3697+
return root().createRequest()
3698+
.method("GET")
3699+
.withUrlPath(getApiTailUrl("/vulnerability-alerts"))
3700+
.fetchHttpStatusCode() == 204;
3701+
}
3702+
36883703
/**
36893704
* A {@link GHRepositoryBuilder} that allows multiple properties to be updated per request.
36903705
*

src/test/java/org/kohsuke/github/GHRepositoryTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,18 @@ public void testGetRulesForBranch() throws Exception {
19201920
assertThat(rule.getParameter(GHRepositoryRule.Parameters.REQUIRE_CODE_OWNER_REVIEW).get(), is(equalTo(false)));
19211921
}
19221922

1923+
/**
1924+
* Test getVulnerabilityAlerts.
1925+
*
1926+
* @throws Exception
1927+
* the exception
1928+
*/
1929+
@Test
1930+
public void testIsVulnerabilityAlertsEnabled() throws Exception {
1931+
GHRepository repository = gitHub.getRepository("ihrigb/node-doorbird");
1932+
assertThat(repository.isVulnerabilityAlertsEnabled(), is(true));
1933+
}
1934+
19231935
private void verifyEmptyResult(PagedSearchIterable<GHPullRequest> searchResult) {
19241936
assertThat(searchResult.getTotalCount(), is(0));
19251937
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"login": "ihrigb",
3+
"id": 3423161,
4+
"node_id": "MDQ6VXNlcjM0MjMxNjE=",
5+
"avatar_url": "https://avatars.githubusercontent.com/u/3423161?v=4",
6+
"gravatar_id": "",
7+
"url": "https://api.github.com/users/ihrigb",
8+
"html_url": "https://github.com/ihrigb",
9+
"followers_url": "https://api.github.com/users/ihrigb/followers",
10+
"following_url": "https://api.github.com/users/ihrigb/following{/other_user}",
11+
"gists_url": "https://api.github.com/users/ihrigb/gists{/gist_id}",
12+
"starred_url": "https://api.github.com/users/ihrigb/starred{/owner}{/repo}",
13+
"subscriptions_url": "https://api.github.com/users/ihrigb/subscriptions",
14+
"organizations_url": "https://api.github.com/users/ihrigb/orgs",
15+
"repos_url": "https://api.github.com/users/ihrigb/repos",
16+
"events_url": "https://api.github.com/users/ihrigb/events{/privacy}",
17+
"received_events_url": "https://api.github.com/users/ihrigb/received_events",
18+
"type": "User",
19+
"site_admin": false,
20+
"name": "Benjamin Ihrig",
21+
"company": "SAP SE",
22+
"blog": "",
23+
"location": "Germany",
24+
"email": null,
25+
"hireable": null,
26+
"bio": "Working at @SAP.\r\nDoing software projects for a volunteer fire brigade in free time. Smart home enthusiast. Scuba diving instructor.",
27+
"twitter_username": null,
28+
"notification_email": null,
29+
"public_repos": 27,
30+
"public_gists": 1,
31+
"followers": 5,
32+
"following": 20,
33+
"created_at": "2013-01-30T02:20:16Z",
34+
"updated_at": "2024-08-12T12:00:08Z"
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
{
2+
"id": 404133501,
3+
"node_id": "MDEwOlJlcG9zaXRvcnk0MDQxMzM1MDE=",
4+
"name": "node-doorbird",
5+
"full_name": "ihrigb/node-doorbird",
6+
"private": false,
7+
"owner": {
8+
"login": "ihrigb",
9+
"id": 3423161,
10+
"node_id": "MDQ6VXNlcjM0MjMxNjE=",
11+
"avatar_url": "https://avatars.githubusercontent.com/u/3423161?v=4",
12+
"gravatar_id": "",
13+
"url": "https://api.github.com/users/ihrigb",
14+
"html_url": "https://github.com/ihrigb",
15+
"followers_url": "https://api.github.com/users/ihrigb/followers",
16+
"following_url": "https://api.github.com/users/ihrigb/following{/other_user}",
17+
"gists_url": "https://api.github.com/users/ihrigb/gists{/gist_id}",
18+
"starred_url": "https://api.github.com/users/ihrigb/starred{/owner}{/repo}",
19+
"subscriptions_url": "https://api.github.com/users/ihrigb/subscriptions",
20+
"organizations_url": "https://api.github.com/users/ihrigb/orgs",
21+
"repos_url": "https://api.github.com/users/ihrigb/repos",
22+
"events_url": "https://api.github.com/users/ihrigb/events{/privacy}",
23+
"received_events_url": "https://api.github.com/users/ihrigb/received_events",
24+
"type": "User",
25+
"site_admin": false
26+
},
27+
"html_url": "https://github.com/ihrigb/node-doorbird",
28+
"description": "Node client library for Doorbird's HTTP API.",
29+
"fork": false,
30+
"url": "https://api.github.com/repos/ihrigb/node-doorbird",
31+
"forks_url": "https://api.github.com/repos/ihrigb/node-doorbird/forks",
32+
"keys_url": "https://api.github.com/repos/ihrigb/node-doorbird/keys{/key_id}",
33+
"collaborators_url": "https://api.github.com/repos/ihrigb/node-doorbird/collaborators{/collaborator}",
34+
"teams_url": "https://api.github.com/repos/ihrigb/node-doorbird/teams",
35+
"hooks_url": "https://api.github.com/repos/ihrigb/node-doorbird/hooks",
36+
"issue_events_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues/events{/number}",
37+
"events_url": "https://api.github.com/repos/ihrigb/node-doorbird/events",
38+
"assignees_url": "https://api.github.com/repos/ihrigb/node-doorbird/assignees{/user}",
39+
"branches_url": "https://api.github.com/repos/ihrigb/node-doorbird/branches{/branch}",
40+
"tags_url": "https://api.github.com/repos/ihrigb/node-doorbird/tags",
41+
"blobs_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/blobs{/sha}",
42+
"git_tags_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/tags{/sha}",
43+
"git_refs_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/refs{/sha}",
44+
"trees_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/trees{/sha}",
45+
"statuses_url": "https://api.github.com/repos/ihrigb/node-doorbird/statuses/{sha}",
46+
"languages_url": "https://api.github.com/repos/ihrigb/node-doorbird/languages",
47+
"stargazers_url": "https://api.github.com/repos/ihrigb/node-doorbird/stargazers",
48+
"contributors_url": "https://api.github.com/repos/ihrigb/node-doorbird/contributors",
49+
"subscribers_url": "https://api.github.com/repos/ihrigb/node-doorbird/subscribers",
50+
"subscription_url": "https://api.github.com/repos/ihrigb/node-doorbird/subscription",
51+
"commits_url": "https://api.github.com/repos/ihrigb/node-doorbird/commits{/sha}",
52+
"git_commits_url": "https://api.github.com/repos/ihrigb/node-doorbird/git/commits{/sha}",
53+
"comments_url": "https://api.github.com/repos/ihrigb/node-doorbird/comments{/number}",
54+
"issue_comment_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues/comments{/number}",
55+
"contents_url": "https://api.github.com/repos/ihrigb/node-doorbird/contents/{+path}",
56+
"compare_url": "https://api.github.com/repos/ihrigb/node-doorbird/compare/{base}...{head}",
57+
"merges_url": "https://api.github.com/repos/ihrigb/node-doorbird/merges",
58+
"archive_url": "https://api.github.com/repos/ihrigb/node-doorbird/{archive_format}{/ref}",
59+
"downloads_url": "https://api.github.com/repos/ihrigb/node-doorbird/downloads",
60+
"issues_url": "https://api.github.com/repos/ihrigb/node-doorbird/issues{/number}",
61+
"pulls_url": "https://api.github.com/repos/ihrigb/node-doorbird/pulls{/number}",
62+
"milestones_url": "https://api.github.com/repos/ihrigb/node-doorbird/milestones{/number}",
63+
"notifications_url": "https://api.github.com/repos/ihrigb/node-doorbird/notifications{?since,all,participating}",
64+
"labels_url": "https://api.github.com/repos/ihrigb/node-doorbird/labels{/name}",
65+
"releases_url": "https://api.github.com/repos/ihrigb/node-doorbird/releases{/id}",
66+
"deployments_url": "https://api.github.com/repos/ihrigb/node-doorbird/deployments",
67+
"created_at": "2021-09-07T21:58:15Z",
68+
"updated_at": "2024-07-01T18:54:00Z",
69+
"pushed_at": "2024-09-03T07:44:00Z",
70+
"git_url": "git://github.com/ihrigb/node-doorbird.git",
71+
"ssh_url": "[email protected]:ihrigb/node-doorbird.git",
72+
"clone_url": "https://github.com/ihrigb/node-doorbird.git",
73+
"svn_url": "https://github.com/ihrigb/node-doorbird",
74+
"homepage": "",
75+
"size": 1066,
76+
"stargazers_count": 4,
77+
"watchers_count": 4,
78+
"language": "TypeScript",
79+
"has_issues": true,
80+
"has_projects": false,
81+
"has_downloads": true,
82+
"has_wiki": false,
83+
"has_pages": false,
84+
"has_discussions": false,
85+
"forks_count": 2,
86+
"mirror_url": null,
87+
"archived": false,
88+
"disabled": false,
89+
"open_issues_count": 9,
90+
"license": {
91+
"key": "apache-2.0",
92+
"name": "Apache License 2.0",
93+
"spdx_id": "Apache-2.0",
94+
"url": "https://api.github.com/licenses/apache-2.0",
95+
"node_id": "MDc6TGljZW5zZTI="
96+
},
97+
"allow_forking": true,
98+
"is_template": false,
99+
"web_commit_signoff_required": false,
100+
"topics": [
101+
"client-library",
102+
"doorbell",
103+
"doorbird",
104+
"library",
105+
"smarthome"
106+
],
107+
"visibility": "public",
108+
"forks": 2,
109+
"open_issues": 9,
110+
"watchers": 4,
111+
"default_branch": "main",
112+
"permissions": {
113+
"admin": true,
114+
"maintain": true,
115+
"push": true,
116+
"triage": true,
117+
"pull": true
118+
},
119+
"temp_clone_token": "",
120+
"allow_squash_merge": true,
121+
"allow_merge_commit": true,
122+
"allow_rebase_merge": true,
123+
"allow_auto_merge": false,
124+
"delete_branch_on_merge": false,
125+
"allow_update_branch": false,
126+
"use_squash_pr_title_as_default": false,
127+
"squash_merge_commit_message": "COMMIT_MESSAGES",
128+
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
129+
"merge_commit_message": "PR_TITLE",
130+
"merge_commit_title": "MERGE_MESSAGE",
131+
"security_and_analysis": {
132+
"secret_scanning": {
133+
"status": "disabled"
134+
},
135+
"secret_scanning_push_protection": {
136+
"status": "disabled"
137+
},
138+
"dependabot_security_updates": {
139+
"status": "disabled"
140+
},
141+
"secret_scanning_non_provider_patterns": {
142+
"status": "disabled"
143+
},
144+
"secret_scanning_validity_checks": {
145+
"status": "disabled"
146+
}
147+
},
148+
"network_count": 2,
149+
"subscribers_count": 6
150+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "057181f4-19fc-497e-bc79-78485c3fbb4b",
3+
"name": "user",
4+
"request": {
5+
"url": "/user",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "1-user.json",
16+
"headers": {
17+
"Date": "Tue, 03 Sep 2024 14:40:21 GMT",
18+
"Content-Type": "application/json; charset=utf-8",
19+
"Cache-Control": "private, max-age=60, s-maxage=60",
20+
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
21+
"ETag": "W/\"feef28d57fd914d7e1936fb4ddd2616ea7a4fe2cf5be3eb97ce9b82e603eeaac\"",
22+
"Last-Modified": "Mon, 12 Aug 2024 12:00:08 GMT",
23+
"X-OAuth-Scopes": "admin:org, repo",
24+
"X-Accepted-OAuth-Scopes": "",
25+
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
26+
"X-GitHub-Media-Type": "github.v3; format=json",
27+
"x-github-api-version-selected": "2022-11-28",
28+
"X-RateLimit-Limit": "5000",
29+
"X-RateLimit-Remaining": "4995",
30+
"X-RateLimit-Reset": "1725376444",
31+
"X-RateLimit-Used": "5",
32+
"X-RateLimit-Resource": "core",
33+
"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",
34+
"Access-Control-Allow-Origin": "*",
35+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
36+
"X-Frame-Options": "deny",
37+
"X-Content-Type-Options": "nosniff",
38+
"X-XSS-Protection": "0",
39+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
40+
"Content-Security-Policy": "default-src 'none'",
41+
"Server": "github.com",
42+
"X-GitHub-Request-Id": "D968:3A978A:64638FE:6586262:66D71FD4"
43+
}
44+
},
45+
"uuid": "057181f4-19fc-497e-bc79-78485c3fbb4b",
46+
"persistent": true,
47+
"insertionIndex": 1
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"id": "d075c001-c9f2-4b76-9493-6d70164c8226",
3+
"name": "repos_ihrigb_node-doorbird",
4+
"request": {
5+
"url": "/repos/ihrigb/node-doorbird",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 200,
15+
"bodyFileName": "2-r_i_node-doorbird.json",
16+
"headers": {
17+
"Date": "Tue, 03 Sep 2024 14:40:21 GMT",
18+
"Content-Type": "application/json; charset=utf-8",
19+
"Cache-Control": "private, max-age=60, s-maxage=60",
20+
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With",
21+
"ETag": "W/\"b3bb65178f0f4bfb02d44a277db22b6ea92fa8fc50b4bd6577ca997f31474424\"",
22+
"Last-Modified": "Mon, 01 Jul 2024 18:54:00 GMT",
23+
"X-OAuth-Scopes": "admin:org, repo",
24+
"X-Accepted-OAuth-Scopes": "repo",
25+
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
26+
"X-GitHub-Media-Type": "github.v3; format=json",
27+
"x-github-api-version-selected": "2022-11-28",
28+
"X-RateLimit-Limit": "5000",
29+
"X-RateLimit-Remaining": "4993",
30+
"X-RateLimit-Reset": "1725376444",
31+
"X-RateLimit-Used": "7",
32+
"X-RateLimit-Resource": "core",
33+
"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",
34+
"Access-Control-Allow-Origin": "*",
35+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
36+
"X-Frame-Options": "deny",
37+
"X-Content-Type-Options": "nosniff",
38+
"X-XSS-Protection": "0",
39+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
40+
"Content-Security-Policy": "default-src 'none'",
41+
"Server": "github.com",
42+
"X-GitHub-Request-Id": "6888:328A84:5D538DD:5E63CD4:66D71FD5"
43+
}
44+
},
45+
"uuid": "d075c001-c9f2-4b76-9493-6d70164c8226",
46+
"persistent": true,
47+
"insertionIndex": 2
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"id": "fd134a9f-b379-4cce-9eed-4f11d181ec3b",
3+
"name": "repos_ihrigb_node-doorbird_vulnerability-alerts",
4+
"request": {
5+
"url": "/repos/ihrigb/node-doorbird/vulnerability-alerts",
6+
"method": "GET",
7+
"headers": {
8+
"Accept": {
9+
"equalTo": "application/vnd.github+json"
10+
}
11+
}
12+
},
13+
"response": {
14+
"status": 204,
15+
"headers": {
16+
"Date": "Tue, 03 Sep 2024 14:40:22 GMT",
17+
"X-OAuth-Scopes": "admin:org, repo",
18+
"X-Accepted-OAuth-Scopes": "repo",
19+
"github-authentication-token-expiration": "2024-10-03 12:42:47 UTC",
20+
"X-GitHub-Media-Type": "github.v3; format=json",
21+
"x-github-api-version-selected": "2022-11-28",
22+
"X-RateLimit-Limit": "5000",
23+
"X-RateLimit-Remaining": "4992",
24+
"X-RateLimit-Reset": "1725376444",
25+
"X-RateLimit-Used": "8",
26+
"X-RateLimit-Resource": "core",
27+
"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",
28+
"Access-Control-Allow-Origin": "*",
29+
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
30+
"X-Frame-Options": "deny",
31+
"X-Content-Type-Options": "nosniff",
32+
"X-XSS-Protection": "0",
33+
"Referrer-Policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
34+
"Content-Security-Policy": "default-src 'none'",
35+
"Vary": "Accept-Encoding, Accept, X-Requested-With",
36+
"Server": "github.com",
37+
"X-GitHub-Request-Id": "F915:364E9B:17BDCA1:17F450B:66D71FD5"
38+
}
39+
},
40+
"uuid": "fd134a9f-b379-4cce-9eed-4f11d181ec3b",
41+
"persistent": true,
42+
"insertionIndex": 3
43+
}

0 commit comments

Comments
 (0)