type Github = {
token: string;
};
/**
* List secret scanning alerts for an organization
* Lists secret scanning alerts for eligible repositories in an organization, from newest to oldest.
To use this endpoint, you must be an administrator 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 the `secret_scanning_alerts` read permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
state: "open" | "resolved" | undefined,
secret_type: string | undefined,
resolution: string | undefined,
sort: "created" | "updated" | undefined,
direction: "asc" | "desc" | undefined,
page: string | undefined,
per_page: string | undefined,
before: string | undefined,
after: string | undefined
) {
const url = new URL(
`https://api.github.com/orgs/${org}/secret-scanning/alerts`
);
for (const [k, v] of [
["state", state],
["secret_type", secret_type],
["resolution", resolution],
["sort", sort],
["direction", direction],
["page", page],
["per_page", per_page],
["before", before],
["after", after],
]) {
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 secret scanning alerts for an organization
* Lists secret scanning alerts for eligible repositories in an organization, from newest to oldest.
To use this endpoint, you must be an administrator 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 the `secret_scanning_alerts` read permission to use this endpoint.
*/
export async function main(
auth: Github,
org: string,
state: "open" | "resolved" | undefined,
secret_type: string | undefined,
resolution: string | undefined,
sort: "created" | "updated" | undefined,
direction: "asc" | "desc" | undefined,
page: string | undefined,
per_page: string | undefined,
before: string | undefined,
after: string | undefined
) {
const url = new URL(
`https://api.github.com/orgs/${org}/secret-scanning/alerts`
);
for (const [k, v] of [
["state", state],
["secret_type", secret_type],
["resolution", resolution],
["sort", sort],
["direction", direction],
["page", page],
["per_page", per_page],
["before", before],
["after", after],
]) {
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