-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fa3fd1
commit 655e3f0
Showing
4 changed files
with
102 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import API from "./rest.js"; | ||
|
||
export class CodeScan extends API { | ||
async listForOrg(org) { | ||
const {data} = await this.client.codeScanning.listAlertsForOrg({ | ||
org, | ||
}); | ||
return data | ||
} | ||
|
||
async listForRepo(org, repo) { | ||
const {data} = await this.client.codeScanning.listAlertsForRepo({ | ||
repo, | ||
owner: org | ||
}) | ||
return data | ||
} | ||
} | ||
|
||
export class SecretScan extends API { | ||
async listForOrg(org) { | ||
const {data} = await this.client.secretScanning.listAlertsForOrg({org}) | ||
return data | ||
} | ||
|
||
async listForRepo(org, repo) { | ||
const {data} = await this.client.secretScanning.listAlertsForRepo({ | ||
owner: org, | ||
repo | ||
}) | ||
return data | ||
} | ||
} | ||
|
||
export class Dependabot extends API { | ||
async listForOrg(org) { | ||
const {data} = await this.client.dependabot.listAlertsForOrg({org}) | ||
return data | ||
} | ||
|
||
async listForRepo(org, repo) { | ||
const {data} = await this.client.dependabot.listAlertsForRepo({owner: org, repo}) | ||
return data | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {CodeScan, Dependabot, SecretScan} from "../security.js"; | ||
import assert from "assert"; | ||
const pat = process.env.GITHUB_TOKEN | ||
describe('codeScan', function () { | ||
this.timeout(0) | ||
const api = new CodeScan({pat}) | ||
it('list for repos', async () => { | ||
|
||
const org = 'davidkhala' | ||
const repo = 'ci-cd-utils' | ||
const data = await api.listForRepo(org, repo) | ||
console.debug(data) | ||
await assert.rejects(async()=>{ | ||
await api.listForRepo(undefined, `${org}/${repo}`) | ||
}, 'HttpError: Not Found - https://docs.github.com/rest') | ||
|
||
}) | ||
it('list for org', async () => { | ||
|
||
const org = 'stage4fish' | ||
const data = await api.listForOrg(org) | ||
console.debug(data) | ||
}) | ||
}) | ||
describe('secretScans', function () { | ||
this.timeout(0) | ||
const api = new SecretScan({pat}) | ||
it('list for repos', async () => { | ||
|
||
const org = 'davidkhala' | ||
const repo = 'ci-cd-utils' | ||
const data = await api.listForRepo(org, repo) | ||
console.debug(data) | ||
}) | ||
it('list for org', async () => { | ||
const org = 'stage4fish' | ||
const data = await api.listForOrg(org) | ||
console.debug(data) | ||
}) | ||
}) | ||
describe('Dependabot', function (){ | ||
this.timeout(0) | ||
const api = new Dependabot({pat}) | ||
it('list for repos', async ()=>{ | ||
|
||
const org = 'davidkhala' | ||
const repo = 'ci-cd-utils' | ||
const data = await api.listForRepo(org, repo) | ||
console.debug(data) | ||
}) | ||
it('list for org', async ()=>{ | ||
const org = 'stage4fish' | ||
const data = await api.listForOrg(org) | ||
console.debug(data) | ||
}) | ||
}) |