Skip to content

Commit fd2c574

Browse files
committed
feat: fetch repository sbom
1 parent 36f0922 commit fd2c574

12 files changed

Lines changed: 2440 additions & 1 deletion

File tree

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,20 @@ public GHRelease getReleaseByTagName(String tag) throws IOException {
19831983
}
19841984
}
19851985

1986+
/**
1987+
* Exports the software bill of materials (SBOM) for a repository.
1988+
*
1989+
* @return the SBOM export result containing the SPDX-formatted SBOM
1990+
* @throws IOException
1991+
* the io exception
1992+
* @see <a href="https://docs.github.com/en/rest/dependency-graph/sboms">SBOM API documentation</a>
1993+
*/
1994+
public GHSBOMExportResult getSBOM() throws IOException {
1995+
return root().createRequest()
1996+
.withUrlPath(getApiTailUrl("dependency-graph/sbom"))
1997+
.fetch(GHSBOMExportResult.class);
1998+
}
1999+
19862000
/**
19872001
* Gets size.
19882002
*
@@ -3397,7 +3411,7 @@ private void modifyCollaborators(@NonNull Collection<GHUser> users,
33973411
* @return the api tail url
33983412
*/
33993413
String getApiTailUrl(String tail) {
3400-
if (tail.length() > 0 && !tail.startsWith("/")) {
3414+
if (!tail.isEmpty() && !tail.startsWith("/")) {
34013415
tail = '/' + tail;
34023416
}
34033417
return "/repos/" + fullName + tail;

0 commit comments

Comments
 (0)