type Github = {
token: string;
};
/**
* List Dependabot alerts for an organization
* Lists Dependabot alerts for an organization.
To use this endpoint, you must be an owner or security manager for the organization, and you must use an access token with the `repo` scope or `security_events` scope.
For public repositories, you may instead use the `public_repo` scope.
GitHub Apps must have **Dependabot alerts** read permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
state: string | undefined,
severity: string | undefined,
ecosystem: string | undefined,
package: string | undefined,
scope: "development" | "runtime" | undefined,
sort: "created" | "updated" | undefined,
direction: "asc" | "desc" | undefined,
before: string | undefined,
after: string | undefined,
first: string | undefined,
last: string | undefined,
per_page: string | undefined
) {
const url = new URL(`https://api.github.com/orgs/${org}/dependabot/alerts`);
for (const [k, v] of [
["state", state],
["severity", severity],
["ecosystem", ecosystem],
["package", package],
["scope", scope],
["sort", sort],
["direction", direction],
["before", before],
["after", after],
["first", first],
["last", last],
["per_page", per_page],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 367 days ago
type Github = {
token: string;
};
/**
* List Dependabot alerts for an organization
* Lists Dependabot alerts for an organization.
To use this endpoint, you must be an owner or security manager for the organization, and you must use an access token with the `repo` scope or `security_events` scope.
For public repositories, you may instead use the `public_repo` scope.
GitHub Apps must have **Dependabot alerts** read permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
state: string | undefined,
severity: string | undefined,
ecosystem: string | undefined,
package: string | undefined,
scope: "development" | "runtime" | undefined,
sort: "created" | "updated" | undefined,
direction: "asc" | "desc" | undefined,
before: string | undefined,
after: string | undefined,
first: string | undefined,
last: string | undefined,
per_page: string | undefined
) {
const url = new URL(`https://api.github.com/orgs/${org}/dependabot/alerts`);
for (const [k, v] of [
["state", state],
["severity", severity],
["ecosystem", ecosystem],
["package", package],
["scope", scope],
["sort", sort],
["direction", direction],
["before", before],
["after", after],
["first", first],
["last", last],
["per_page", per_page],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 927 days ago