From 7912ab064678e3d7bf95edff058a760eb6701f00 Mon Sep 17 00:00:00 2001 From: Akash Rindhe Date: Mon, 17 May 2021 21:20:33 +0800 Subject: [PATCH 1/9] (feat) Add data models for code scanning alert and related structures [https://github.com/hub4j/github-api/issues/1133] --- .../kohsuke/github/GHCodeScanningAlert.java | 249 ++++++++++++++++++ .../github/GHCodeScanningAlertInstance.java | 94 +++++++ .../github/GHCodeScanningAlertState.java | 5 + 3 files changed, 348 insertions(+) create mode 100644 src/main/java/org/kohsuke/github/GHCodeScanningAlert.java create mode 100644 src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java create mode 100644 src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java new file mode 100644 index 0000000000..9bd530e165 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java @@ -0,0 +1,249 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +import java.io.IOException; +import java.net.URL; +import java.util.Date; + +/** + * Code scanning alert for a repository + * + * + */ +@SuppressFBWarnings(value = { "UUF_UNUSED_FIELD" }, justification = "JSON API") +public class GHCodeScanningAlert extends GHObject { + @JsonIgnore + private GHRepository owner; + private long number; + private String html_url; + private GHCodeScanningAlertState state; + private GHUser dismissed_by; + private String dismissed_at; + private String dismissed_reason; + private Tool tool; + private Rule rule; + private GHCodeScanningAlertInstance most_recent_instance; + private String instances_url; + + GHCodeScanningAlert wrap(GHRepository owner) { + this.owner = owner; + return wrap(owner.root); + } + + GHCodeScanningAlert wrap(GitHub root) { + this.root = root; + if (owner != null) { + owner.wrap(root); + } + return this; + } + + /** + * Id/number of the alert. + * + * @return the id/number + * @see #getId() + */ + public long getNumber() { + return number; + } + + /** + * Id/number of the alert. + * + * @return the id/number + * @see #getNumber() + */ + @Override + public long getId() { + return getNumber(); + } + + /** + * State of alert + * + * @return the state + */ + public GHCodeScanningAlertState getState() { + return state; + } + + /** + * User that has dismissed the alert. Non-null when {@link #getState()} is Dismissed + * + *

+ * Note: User object returned by code scanning GitHub API does not contain all fields. Use with caution + *

+ * + * @return the user + */ + public GHUser getDismissedBy() { + return dismissed_by; + } + + /** + * Time when alert was dismissed. Non-null when {@link #getState()} is Dismissed + * + * @return the time + */ + public Date getDismissedAt() { + return GitHubClient.parseDate(dismissed_at); + } + + /** + * Reason provided for dismissing the alert. + * + * @return the reason + */ + public String getDismissedReason() { + return dismissed_reason; + } + + /** + * Code scanning tool that created this alert + * + * @return the tool + */ + public Tool getTool() { + return tool; + } + + /** + * Code scanning rule that was violated, causing the alert + * + * @return the rule + */ + public Rule getRule() { + return rule; + } + + /** + * Most recent instance of the alert + * + * @return most recent instance + */ + public GHCodeScanningAlertInstance getMostRecentInstance() { + return most_recent_instance; + } + + @Override + public URL getHtmlUrl() throws IOException { + return GitHubClient.parseURL(html_url); + } + + /** + * Code scanning rule + */ + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + static class Rule { + private String id; + private String severity; + private String description; + private String name; + private String full_description; + private String[] tags; + private String help; + + /** + * Id of rule + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Severity of rule + * + * @return the severity + */ + public String getSeverity() { + return severity; + } + + /** + * Description of rule + * + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * Name of rule + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Full description of rule + * + * @return the full description + */ + public String getFullDescription() { + return full_description; + } + + /** + * Tags associated with the rule + * + * @return the tags + */ + public String[] getTags() { + return tags; + } + + /** + * Help text for the rule + * + * @return the help text + */ + public String getHelp() { + return help; + } + } + + /** + * Code scanning tool + */ + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + static class Tool { + private String name; + private String guid; + private String version; + + /** + * Name of code scanning tool + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * GUID of code scanning tool + * + * @return the GUID + */ + public String getGuid() { + return guid; + } + + /** + * Version of code scanning tool + * + * @return the version + */ + public String getVersion() { + return version; + } + } +} diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java new file mode 100644 index 0000000000..740b446366 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java @@ -0,0 +1,94 @@ +package org.kohsuke.github; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +public class GHCodeScanningAlertInstance { + + @JsonIgnore + private GHCodeScanningAlert owner; + + private String ref; + private String analysis_key; + private String environment; + private GHCodeScanningAlertState state; + private String commit_sha; + private String[] classifications; + private Message message; + private Location location; + + public String getRef() { + return ref; + } + + public String getAnalysisKey() { + return analysis_key; + } + + public String getEnvironment() { + return environment; + } + + public GHCodeScanningAlertState getState() { + return state; + } + + public String getCommitSha() { + return commit_sha; + } + + public List getClassifications() { + return Collections.unmodifiableList(Arrays.asList(classifications)); + } + + public Message getMessage() { + return message; + } + + public Location getLocation() { + return location; + } + + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + static class Message { + + private String text; + + public String getText() { + return text; + } + } + + @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") + static class Location { + private String path; + private long start_line; + private long end_line; + private long start_column; + private long end_column; + + public String getPath() { + return path; + } + + public long getStartLine() { + return start_line; + } + + public long getEndLine() { + return end_line; + } + + public long getStartColumn() { + return start_column; + } + + public long getEndColumn() { + return end_column; + } + } +} diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java new file mode 100644 index 0000000000..2b9f2ad470 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java @@ -0,0 +1,5 @@ +package org.kohsuke.github; + +public enum GHCodeScanningAlertState { + OPEN, FIXED, DISMISSED +} From 1f999bbb3c048d37e091bacc4c0537e18e3f8858 Mon Sep 17 00:00:00 2001 From: Akash Rindhe Date: Mon, 17 May 2021 23:03:25 +0800 Subject: [PATCH 2/9] (feat) Add methods to list code scanning alerts on a repository 3 methods added - 1 with no filter, 1 with state filter and 1 with tool name filter. [https://github.com/hub4j/github-api/issues/1133] --- .../github/GHCodeScanningAlertsIterable.java | 50 +++ .../java/org/kohsuke/github/GHRepository.java | 36 ++ .../github/GHCodeScanningAlertTest.java | 66 ++++ .../__files/repos_hub4j-test-org_pixi-2.json | 332 ++++++++++++++++++ ...-test-org_pixi_code-scanning_alerts-3.json | 82 +++++ ...-test-org_pixi_code-scanning_alerts-4.json | 82 +++++ .../__files/user-1.json | 46 +++ .../mappings/repos_hub4j-test-org_pixi-2.json | 47 +++ ...-test-org_pixi_code-scanning_alerts-3.json | 47 +++ ...-test-org_pixi_code-scanning_alerts-4.json | 47 +++ .../mappings/user-1.json | 47 +++ 11 files changed, 882 insertions(+) create mode 100644 src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java create mode 100644 src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java new file mode 100644 index 0000000000..20a1933d9f --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java @@ -0,0 +1,50 @@ +package org.kohsuke.github; + +import java.net.MalformedURLException; +import java.util.Iterator; + +import javax.annotation.Nonnull; + +class GHCodeScanningAlertsIterable extends PagedIterable { + private final GHRepository owner; + private final GitHubRequest request; + private GHCodeScanningAlert[] result; + + public GHCodeScanningAlertsIterable(GHRepository owner, GitHubRequest.Builder requestBuilder) { + this.owner = owner; + try { + this.request = requestBuilder.build(); + } catch (MalformedURLException e) { + throw new GHException("Malformed URL", e); + } + } + + @Nonnull + @Override + public PagedIterator _iterator(int pageSize) { + return new PagedIterator<>( + adapt(GitHubPageIterator + .create(owner.getRoot().getClient(), GHCodeScanningAlert[].class, request, pageSize)), + null); + } + + protected Iterator adapt(final Iterator base) { + return new Iterator() { + public boolean hasNext() { + return base.hasNext(); + } + + public GHCodeScanningAlert[] next() { + GHCodeScanningAlert[] v = base.next(); + if (result == null) { + result = v; + } + + for (GHCodeScanningAlert alert : result) { + alert.wrap(owner); + } + return result; + } + }; + } +} diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index a508b17971..fa446e9b67 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -3523,6 +3523,42 @@ public GHTagObject createTag(String tag, String message, String object, String t .wrap(this); } + /** + * Lists the code scanning alerts of this repository. + * + * @return the paged iterable + */ + public PagedIterable listCodeScanningAlerts() { + return listCodeScanningAlerts(Collections.emptyMap()); + } + + /** + * Lists the code scanning alerts of this repository filtered on the alert status + * + * @param state + * alert status to filter on + * @return the paged iterable + */ + public PagedIterable listCodeScanningAlerts(GHCodeScanningAlertState state) { + return listCodeScanningAlerts(Collections.singletonMap("state", state.name().toLowerCase())); + } + + /** + * Lists the code scanning alerts of this repository filtered on the code scanning tool name + * + * @param toolName + * name of code scanning tool that creates alerts + * @return the paged iterable + */ + public PagedIterable listCodeScanningAlerts(String toolName) { + return listCodeScanningAlerts(Collections.singletonMap("tool_name", toolName)); + } + + private PagedIterable listCodeScanningAlerts(Map filters) { + return new GHCodeScanningAlertsIterable(this, + root.createRequest().withUrlPath(getApiTailUrl("code-scanning/alerts")).with(filters)); + } + /** * Streams a zip archive of the repository, optionally at a given ref. * diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java new file mode 100644 index 0000000000..112d3d6849 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java @@ -0,0 +1,66 @@ +package org.kohsuke.github; + +import org.junit.Before; +import org.junit.Test; + +import java.util.List; + +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; + +/** + *

+ * Note : As the code scanning alerts cannot be tailored as part of test setup, lot of the test cases are dependent on + * manual setup of the mock repo. Assertions and verifications will often simply check that the values are non-null + * rather than depending on hard-coded values, to prevent making the tests flimsy + *

+ */ +public class GHCodeScanningAlertTest extends AbstractGitHubWireMockTest { + private static final String REPO_NAME = "Pixi"; + private GHRepository repo; + + @Before + public void setUp() throws Exception { + repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); + } + + @Test + public void testListCodeScanningAlerts() { + // Arrange + + // Act - Search by filtering on code scanning tool + List codeQlAlerts = repo.listCodeScanningAlerts("CodeQL")._iterator(2).nextPage(); + + // Assert + assertThat(codeQlAlerts.size(), equalTo(2)); // This assertion is based on manual setup done on repo to + // guarantee there are atleast 2 issues + + GHCodeScanningAlert alert = codeQlAlerts.get(0); + + // Verify the code scanning tool details + assertThat(alert.getTool(), not((Object) null)); + GHCodeScanningAlert.Tool tool = alert.getTool(); + assertThat(tool.getName(), is("CodeQL")); + assertThat(tool.getVersion(), not((Object) null)); + + // Verify the generic values of the code scanning rule + assertThat(alert.getRule(), not((Object) null)); + GHCodeScanningAlert.Rule rule = alert.getRule(); + assertThat(rule.getId(), not((Object) null)); + assertThat(rule.getName(), not((Object) null)); + assertThat(rule.getSeverity(), not((Object) null)); + + // Act - Search by filtering on alert status + List openAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.OPEN) + ._iterator(2) + .nextPage(); // This assertion is based on manual setup done on repo to + // guarantee there are atleast 2 issues + + // Assert + assertThat(openAlerts.size(), equalTo(2)); + GHCodeScanningAlert openAlert = openAlerts.get(0); + assertThat(openAlert.getState(), is(GHCodeScanningAlertState.OPEN)); + } + +} diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..ca64db2873 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,332 @@ +{ + "id": 368222117, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjgyMjIxMTc=", + "name": "Pixi", + "full_name": "hub4j-test-org/Pixi", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/Pixi", + "description": "Used for running code scanning test cases", + "fork": true, + "url": "https://api.github.com/repos/hub4j-test-org/Pixi", + "forks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/Pixi/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/Pixi/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/Pixi/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/deployments", + "created_at": "2021-05-17T14:48:31Z", + "updated_at": "2021-05-17T14:50:01Z", + "pushed_at": "2021-05-17T14:49:58Z", + "git_url": "git://github.com/hub4j-test-org/Pixi.git", + "ssh_url": "git@github.com:hub4j-test-org/Pixi.git", + "clone_url": "https://github.com/hub4j-test-org/Pixi.git", + "svn_url": "https://github.com/hub4j-test-org/Pixi", + "homepage": "", + "size": 19772, + "stargazers_count": 0, + "watchers_count": 0, + "language": "JavaScript", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": 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", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "source": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "network_count": 39, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..93b427d349 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,82 @@ +[ + { + "number": 111, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/111", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/111", + "state": "open", + "dismissed_by": null, + "dismissed_at": null, + "dismissed_reason": null, + "rule": { + "id": "js/unsafe-jquery-plugin", + "severity": "warning", + "description": "Unsafe jQuery plugin", + "name": "js/unsafe-jquery-plugin" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "open", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Potential XSS vulnerability in the '$.fn.tooltip' plugin." + }, + "location": { + "path": "app/public/js/bootstrap.js", + "start_line": 3090, + "end_line": 3090, + "start_column": 27, + "end_column": 34 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/111/instances" + }, + { + "number": 110, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/110", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/110", + "state": "open", + "dismissed_by": null, + "dismissed_at": null, + "dismissed_reason": null, + "rule": { + "id": "js/unsafe-jquery-plugin", + "severity": "warning", + "description": "Unsafe jQuery plugin", + "name": "js/unsafe-jquery-plugin" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "open", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Potential XSS vulnerability in the '$.fn.tooltip' plugin." + }, + "location": { + "path": "app/public/js/bootstrap.js", + "start_line": 3086, + "end_line": 3086, + "start_column": 18, + "end_column": 25 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/110/instances" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json new file mode 100644 index 0000000000..93b427d349 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json @@ -0,0 +1,82 @@ +[ + { + "number": 111, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/111", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/111", + "state": "open", + "dismissed_by": null, + "dismissed_at": null, + "dismissed_reason": null, + "rule": { + "id": "js/unsafe-jquery-plugin", + "severity": "warning", + "description": "Unsafe jQuery plugin", + "name": "js/unsafe-jquery-plugin" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "open", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Potential XSS vulnerability in the '$.fn.tooltip' plugin." + }, + "location": { + "path": "app/public/js/bootstrap.js", + "start_line": 3090, + "end_line": 3090, + "start_column": 27, + "end_column": 34 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/111/instances" + }, + { + "number": 110, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/110", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/110", + "state": "open", + "dismissed_by": null, + "dismissed_at": null, + "dismissed_reason": null, + "rule": { + "id": "js/unsafe-jquery-plugin", + "severity": "warning", + "description": "Unsafe jQuery plugin", + "name": "js/unsafe-jquery-plugin" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "open", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Potential XSS vulnerability in the '$.fn.tooltip' plugin." + }, + "location": { + "path": "app/public/js/bootstrap.js", + "start_line": 3086, + "end_line": 3086, + "start_column": 18, + "end_column": 25 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/110/instances" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/user-1.json new file mode 100644 index 0000000000..039ef9bf05 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false, + "name": "Akash Rindhe", + "company": null, + "blog": "", + "location": "Singapore", + "email": null, + "hireable": null, + "bio": null, + "twitter_username": null, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 6, + "created_at": "2015-09-03T18:07:43Z", + "updated_at": "2021-05-18T02:04:49Z", + "private_gists": 0, + "total_private_repos": 4, + "owned_private_repos": 4, + "disk_usage": 25766, + "collaborators": 1, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..3d6ed9491a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,47 @@ +{ + "id": "9c8052bf-a6fd-45e8-b65e-c54d7075edc0", + "name": "repos_hub4j-test-org_pixi", + "request": { + "url": "/repos/hub4j-test-org/Pixi", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:28:48 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/\"798dc78bb4c7a5f7af29dd24986abff44807dbd0601e8a2e0b5768a9e86d236f\"", + "Last-Modified": "Mon, 17 May 2021 14:50:01 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4991", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "9", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "816A:2EE1:BD42CD:CF77D9:60A51290" + } + }, + "uuid": "9c8052bf-a6fd-45e8-b65e-c54d7075edc0", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..d7a775c4c9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,47 @@ +{ + "id": "b0af49bf-af63-425a-83b5-2a65bc77e87e", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts?tool_name=CodeQL&per_page=2", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:28:49 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/\"eaffae955592b9800adbebbf37928d028724ebd57307d9afd767cd9f9df7fb7e\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4990", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "10", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "816A:2EE1:BD4320:CF7838:60A51290", + "Link": "; rel=\"next\", ; rel=\"last\"" + } + }, + "uuid": "b0af49bf-af63-425a-83b5-2a65bc77e87e", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json new file mode 100644 index 0000000000..fd76711943 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json @@ -0,0 +1,47 @@ +{ + "id": "ea33cf87-3a85-41ac-8285-c2eb29db4460", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts?state=open&per_page=2", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts-4.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:28:49 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/\"eaffae955592b9800adbebbf37928d028724ebd57307d9afd767cd9f9df7fb7e\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4989", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "11", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "816A:2EE1:BD4339:CF784E:60A51291", + "Link": "; rel=\"next\", ; rel=\"last\"" + } + }, + "uuid": "ea33cf87-3a85-41ac-8285-c2eb29db4460", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json new file mode 100644 index 0000000000..052e6c4692 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json @@ -0,0 +1,47 @@ +{ + "id": "b9847f47-a1dd-4ab1-bac4-77dbd80c47cc", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:28:47 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/\"b3db1d8dfd0cef27934c732c74e2d774a7869d6c1b525a4b22e050220ee9aa33\"", + "Last-Modified": "Tue, 18 May 2021 02:04:49 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4993", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "7", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "816A:2EE1:BD4230:CF7737:60A5128E" + } + }, + "uuid": "b9847f47-a1dd-4ab1-bac4-77dbd80c47cc", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From f9eff5abe2b07c459514b5952ba82f96d968af9e Mon Sep 17 00:00:00 2001 From: Akash Rindhe Date: Mon, 17 May 2021 23:18:57 +0800 Subject: [PATCH 3/9] (feat) Add function to search code scanning alert by id [https://github.com/hub4j/github-api/issues/1133] --- .../java/org/kohsuke/github/GHRepository.java | 16 + .../github/GHCodeScanningAlertTest.java | 26 +- .../__files/repos_hub4j-test-org_pixi-2.json | 332 ++++++++++++++++++ ...-test-org_pixi_code-scanning_alerts-3.json | 61 ++++ ...est-org_pixi_code-scanning_alerts_1-4.json | 86 +++++ .../__files/user-1.json | 46 +++ .../mappings/repos_hub4j-test-org_pixi-2.json | 47 +++ ...-test-org_pixi_code-scanning_alerts-3.json | 46 +++ ...est-org_pixi_code-scanning_alerts_1-4.json | 46 +++ .../mappings/user-1.json | 47 +++ 10 files changed, 752 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index fa446e9b67..ce984aec4f 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -3559,6 +3559,22 @@ private PagedIterable listCodeScanningAlerts(Mapref. * diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java index 112d3d6849..709d546876 100644 --- a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java @@ -1,11 +1,14 @@ package org.kohsuke.github; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; +import java.io.IOException; import java.util.List; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; @@ -44,7 +47,7 @@ public void testListCodeScanningAlerts() { assertThat(tool.getName(), is("CodeQL")); assertThat(tool.getVersion(), not((Object) null)); - // Verify the generic values of the code scanning rule + // Verify that fields of the code scanning rule are non-null assertThat(alert.getRule(), not((Object) null)); GHCodeScanningAlert.Rule rule = alert.getRule(); assertThat(rule.getId(), not((Object) null)); @@ -63,4 +66,25 @@ public void testListCodeScanningAlerts() { assertThat(openAlert.getState(), is(GHCodeScanningAlertState.OPEN)); } + @Test + public void testGetCodeScanningAlert() throws IOException { + // Arrange + List dismissedAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.DISMISSED) + ._iterator(1) + .nextPage(); + Assume.assumeThat(dismissedAlerts.size(), greaterThanOrEqualTo(1)); + GHCodeScanningAlert dismissedAlert = dismissedAlerts.get(0); + long idOfDismissed = dismissedAlert.getId(); + + // Act + GHCodeScanningAlert result = repo.getCodeScanningAlert(idOfDismissed); + + // Assert + assertThat(result, not((Object) null)); + assertThat(result.getId(), equalTo(idOfDismissed)); + assertThat(result.getDismissedReason(), equalTo(dismissedAlert.getDismissedReason())); + assertThat(result.getDismissedAt(), equalTo(dismissedAlert.getDismissedAt())); + assertThat(result.getDismissedBy().login, equalTo(dismissedAlert.getDismissedBy().login)); + } + } diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..ca64db2873 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,332 @@ +{ + "id": 368222117, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjgyMjIxMTc=", + "name": "Pixi", + "full_name": "hub4j-test-org/Pixi", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/Pixi", + "description": "Used for running code scanning test cases", + "fork": true, + "url": "https://api.github.com/repos/hub4j-test-org/Pixi", + "forks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/Pixi/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/Pixi/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/Pixi/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/deployments", + "created_at": "2021-05-17T14:48:31Z", + "updated_at": "2021-05-17T14:50:01Z", + "pushed_at": "2021-05-17T14:49:58Z", + "git_url": "git://github.com/hub4j-test-org/Pixi.git", + "ssh_url": "git@github.com:hub4j-test-org/Pixi.git", + "clone_url": "https://github.com/hub4j-test-org/Pixi.git", + "svn_url": "https://github.com/hub4j-test-org/Pixi", + "homepage": "", + "size": 19772, + "stargazers_count": 0, + "watchers_count": 0, + "language": "JavaScript", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": 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", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "source": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "network_count": 39, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..eb7e54671c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,61 @@ +[ + { + "number": 1, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/1", + "state": "dismissed", + "dismissed_by": { + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false + }, + "dismissed_at": "2021-05-18T01:45:16Z", + "dismissed_reason": "used in tests", + "rule": { + "id": "js/angular/disabling-sce", + "severity": "warning", + "description": "Disabling SCE", + "name": "js/angular/disabling-sce" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "dismissed", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Disabling SCE is strongly discouraged." + }, + "location": { + "path": "app/pixi.html", + "start_line": 179, + "end_line": 179, + "start_column": 4, + "end_column": 31 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1/instances" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json new file mode 100644 index 0000000000..4fcfe3a0aa --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json @@ -0,0 +1,86 @@ +{ + "number": 1, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/1", + "state": "dismissed", + "dismissed_by": { + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false + }, + "dismissed_at": "2021-05-18T01:45:16Z", + "dismissed_reason": "used in tests", + "rule": { + "id": "js/angular/disabling-sce", + "severity": "warning", + "description": "Disabling SCE", + "name": "js/angular/disabling-sce", + "full_description": "Disabling strict contextual escaping (SCE) can cause security vulnerabilities.", + "tags": [ + "frameworks/angularjs", + "maintainability", + "security" + ], + "help": "# Disabling SCE\nAngularJS is secure by default through automated sanitization and filtering of untrusted values that could cause vulnerabilities such as XSS. Strict Contextual Escaping (SCE) is an execution mode in AngularJS that provides this security mechanism.\n\nDisabling SCE in an AngularJS application is strongly discouraged. It is even more discouraged to disable SCE in a library, since it is an application-wide setting.\n\n\n## Recommendation\nDo not disable SCE.\n\n\n## Example\nThe following example shows an AngularJS application that disables SCE in order to dynamically construct an HTML fragment, which is later inserted into the DOM through `$scope.html`.\n\n\n```javascript\nangular.module('app', [])\n .config(function($sceProvider) {\n $sceProvider.enabled(false); // BAD\n }).controller('controller', function($scope) {\n // ...\n $scope.html = '
  • ' + item.toString() + '
';\n });\n\n```\nThis is problematic, since it disables SCE for the entire AngularJS application.\n\nInstead, just mark the dynamically constructed HTML fragment as safe using `$sce.trustAsHtml`, before assigning it to `$scope.html`:\n\n\n```javascript\nangular.module('app', [])\n .controller('controller', function($scope, $sce) {\n // ...\n // GOOD (but should use the templating system instead)\n $scope.html = $sce.trustAsHtml('
  • ' + item.toString() + '
'); \n });\n\n```\nPlease note that this example is for illustrative purposes only; use the AngularJS templating system to dynamically construct HTML when possible.\n\n\n## References\n* AngularJS Developer Guide: [Strict Contextual Escaping](https://docs.angularjs.org/api/ng/service/$sce)\n* AngularJS Developer Guide: [Can I disable SCE completely?](https://docs.angularjs.org/api/ng/service/$sce#can-i-disable-sce-completely-).\n" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "dismissed", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Disabling SCE is strongly discouraged." + }, + "location": { + "path": "app/pixi.html", + "start_line": 179, + "end_line": 179, + "start_column": 4, + "end_column": 31 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1/instances", + "instances": [ + { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "dismissed", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Disabling SCE is strongly discouraged." + }, + "location": { + "path": "app/pixi.html", + "start_line": 179, + "end_line": 179, + "start_column": 4, + "end_column": 31 + }, + "classifications": [] + } + ] +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/user-1.json new file mode 100644 index 0000000000..5dc3a6b70b --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false, + "name": "Akash Rindhe", + "company": null, + "blog": "", + "location": "Singapore", + "email": null, + "hireable": null, + "bio": null, + "twitter_username": null, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 6, + "created_at": "2015-09-03T18:07:43Z", + "updated_at": "2021-05-17T14:48:09Z", + "private_gists": 0, + "total_private_repos": 4, + "owned_private_repos": 4, + "disk_usage": 24553, + "collaborators": 1, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..55ff3cc82e --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,47 @@ +{ + "id": "eaf33f02-185f-4be9-a97b-924271e6e7c5", + "name": "repos_hub4j-test-org_pixi", + "request": { + "url": "/repos/hub4j-test-org/Pixi", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 18 May 2021 01:47:57 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/\"798dc78bb4c7a5f7af29dd24986abff44807dbd0601e8a2e0b5768a9e86d236f\"", + "Last-Modified": "Mon, 17 May 2021 14:50:01 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4989", + "X-RateLimit-Reset": "1621305488", + "X-RateLimit-Used": "11", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "C5B4:3979:DD47:15200:60A31CCC" + } + }, + "uuid": "eaf33f02-185f-4be9-a97b-924271e6e7c5", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..5b8fed5a77 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,46 @@ +{ + "id": "60d5109b-44b1-4891-94f2-10cb944b54a8", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts?state=dismissed&per_page=1", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 18 May 2021 01:47:57 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/\"9a1d2adc0632ce1ed356060f568dde4d49ff9bb466dbd8dd178c2d7f2deb168a\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4988", + "X-RateLimit-Reset": "1621305488", + "X-RateLimit-Used": "12", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "C5B4:3979:DD51:1520E:60A31CCD" + } + }, + "uuid": "60d5109b-44b1-4891-94f2-10cb944b54a8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json new file mode 100644 index 0000000000..1bf9bdf4a3 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json @@ -0,0 +1,46 @@ +{ + "id": "4f2360f2-1657-4c11-815a-9ec1cd813ff2", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts_1", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts/1", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 18 May 2021 01:47:58 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/\"14c49b996528874d4e190e109c9ece7d5a6c8b43fb2a91f816c65bdf1a5532b5\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4987", + "X-RateLimit-Reset": "1621305488", + "X-RateLimit-Used": "13", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "C5B4:3979:DD58:15215:60A31CCD" + } + }, + "uuid": "4f2360f2-1657-4c11-815a-9ec1cd813ff2", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json new file mode 100644 index 0000000000..3227dd2fc9 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json @@ -0,0 +1,47 @@ +{ + "id": "d4353d07-0834-491b-8748-1572b1f98ccf", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Tue, 18 May 2021 01:47:55 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/\"b4c807fe770ee29631ba93ab998f014ce7ad3cefa967fb0ad843c2a9bf18b97a\"", + "Last-Modified": "Mon, 17 May 2021 14:48:09 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4991", + "X-RateLimit-Reset": "1621305488", + "X-RateLimit-Used": "9", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "C5B4:3979:DD3B:151F0:60A31CCB" + } + }, + "uuid": "d4353d07-0834-491b-8748-1572b1f98ccf", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From be778cdb5a033b33a5a10a9393114d307d372295 Mon Sep 17 00:00:00 2001 From: Akash Rindhe Date: Wed, 19 May 2021 21:26:51 +0800 Subject: [PATCH 4/9] (feat) Add method to list instances of code scanning alert [https://github.com/hub4j/github-api/issues/1133] --- .../kohsuke/github/GHCodeScanningAlert.java | 9 + .../github/GHCodeScanningAlertInstance.java | 6 - .../GHCodeScanningAlertInstancesIterable.java | 46 +++ .../GHCodeScanningAlertInstanceTest.java | 65 ++++ .../__files/repos_hub4j-test-org_pixi-2.json | 332 ++++++++++++++++++ ...-test-org_pixi_code-scanning_alerts-3.json | 61 ++++ ...xi_code-scanning_alerts_1_instances-4.json | 20 ++ .../__files/user-1.json | 46 +++ .../mappings/repos_hub4j-test-org_pixi-2.json | 47 +++ ...-test-org_pixi_code-scanning_alerts-3.json | 46 +++ ...xi_code-scanning_alerts_1_instances-4.json | 46 +++ .../mappings/user-1.json | 47 +++ 12 files changed, 765 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java create mode 100644 src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/user-1.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json create mode 100644 src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java index 9bd530e165..8e21e46c57 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java @@ -128,6 +128,15 @@ public GHCodeScanningAlertInstance getMostRecentInstance() { return most_recent_instance; } + /** + * List all instances of the alert + * + * @return the paged iterable + */ + public PagedIterable listAlertInstances() { + return new GHCodeScanningAlertInstancesIterable(this, root.createRequest().withUrlPath(instances_url)); + } + @Override public URL getHtmlUrl() throws IOException { return GitHubClient.parseURL(html_url); diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java index 740b446366..1c213ab805 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import com.fasterxml.jackson.annotation.JsonIgnore; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.util.Arrays; @@ -8,10 +7,6 @@ import java.util.List; public class GHCodeScanningAlertInstance { - - @JsonIgnore - private GHCodeScanningAlert owner; - private String ref; private String analysis_key; private String environment; @@ -55,7 +50,6 @@ public Location getLocation() { @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") static class Message { - private String text; public String getText() { diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java new file mode 100644 index 0000000000..0ce4f1116b --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java @@ -0,0 +1,46 @@ +package org.kohsuke.github; + +import java.net.MalformedURLException; +import java.util.Iterator; + +import javax.annotation.Nonnull; + +public class GHCodeScanningAlertInstancesIterable extends PagedIterable { + private final GHCodeScanningAlert owner; + private final GitHubRequest request; + private GHCodeScanningAlertInstance[] result; + + public GHCodeScanningAlertInstancesIterable(GHCodeScanningAlert owner, GitHubRequest.Builder requestBuilder) { + this.owner = owner; + try { + this.request = requestBuilder.build(); + } catch (MalformedURLException e) { + throw new GHException("Malformed URL", e); + } + } + + @Nonnull + @Override + public PagedIterator _iterator(int pageSize) { + return new PagedIterator<>( + adapt(GitHubPageIterator + .create(owner.getRoot().getClient(), GHCodeScanningAlertInstance[].class, request, pageSize)), + null); + } + + protected Iterator adapt(final Iterator base) { + return new Iterator() { + public boolean hasNext() { + return base.hasNext(); + } + + public GHCodeScanningAlertInstance[] next() { + GHCodeScanningAlertInstance[] v = base.next(); + if (result == null) { + result = v; + } + return result; + } + }; + } +} diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java new file mode 100644 index 0000000000..c80953eb01 --- /dev/null +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java @@ -0,0 +1,65 @@ +package org.kohsuke.github; + +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.util.List; + +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.not; + +/** + *

+ * Note : As the code scanning alerts cannot be tailored as part of test setup, lot of the test cases are dependent on + * manual setup of the mock repo. Assertions and verifications will often simply check that the values are non-null + * rather than depending on hard-coded values, to prevent making the tests flimsy + *

+ */ +public class GHCodeScanningAlertInstanceTest extends AbstractGitHubWireMockTest { + private static final String REPO_NAME = "Pixi"; + private GHCodeScanningAlert alert; + + @Before + public void setUp() throws Exception { + GHRepository repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); + alert = getAlertFromRepo(repo); + } + + private GHCodeScanningAlert getAlertFromRepo(GHRepository repo) { + List dismissedAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.DISMISSED) + ._iterator(1) + .nextPage(); + Assume.assumeThat(dismissedAlerts.size(), greaterThanOrEqualTo(1)); + return dismissedAlerts.get(0); + } + + @Test + public void testListAlertInstances() throws IOException { + // Arrange + + // Act + List results = alert.listAlertInstances().toList(); + + // Assert + assertThat(results.size(), greaterThanOrEqualTo(1)); + GHCodeScanningAlertInstance instance = results.get(0); + // Can't assert on exact values with having to hardcode values from + // json file, hence making the assertions generics + assertThat(instance.getRef(), not((Object) null)); + assertThat(instance.getCommitSha(), not((Object) null)); + assertThat(instance.getState(), not((Object) null)); + assertThat(instance.getMessage(), not((Object) null)); + assertThat(instance.getLocation(), not((Object) null)); + + GHCodeScanningAlertInstance.Location location = instance.getLocation(); + // Can't assert on exact values with having to hardcode values from + // json file, hence making the assertions generics + assertThat(location.getPath(), not((Object) null)); + assertThat(location.getStartLine(), greaterThanOrEqualTo(0L)); + assertThat(location.getEndLine(), greaterThanOrEqualTo(0L)); + assertThat(location.getStartColumn(), greaterThanOrEqualTo(0L)); + assertThat(location.getStartColumn(), greaterThanOrEqualTo(0L)); + } +} diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..ca64db2873 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,332 @@ +{ + "id": 368222117, + "node_id": "MDEwOlJlcG9zaXRvcnkzNjgyMjIxMTc=", + "name": "Pixi", + "full_name": "hub4j-test-org/Pixi", + "private": false, + "owner": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/hub4j-test-org/Pixi", + "description": "Used for running code scanning test cases", + "fork": true, + "url": "https://api.github.com/repos/hub4j-test-org/Pixi", + "forks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/forks", + "keys_url": "https://api.github.com/repos/hub4j-test-org/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/hub4j-test-org/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/hub4j-test-org/Pixi/teams", + "hooks_url": "https://api.github.com/repos/hub4j-test-org/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/hub4j-test-org/Pixi/events", + "assignees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/hub4j-test-org/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/tags", + "blobs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/hub4j-test-org/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/hub4j-test-org/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/hub4j-test-org/Pixi/subscription", + "commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/hub4j-test-org/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/hub4j-test-org/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/hub4j-test-org/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/hub4j-test-org/Pixi/merges", + "archive_url": "https://api.github.com/repos/hub4j-test-org/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/hub4j-test-org/Pixi/downloads", + "issues_url": "https://api.github.com/repos/hub4j-test-org/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/hub4j-test-org/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/hub4j-test-org/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/hub4j-test-org/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/hub4j-test-org/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/hub4j-test-org/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/hub4j-test-org/Pixi/deployments", + "created_at": "2021-05-17T14:48:31Z", + "updated_at": "2021-05-17T14:50:01Z", + "pushed_at": "2021-05-17T14:49:58Z", + "git_url": "git://github.com/hub4j-test-org/Pixi.git", + "ssh_url": "git@github.com:hub4j-test-org/Pixi.git", + "clone_url": "https://github.com/hub4j-test-org/Pixi.git", + "svn_url": "https://github.com/hub4j-test-org/Pixi", + "homepage": "", + "size": 19772, + "stargazers_count": 0, + "watchers_count": 0, + "language": "JavaScript", + "has_issues": false, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 0, + "mirror_url": null, + "archived": false, + "disabled": 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", + "permissions": { + "admin": true, + "push": true, + "pull": true + }, + "temp_clone_token": "", + "allow_squash_merge": true, + "allow_merge_commit": true, + "allow_rebase_merge": true, + "delete_branch_on_merge": false, + "organization": { + "login": "hub4j-test-org", + "id": 7544739, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjc1NDQ3Mzk=", + "avatar_url": "https://avatars.githubusercontent.com/u/7544739?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hub4j-test-org", + "html_url": "https://github.com/hub4j-test-org", + "followers_url": "https://api.github.com/users/hub4j-test-org/followers", + "following_url": "https://api.github.com/users/hub4j-test-org/following{/other_user}", + "gists_url": "https://api.github.com/users/hub4j-test-org/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hub4j-test-org/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hub4j-test-org/subscriptions", + "organizations_url": "https://api.github.com/users/hub4j-test-org/orgs", + "repos_url": "https://api.github.com/users/hub4j-test-org/repos", + "events_url": "https://api.github.com/users/hub4j-test-org/events{/privacy}", + "received_events_url": "https://api.github.com/users/hub4j-test-org/received_events", + "type": "Organization", + "site_admin": false + }, + "parent": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "source": { + "id": 131328028, + "node_id": "MDEwOlJlcG9zaXRvcnkxMzEzMjgwMjg=", + "name": "Pixi", + "full_name": "DevSlop/Pixi", + "private": false, + "owner": { + "login": "DevSlop", + "id": 38781597, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM4NzgxNTk3", + "avatar_url": "https://avatars.githubusercontent.com/u/38781597?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/DevSlop", + "html_url": "https://github.com/DevSlop", + "followers_url": "https://api.github.com/users/DevSlop/followers", + "following_url": "https://api.github.com/users/DevSlop/following{/other_user}", + "gists_url": "https://api.github.com/users/DevSlop/gists{/gist_id}", + "starred_url": "https://api.github.com/users/DevSlop/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/DevSlop/subscriptions", + "organizations_url": "https://api.github.com/users/DevSlop/orgs", + "repos_url": "https://api.github.com/users/DevSlop/repos", + "events_url": "https://api.github.com/users/DevSlop/events{/privacy}", + "received_events_url": "https://api.github.com/users/DevSlop/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/DevSlop/Pixi", + "description": "The Pixi module is a MEAN Stack web app with wildly insecure APIs!", + "fork": false, + "url": "https://api.github.com/repos/DevSlop/Pixi", + "forks_url": "https://api.github.com/repos/DevSlop/Pixi/forks", + "keys_url": "https://api.github.com/repos/DevSlop/Pixi/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/DevSlop/Pixi/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/DevSlop/Pixi/teams", + "hooks_url": "https://api.github.com/repos/DevSlop/Pixi/hooks", + "issue_events_url": "https://api.github.com/repos/DevSlop/Pixi/issues/events{/number}", + "events_url": "https://api.github.com/repos/DevSlop/Pixi/events", + "assignees_url": "https://api.github.com/repos/DevSlop/Pixi/assignees{/user}", + "branches_url": "https://api.github.com/repos/DevSlop/Pixi/branches{/branch}", + "tags_url": "https://api.github.com/repos/DevSlop/Pixi/tags", + "blobs_url": "https://api.github.com/repos/DevSlop/Pixi/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/DevSlop/Pixi/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/DevSlop/Pixi/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/DevSlop/Pixi/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/DevSlop/Pixi/statuses/{sha}", + "languages_url": "https://api.github.com/repos/DevSlop/Pixi/languages", + "stargazers_url": "https://api.github.com/repos/DevSlop/Pixi/stargazers", + "contributors_url": "https://api.github.com/repos/DevSlop/Pixi/contributors", + "subscribers_url": "https://api.github.com/repos/DevSlop/Pixi/subscribers", + "subscription_url": "https://api.github.com/repos/DevSlop/Pixi/subscription", + "commits_url": "https://api.github.com/repos/DevSlop/Pixi/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/DevSlop/Pixi/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/DevSlop/Pixi/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/DevSlop/Pixi/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/DevSlop/Pixi/contents/{+path}", + "compare_url": "https://api.github.com/repos/DevSlop/Pixi/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/DevSlop/Pixi/merges", + "archive_url": "https://api.github.com/repos/DevSlop/Pixi/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/DevSlop/Pixi/downloads", + "issues_url": "https://api.github.com/repos/DevSlop/Pixi/issues{/number}", + "pulls_url": "https://api.github.com/repos/DevSlop/Pixi/pulls{/number}", + "milestones_url": "https://api.github.com/repos/DevSlop/Pixi/milestones{/number}", + "notifications_url": "https://api.github.com/repos/DevSlop/Pixi/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/DevSlop/Pixi/labels{/name}", + "releases_url": "https://api.github.com/repos/DevSlop/Pixi/releases{/id}", + "deployments_url": "https://api.github.com/repos/DevSlop/Pixi/deployments", + "created_at": "2018-04-27T17:49:11Z", + "updated_at": "2021-04-28T12:48:18Z", + "pushed_at": "2020-09-04T10:17:22Z", + "git_url": "git://github.com/DevSlop/Pixi.git", + "ssh_url": "git@github.com:DevSlop/Pixi.git", + "clone_url": "https://github.com/DevSlop/Pixi.git", + "svn_url": "https://github.com/DevSlop/Pixi", + "homepage": null, + "size": 19776, + "stargazers_count": 43, + "watchers_count": 43, + "language": "JavaScript", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 39, + "mirror_url": null, + "archived": false, + "disabled": false, + "open_issues_count": 25, + "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": 39, + "open_issues": 25, + "watchers": 43, + "default_branch": "master" + }, + "network_count": 39, + "subscribers_count": 0 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..eb7e54671c --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,61 @@ +[ + { + "number": 1, + "created_at": "2021-05-17T14:55:01Z", + "url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1", + "html_url": "https://github.com/hub4j-test-org/Pixi/security/code-scanning/1", + "state": "dismissed", + "dismissed_by": { + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false + }, + "dismissed_at": "2021-05-18T01:45:16Z", + "dismissed_reason": "used in tests", + "rule": { + "id": "js/angular/disabling-sce", + "severity": "warning", + "description": "Disabling SCE", + "name": "js/angular/disabling-sce" + }, + "tool": { + "name": "CodeQL", + "guid": null, + "version": "2.5.4" + }, + "most_recent_instance": { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "dismissed", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Disabling SCE is strongly discouraged." + }, + "location": { + "path": "app/pixi.html", + "start_line": 179, + "end_line": 179, + "start_column": 4, + "end_column": 31 + }, + "classifications": [] + }, + "instances_url": "https://api.github.com/repos/hub4j-test-org/Pixi/code-scanning/alerts/1/instances" + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json new file mode 100644 index 0000000000..8f4e6965c7 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json @@ -0,0 +1,20 @@ +[ + { + "ref": "refs/heads/master", + "analysis_key": ".github/workflows/codeql-analysis.yml:analyze", + "environment": "{\"language\":\"javascript\"}", + "state": "open", + "commit_sha": "b3cfb0474bb3d5b5cd499a17e448281abbd256d7", + "message": { + "text": "Disabling SCE is strongly discouraged." + }, + "location": { + "path": "app/pixi.html", + "start_line": 179, + "end_line": 179, + "start_column": 4, + "end_column": 31 + }, + "classifications": [] + } +] \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/user-1.json new file mode 100644 index 0000000000..039ef9bf05 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/__files/user-1.json @@ -0,0 +1,46 @@ +{ + "login": "akashRindhe", + "id": 14114123, + "node_id": "MDQ6VXNlcjE0MTE0MTIz", + "avatar_url": "https://avatars.githubusercontent.com/u/14114123?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akashRindhe", + "html_url": "https://github.com/akashRindhe", + "followers_url": "https://api.github.com/users/akashRindhe/followers", + "following_url": "https://api.github.com/users/akashRindhe/following{/other_user}", + "gists_url": "https://api.github.com/users/akashRindhe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akashRindhe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akashRindhe/subscriptions", + "organizations_url": "https://api.github.com/users/akashRindhe/orgs", + "repos_url": "https://api.github.com/users/akashRindhe/repos", + "events_url": "https://api.github.com/users/akashRindhe/events{/privacy}", + "received_events_url": "https://api.github.com/users/akashRindhe/received_events", + "type": "User", + "site_admin": false, + "name": "Akash Rindhe", + "company": null, + "blog": "", + "location": "Singapore", + "email": null, + "hireable": null, + "bio": null, + "twitter_username": null, + "public_repos": 10, + "public_gists": 0, + "followers": 0, + "following": 6, + "created_at": "2015-09-03T18:07:43Z", + "updated_at": "2021-05-18T02:04:49Z", + "private_gists": 0, + "total_private_repos": 4, + "owned_private_repos": 4, + "disk_usage": 25766, + "collaborators": 1, + "two_factor_authentication": true, + "plan": { + "name": "free", + "space": 976562499, + "collaborators": 0, + "private_repos": 10000 + } +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json new file mode 100644 index 0000000000..2767224e1f --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json @@ -0,0 +1,47 @@ +{ + "id": "739d3462-2e22-426c-a77c-d20fd076943a", + "name": "repos_hub4j-test-org_pixi", + "request": { + "url": "/repos/hub4j-test-org/Pixi", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi-2.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:19:07 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/\"798dc78bb4c7a5f7af29dd24986abff44807dbd0601e8a2e0b5768a9e86d236f\"", + "Last-Modified": "Mon, 17 May 2021 14:50:01 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "repo", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4997", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "3", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "ECF6:0F89:98810:A70AE:60A5104A" + } + }, + "uuid": "739d3462-2e22-426c-a77c-d20fd076943a", + "persistent": true, + "insertionIndex": 2 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json new file mode 100644 index 0000000000..23306dde16 --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -0,0 +1,46 @@ +{ + "id": "b402a154-73bd-4924-8b91-4f24595619b8", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts?state=dismissed&per_page=1", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts-3.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:19:08 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/\"9a1d2adc0632ce1ed356060f568dde4d49ff9bb466dbd8dd178c2d7f2deb168a\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4996", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "4", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "ECF6:0F89:98830:A70D5:60A5104B" + } + }, + "uuid": "b402a154-73bd-4924-8b91-4f24595619b8", + "persistent": true, + "insertionIndex": 3 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json new file mode 100644 index 0000000000..43f9c37ddc --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json @@ -0,0 +1,46 @@ +{ + "id": "80a85afe-0843-4749-a7fc-9ff3bfef9d98", + "name": "repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances", + "request": { + "url": "/repos/hub4j-test-org/Pixi/code-scanning/alerts/1/instances", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:19:08 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/\"c919e1cdca3a115eeb46d88ad4f4f4ca2cf3a73f1ef3f8759d3f1912d0501847\"", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "admin:repo_hook, delete_repo, read:repo_hook, repo, repo:invite, repo:status, repo_deployment, security_events, write:repo_hook", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4995", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "5", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "ECF6:0F89:98841:A70E9:60A5104C" + } + }, + "uuid": "80a85afe-0843-4749-a7fc-9ff3bfef9d98", + "persistent": true, + "insertionIndex": 4 +} \ No newline at end of file diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json new file mode 100644 index 0000000000..23870c743a --- /dev/null +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json @@ -0,0 +1,47 @@ +{ + "id": "3791c749-1861-498d-91c0-ae1cb17c4d13", + "name": "user", + "request": { + "url": "/user", + "method": "GET", + "headers": { + "Accept": { + "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + } + } + }, + "response": { + "status": 200, + "bodyFileName": "user-1.json", + "headers": { + "Server": "GitHub.com", + "Date": "Wed, 19 May 2021 13:19:05 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/\"b3db1d8dfd0cef27934c732c74e2d774a7869d6c1b525a4b22e050220ee9aa33\"", + "Last-Modified": "Tue, 18 May 2021 02:04:49 GMT", + "X-OAuth-Scopes": "admin:enterprise, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete:packages, delete_repo, gist, notifications, repo, user, workflow, write:discussion, write:packages", + "X-Accepted-OAuth-Scopes": "", + "X-GitHub-Media-Type": "unknown, github.v3", + "X-RateLimit-Limit": "5000", + "X-RateLimit-Remaining": "4999", + "X-RateLimit-Reset": "1621433945", + "X-RateLimit-Used": "1", + "X-RateLimit-Resource": "core", + "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'", + "X-GitHub-Request-Id": "ECF6:0F89:987DE:A707B:60A51049" + } + }, + "uuid": "3791c749-1861-498d-91c0-ae1cb17c4d13", + "persistent": true, + "insertionIndex": 1 +} \ No newline at end of file From b3742b8f9600d2e1b80f9ce851595dad578d62f5 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 25 Oct 2021 14:41:10 -0700 Subject: [PATCH 5/9] Bring PR up to current main --- .../java/org/kohsuke/github/GHCodeScanningAlert.java | 12 +++--------- .../github/GHCodeScanningAlertInstancesIterable.java | 11 +++-------- .../kohsuke/github/GHCodeScanningAlertsIterable.java | 11 +++-------- src/main/java/org/kohsuke/github/GHRepository.java | 4 ++-- 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java index 8e21e46c57..3918d49429 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java @@ -29,14 +29,6 @@ public class GHCodeScanningAlert extends GHObject { GHCodeScanningAlert wrap(GHRepository owner) { this.owner = owner; - return wrap(owner.root); - } - - GHCodeScanningAlert wrap(GitHub root) { - this.root = root; - if (owner != null) { - owner.wrap(root); - } return this; } @@ -79,6 +71,7 @@ public GHCodeScanningAlertState getState() { * * @return the user */ + @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior") public GHUser getDismissedBy() { return dismissed_by; } @@ -134,7 +127,8 @@ public GHCodeScanningAlertInstance getMostRecentInstance() { * @return the paged iterable */ public PagedIterable listAlertInstances() { - return new GHCodeScanningAlertInstancesIterable(this, root.createRequest().withUrlPath(instances_url)); + return new GHCodeScanningAlertInstancesIterable(this, + root().createRequest().withUrlPath(instances_url).build()); } @Override diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java index 0ce4f1116b..7d66419128 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import java.net.MalformedURLException; import java.util.Iterator; import javax.annotation.Nonnull; @@ -10,13 +9,9 @@ public class GHCodeScanningAlertInstancesIterable extends PagedIterable requestBuilder) { + GHCodeScanningAlertInstancesIterable(GHCodeScanningAlert owner, GitHubRequest request) { this.owner = owner; - try { - this.request = requestBuilder.build(); - } catch (MalformedURLException e) { - throw new GHException("Malformed URL", e); - } + this.request = request; } @Nonnull @@ -24,7 +19,7 @@ public GHCodeScanningAlertInstancesIterable(GHCodeScanningAlert owner, GitHubReq public PagedIterator _iterator(int pageSize) { return new PagedIterator<>( adapt(GitHubPageIterator - .create(owner.getRoot().getClient(), GHCodeScanningAlertInstance[].class, request, pageSize)), + .create(owner.root().getClient(), GHCodeScanningAlertInstance[].class, request, pageSize)), null); } diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java index 20a1933d9f..ae05818be5 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertsIterable.java @@ -1,6 +1,5 @@ package org.kohsuke.github; -import java.net.MalformedURLException; import java.util.Iterator; import javax.annotation.Nonnull; @@ -10,13 +9,9 @@ class GHCodeScanningAlertsIterable extends PagedIterable { private final GitHubRequest request; private GHCodeScanningAlert[] result; - public GHCodeScanningAlertsIterable(GHRepository owner, GitHubRequest.Builder requestBuilder) { + GHCodeScanningAlertsIterable(GHRepository owner, GitHubRequest request) { this.owner = owner; - try { - this.request = requestBuilder.build(); - } catch (MalformedURLException e) { - throw new GHException("Malformed URL", e); - } + this.request = request; } @Nonnull @@ -24,7 +19,7 @@ public GHCodeScanningAlertsIterable(GHRepository owner, GitHubRequest.Builder public PagedIterator _iterator(int pageSize) { return new PagedIterator<>( adapt(GitHubPageIterator - .create(owner.getRoot().getClient(), GHCodeScanningAlert[].class, request, pageSize)), + .create(owner.root().getClient(), GHCodeScanningAlert[].class, request, pageSize)), null); } diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index ce984aec4f..81b9202dff 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -3556,7 +3556,7 @@ public PagedIterable listCodeScanningAlerts(String toolName private PagedIterable listCodeScanningAlerts(Map filters) { return new GHCodeScanningAlertsIterable(this, - root.createRequest().withUrlPath(getApiTailUrl("code-scanning/alerts")).with(filters)); + root().createRequest().withUrlPath(getApiTailUrl("code-scanning/alerts")).with(filters).build()); } /** @@ -3569,7 +3569,7 @@ private PagedIterable listCodeScanningAlerts(Map Date: Wed, 21 Dec 2022 10:32:31 -0500 Subject: [PATCH 6/9] Adding javadoc comments that were missing --- .../github/GHCodeScanningAlertInstance.java | 45 +++++++++++++++++++ .../GHCodeScanningAlertInstancesIterable.java | 10 +++++ .../github/GHCodeScanningAlertState.java | 16 ++++++- 3 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java index 1c213ab805..fa0c8aeb81 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java @@ -6,6 +6,11 @@ import java.util.Collections; import java.util.List; +/** + * Code scanning alert instance for a repository + * + * + */ public class GHCodeScanningAlertInstance { private String ref; private String analysis_key; @@ -16,34 +21,74 @@ public class GHCodeScanningAlertInstance { private Message message; private Location location; + /** + * Ref that the alert instance was triggered on + * + * @return ref of the alert instance + */ public String getRef() { return ref; } + /** + * Analysis key of the alert instance + * + * @return the analysis key + */ public String getAnalysisKey() { return analysis_key; } + /** + * Environment the alert instance was triggered in + * + * @return the environment + */ public String getEnvironment() { return environment; } + /** + * State of alert instance + * + * @return the state + */ public GHCodeScanningAlertState getState() { return state; } + /** + * Commit Sha that triggered the alert instance + * + * @return the commit sha + */ public String getCommitSha() { return commit_sha; } + /** + * Classifications of the alert instance + * + * @return the list of classifications + */ public List getClassifications() { return Collections.unmodifiableList(Arrays.asList(classifications)); } + /** + * Message object associated with the alert instance + * + * @return the message object + */ public Message getMessage() { return message; } + /** + * Location of the alert instance (contains path, start_line, end_line, start_column, and end_column attributes) + * + * @return the location + */ public Location getLocation() { return location; } diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java index 7d66419128..ded88d4f9b 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstancesIterable.java @@ -4,6 +4,9 @@ import javax.annotation.Nonnull; +/** + * Iterable for github code scanning instances. + */ public class GHCodeScanningAlertInstancesIterable extends PagedIterable { private final GHCodeScanningAlert owner; private final GitHubRequest request; @@ -23,6 +26,13 @@ public PagedIterator _iterator(int pageSize) { null); } + /** + * Adapts {@link Iterator}. + * + * @param base + * the base + * @return the iterator + */ protected Iterator adapt(final Iterator base) { return new Iterator() { public boolean hasNext() { diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java index 2b9f2ad470..8c5ce4077f 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertState.java @@ -1,5 +1,19 @@ package org.kohsuke.github; +/** + * What is the current state of the Alert + */ public enum GHCodeScanningAlertState { - OPEN, FIXED, DISMISSED + /** + * Alert is open and still an active issue. + */ + OPEN, + /** + * Issue that has caused the alert has been addressed. + */ + FIXED, + /** + * Alert has been dismissed by a user without being fixed. + */ + DISMISSED } From 3e3f4b2bb8fa7a7ad93eab9a2ef71862dfe17428 Mon Sep 17 00:00:00 2001 From: Wilson Wong Date: Tue, 6 Feb 2024 20:07:05 -0800 Subject: [PATCH 7/9] Improve test coverage for code scanning APIs --- .../kohsuke/github/GHCodeScanningAlert.java | 71 ++++++++++---- .../github/GHCodeScanningAlertInstance.java | 93 ++++++++++++++++++- .../java/org/kohsuke/github/GHRepository.java | 20 ++++ .../GHCodeScanningAlertInstanceTest.java | 20 +++- .../github/GHCodeScanningAlertTest.java | 53 +++++++++-- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- ...-test-org_pixi_code-scanning_alerts-3.json | 2 +- ...xi_code-scanning_alerts_1_instances-4.json | 2 +- .../mappings/user-1.json | 2 +- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- ...-test-org_pixi_code-scanning_alerts-3.json | 2 +- ...est-org_pixi_code-scanning_alerts_1-4.json | 2 +- .../mappings/user-1.json | 2 +- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- ...-test-org_pixi_code-scanning_alerts-3.json | 2 +- ...-test-org_pixi_code-scanning_alerts-4.json | 2 +- .../mappings/user-1.json | 2 +- 17 files changed, 240 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java index 3918d49429..dfe39739bc 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlert.java @@ -7,6 +7,9 @@ import java.net.URL; import java.util.Date; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + /** * Code scanning alert for a repository * @@ -142,74 +145,106 @@ public URL getHtmlUrl() throws IOException { @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") static class Rule { private String id; - private String severity; - private String description; private String name; - private String full_description; + private String description; + private String severity; + private String security_severity_level; private String[] tags; + private String full_description; private String help; + private String help_uri; + /** - * Id of rule + * A unique identifier for the rule used to detect the alert. * * @return the id */ + @Nullable public String getId() { return id; } /** - * Severity of rule + * The name of the rule used to detect the alert. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * The severity of the alert. * * @return the severity */ + @Nullable public String getSeverity() { return severity; } /** - * Description of rule + * The security severity of the alert. + * + * @return the security severity + */ + @Nullable + public String getSecuritySeverityLevel() { + return security_severity_level; + } + + /** + * A short description of the rule used to detect the alert. * * @return the description */ + @Nonnull public String getDescription() { return description; } /** - * Name of rule + * A set of tags applicable for the rule. * - * @return the name + * @return the tags */ - public String getName() { - return name; + @Nullable + public String[] getTags() { + return tags; } + // The following fields only appear on some endpoints. + // These might be empty on endpoints like listSecurityAlerts + /** * Full description of rule * * @return the full description */ + @Nonnull public String getFullDescription() { return full_description; } /** - * Tags associated with the rule + * Help text for the rule * - * @return the tags + * @return the help text */ - public String[] getTags() { - return tags; + @Nullable + public String getHelp() { + return help; } /** - * Help text for the rule + * A link to documentation for the rule used to detect the alert. Can be null. * - * @return the help text + * @return alert documentation url */ - public String getHelp() { - return help; + @Nullable + public String getHelpUri() { + return help_uri; } } diff --git a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java index fa0c8aeb81..0991051ea3 100644 --- a/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java +++ b/src/main/java/org/kohsuke/github/GHCodeScanningAlertInstance.java @@ -5,6 +5,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Objects; /** * Code scanning alert instance for a repository @@ -93,41 +94,129 @@ public Location getLocation() { return location; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + GHCodeScanningAlertInstance that = (GHCodeScanningAlertInstance) o; + return Objects.equals(ref, that.ref) && Objects.equals(analysis_key, that.analysis_key) + && Objects.equals(environment, that.environment) && state == that.state + && Objects.equals(commit_sha, that.commit_sha) && Arrays.equals(classifications, that.classifications) + && Objects.equals(message, that.message) && Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + int result = Objects.hash(ref, analysis_key, environment, state, commit_sha, message, location); + result = 31 * result + Arrays.hashCode(classifications); + return result; + } + + /** + * Alert message + */ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") - static class Message { + public static class Message { private String text; + /** + * Alert message + * + * @return contents of the message + */ public String getText() { return text; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Message message = (Message) o; + return Objects.equals(text, message.text); + } + + @Override + public int hashCode() { + return Objects.hash(text); + } } + /** + * Describe a region within a file for an alert. + */ @SuppressFBWarnings(value = { "UWF_UNWRITTEN_FIELD" }, justification = "JSON API") - static class Location { + public static class Location { private String path; private long start_line; private long end_line; private long start_column; private long end_column; + /** + * Path to the file containing the described code region + * + * @return path + */ public String getPath() { return path; } + /** + * Line number at the start of the code region. + * + * @return line number at the start of the code region + */ public long getStartLine() { return start_line; } + /** + * Line number at the end of the code region. + * + * @return line number at the end of the code region + */ public long getEndLine() { return end_line; } + /** + * Column number at the start of the code region. + * + * @return column number at the start of the code region + */ public long getStartColumn() { return start_column; } + /** + * Column number at the end of the code region. + * + * @return column number at the end of the code region + */ public long getEndColumn() { return end_column; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Location location = (Location) o; + return start_line == location.start_line && end_line == location.end_line + && start_column == location.start_column && end_column == location.end_column + && path.equals(location.path); + } + + @Override + public int hashCode() { + return Objects.hash(path, start_line, end_line, start_column, end_column); + } } } diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 81b9202dff..98ab32b42a 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -3525,6 +3525,11 @@ public GHTagObject createTag(String tag, String message, String object, String t /** * Lists the code scanning alerts of this repository. + *

+ * See: List + * code scanning alerts for a repository + *

* * @return the paged iterable */ @@ -3534,6 +3539,11 @@ public PagedIterable listCodeScanningAlerts() { /** * Lists the code scanning alerts of this repository filtered on the alert status + *

+ * See: List + * code scanning alerts for a repository + *

* * @param state * alert status to filter on @@ -3545,6 +3555,11 @@ public PagedIterable listCodeScanningAlerts(GHCodeScanningA /** * Lists the code scanning alerts of this repository filtered on the code scanning tool name + *

+ * See: List + * code scanning alerts for a repository + *

* * @param toolName * name of code scanning tool that creates alerts @@ -3562,6 +3577,11 @@ private PagedIterable listCodeScanningAlerts(MapSee: + * + * Get a code scanning alert

+ * * @param id * id of the code scanning alert * @return the code scanning alert diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java index c80953eb01..b469142a4a 100644 --- a/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java @@ -7,8 +7,7 @@ import java.io.IOException; import java.util.List; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.*; /** *

@@ -21,6 +20,11 @@ public class GHCodeScanningAlertInstanceTest extends AbstractGitHubWireMockTest private static final String REPO_NAME = "Pixi"; private GHCodeScanningAlert alert; + /** + * Load a dismissed alert from the code scanning api web response + * + * @throws Exception the exception + */ @Before public void setUp() throws Exception { GHRepository repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); @@ -35,6 +39,10 @@ private GHCodeScanningAlert getAlertFromRepo(GHRepository repo) { return dismissedAlerts.get(0); } + /** + * Test that an alert returns a list of its own instances + * @throws IOException could not get a compatible response + */ @Test public void testListAlertInstances() throws IOException { // Arrange @@ -53,6 +61,12 @@ public void testListAlertInstances() throws IOException { assertThat(instance.getMessage(), not((Object) null)); assertThat(instance.getLocation(), not((Object) null)); + assertThat(instance.getMessage().getText(), not(emptyOrNullString())); + + assertThat(instance.getAnalysisKey(), not((Object) null)); + assertThat(instance.getClassifications(), not((Object) null)); + assertThat(instance.getEnvironment(), notNullValue()); + GHCodeScanningAlertInstance.Location location = instance.getLocation(); // Can't assert on exact values with having to hardcode values from // json file, hence making the assertions generics @@ -60,6 +74,6 @@ public void testListAlertInstances() throws IOException { assertThat(location.getStartLine(), greaterThanOrEqualTo(0L)); assertThat(location.getEndLine(), greaterThanOrEqualTo(0L)); assertThat(location.getStartColumn(), greaterThanOrEqualTo(0L)); - assertThat(location.getStartColumn(), greaterThanOrEqualTo(0L)); + assertThat(location.getEndColumn(), greaterThanOrEqualTo(0L)); } } diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java index 709d546876..8bd65c2b9e 100644 --- a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java @@ -5,12 +5,13 @@ import org.junit.Test; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.util.List; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; +import javax.annotation.Nonnull; + +import static org.hamcrest.Matchers.*; /** *

@@ -23,11 +24,20 @@ public class GHCodeScanningAlertTest extends AbstractGitHubWireMockTest { private static final String REPO_NAME = "Pixi"; private GHRepository repo; + /** + * Set up the test with alerts from a purpose-made repo + * + * @throws Exception trouble + */ @Before public void setUp() throws Exception { repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); } + /** + * Check that we can get a list of alerts for a repo and that the response contains + * values in its required fields. + */ @Test public void testListCodeScanningAlerts() { // Arrange @@ -45,7 +55,8 @@ public void testListCodeScanningAlerts() { assertThat(alert.getTool(), not((Object) null)); GHCodeScanningAlert.Tool tool = alert.getTool(); assertThat(tool.getName(), is("CodeQL")); - assertThat(tool.getVersion(), not((Object) null)); + assertThat(tool.getVersion(), isA(String.class)); + assertThat(tool.getGuid(), anyOf(nullValue(), isA(String.class))); // Verify that fields of the code scanning rule are non-null assertThat(alert.getRule(), not((Object) null)); @@ -53,6 +64,8 @@ public void testListCodeScanningAlerts() { assertThat(rule.getId(), not((Object) null)); assertThat(rule.getName(), not((Object) null)); assertThat(rule.getSeverity(), not((Object) null)); + assertThat(rule.getDescription(), not((Object) null)); + assertThat(rule.getSecuritySeverityLevel(), anyOf(nullValue(), instanceOf(String.class))); // Act - Search by filtering on alert status List openAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.OPEN) @@ -66,8 +79,15 @@ public void testListCodeScanningAlerts() { assertThat(openAlert.getState(), is(GHCodeScanningAlertState.OPEN)); } + /** + * Get the data for a single alert and verify that the additional details are filled in. + * + * @throws IOException encountered an error while retrieving a response + * @throws InvocationTargetException tried to reflectively invoke a method incorrectly + * @throws IllegalAccessException tried to reflectively invoke a method that didn't want to be called + */ @Test - public void testGetCodeScanningAlert() throws IOException { + public void testGetCodeScanningAlert() throws IOException, InvocationTargetException, IllegalAccessException { // Arrange List dismissedAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.DISMISSED) ._iterator(1) @@ -85,6 +105,27 @@ public void testGetCodeScanningAlert() throws IOException { assertThat(result.getDismissedReason(), equalTo(dismissedAlert.getDismissedReason())); assertThat(result.getDismissedAt(), equalTo(dismissedAlert.getDismissedAt())); assertThat(result.getDismissedBy().login, equalTo(dismissedAlert.getDismissedBy().login)); + assertThat(result.getHtmlUrl(), equalTo(dismissedAlert.getHtmlUrl())); + assertThat(result.getMostRecentInstance(), equalToObject(dismissedAlert.getMostRecentInstance())); + + GHCodeScanningAlert.Rule rule = result.getRule(); + assertThat(rule.getId(), not((Object) null)); + assertThat(rule.getSeverity(), not((Object) null)); + assertThat(rule.getDescription(), not((Object) null)); + assertThat(rule.getName(), not((Object) null)); + + // The following fields are exclusive to getCodeScanningAlert's response + assertThat(rule.getFullDescription(), not((Object) null)); + assertThat(rule.getTags(), arrayWithSize(greaterThan(0))); + assertThat(rule.getHelp(), not((Object) null)); + assertThat(rule.getHelpUri(), anyOf(nullValue(), isA(String.class))); + + // A little redundant, but we should enforce that Nonnull getters return a value + for (Method m : GHCodeScanningAlert.Rule.class.getDeclaredMethods()) { + if (m.isAnnotationPresent(Nonnull.class)) { + assertThat(m.invoke(rule), notNullValue()); + } + } } } diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json index 2767224e1f..a70ce2b8af 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index 23306dde16..6cd5c0379c 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json index 43f9c37ddc..d6935cbd0c 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json index 23870c743a..d14f54e6df 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json index 55ff3cc82e..33c387a845 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index 5b8fed5a77..c9f93daef8 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json index 1bf9bdf4a3..bb4b4af04d 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json index 3227dd2fc9..cc93722811 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json index 3d6ed9491a..7838acf249 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index d7a775c4c9..2462962c3a 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json index fd76711943..886c3b2b10 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json index 052e6c4692..db891874df 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2" + "equalTo": "application/vnd.github.v3+json" } } }, From 43ef76f9d72f7aff9427f5c31f46956425fdff0d Mon Sep 17 00:00:00 2001 From: Wilson Wong Date: Wed, 7 Feb 2024 23:44:20 -0800 Subject: [PATCH 8/9] Run spotlessApply --- .../java/org/kohsuke/github/GHRepository.java | 7 ++++--- .../github/GHCodeScanningAlertInstanceTest.java | 7 +++++-- .../kohsuke/github/GHCodeScanningAlertTest.java | 15 +++++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 98ab32b42a..57667ed502 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -3577,10 +3577,11 @@ private PagedIterable listCodeScanningAlerts(MapSee: - * + * See: - * Get a code scanning alert

+ * Get a code scanning alert + *

* * @param id * id of the code scanning alert diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java index b469142a4a..7238363fb0 100644 --- a/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertInstanceTest.java @@ -23,7 +23,8 @@ public class GHCodeScanningAlertInstanceTest extends AbstractGitHubWireMockTest /** * Load a dismissed alert from the code scanning api web response * - * @throws Exception the exception + * @throws Exception + * the exception */ @Before public void setUp() throws Exception { @@ -41,7 +42,9 @@ private GHCodeScanningAlert getAlertFromRepo(GHRepository repo) { /** * Test that an alert returns a list of its own instances - * @throws IOException could not get a compatible response + * + * @throws IOException + * could not get a compatible response */ @Test public void testListAlertInstances() throws IOException { diff --git a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java index 8bd65c2b9e..b6df47e31d 100644 --- a/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java +++ b/src/test/java/org/kohsuke/github/GHCodeScanningAlertTest.java @@ -27,7 +27,8 @@ public class GHCodeScanningAlertTest extends AbstractGitHubWireMockTest { /** * Set up the test with alerts from a purpose-made repo * - * @throws Exception trouble + * @throws Exception + * trouble */ @Before public void setUp() throws Exception { @@ -35,8 +36,7 @@ public void setUp() throws Exception { } /** - * Check that we can get a list of alerts for a repo and that the response contains - * values in its required fields. + * Check that we can get a list of alerts for a repo and that the response contains values in its required fields. */ @Test public void testListCodeScanningAlerts() { @@ -82,9 +82,12 @@ public void testListCodeScanningAlerts() { /** * Get the data for a single alert and verify that the additional details are filled in. * - * @throws IOException encountered an error while retrieving a response - * @throws InvocationTargetException tried to reflectively invoke a method incorrectly - * @throws IllegalAccessException tried to reflectively invoke a method that didn't want to be called + * @throws IOException + * encountered an error while retrieving a response + * @throws InvocationTargetException + * tried to reflectively invoke a method incorrectly + * @throws IllegalAccessException + * tried to reflectively invoke a method that didn't want to be called */ @Test public void testGetCodeScanningAlert() throws IOException, InvocationTargetException, IllegalAccessException { From 1e9c3818c639fa5bef98991cbe5c3900f1a5d76c Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Mon, 1 Jul 2024 11:33:04 -0700 Subject: [PATCH 9/9] Apply suggestions from code review --- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- .../repos_hub4j-test-org_pixi_code-scanning_alerts-3.json | 2 +- ..._hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json | 2 +- .../wiremock/testListAlertInstances/mappings/user-1.json | 2 +- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- .../repos_hub4j-test-org_pixi_code-scanning_alerts-3.json | 2 +- .../repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json | 2 +- .../wiremock/testGetCodeScanningAlert/mappings/user-1.json | 2 +- .../mappings/repos_hub4j-test-org_pixi-2.json | 2 +- .../repos_hub4j-test-org_pixi_code-scanning_alerts-3.json | 2 +- .../repos_hub4j-test-org_pixi_code-scanning_alerts-4.json | 2 +- .../wiremock/testListCodeScanningAlerts/mappings/user-1.json | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json index a70ce2b8af..d58e375980 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index 6cd5c0379c..a987fe7d2b 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json index d6935cbd0c..a61ea1affc 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1_instances-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json index d14f54e6df..c92ea9eae2 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertInstanceTest/wiremock/testListAlertInstances/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json index 33c387a845..8dbce018c8 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index c9f93daef8..e68e6d04a4 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json index bb4b4af04d..838768a084 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts_1-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json index cc93722811..9244f04176 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testGetCodeScanningAlert/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json index 7838acf249..bbce963fe1 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi-2.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json index 2462962c3a..84d1bab1e2 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-3.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json index 886c3b2b10..b3aa75e76d 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/repos_hub4j-test-org_pixi_code-scanning_alerts-4.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } }, diff --git a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json index db891874df..3f6e64eb5b 100644 --- a/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json +++ b/src/test/resources/org/kohsuke/github/GHCodeScanningAlertTest/wiremock/testListCodeScanningAlerts/mappings/user-1.json @@ -6,7 +6,7 @@ "method": "GET", "headers": { "Accept": { - "equalTo": "application/vnd.github.v3+json" + "equalTo": "application/vnd.github+json" } } },