Skip to content

Commit

Permalink
pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhala committed Jan 12, 2025
1 parent 1fa3fd1 commit 655e3f0
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 37 deletions.
17 changes: 0 additions & 17 deletions nodejs/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,4 @@ export default class API {

}

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: repo,
owner: org
})
return data
}
}


45 changes: 45 additions & 0 deletions nodejs/security.js
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
}
}
21 changes: 1 addition & 20 deletions nodejs/test/rest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import API, {CodeScan} from '../rest.js';
import API from '../rest.js';
import assert from 'assert';

describe('octokit:rest module', function () {
Expand Down Expand Up @@ -26,22 +26,3 @@ describe('octokit:rest module', function () {
assert.equal(user_view_type, 'private')
})
})
describe('codeScan', function () {
this.timeout(0)

it('list for repos', async () => {
const pat = process.env.GITHUB_TOKEN
const api = new CodeScan({pat})
const org = 'davidkhala'
const repo = 'ci-cd-utils'
const data = await api.listForRepo(org, repo)
console.debug(data)
})
it('list for org', async () => {
const pat = process.env.GITHUB_TOKEN
const api = new CodeScan({pat})
const org = 'stage4fish'
const data = await api.listForOrg(org)
console.debug(data)
})
})
56 changes: 56 additions & 0 deletions nodejs/test/security.js
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)
})
})

0 comments on commit 655e3f0

Please sign in to comment.