-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: compliance check infrastructure
- Loading branch information
Showing
23 changed files
with
507 additions
and
420 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
direnv 2.30.3 |
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 |
---|---|---|
@@ -1,3 +1,13 @@ | ||
{ | ||
"editor.tabSize": 2 | ||
"editor.tabSize": 2, | ||
"debug.javascript.autoAttachFilter": "disabled", | ||
"debug.javascript.autoAttachSmartPattern": [ | ||
"${workspaceFolder}/**", | ||
"!**/node_modules/**", | ||
"**/$KNOWN_TOOLS$/**", | ||
], | ||
"javascript.preferences.importModuleSpecifier": "relative", | ||
"typescript.preferences.importModuleSpecifier": "relative", | ||
"javascript.preferences.importModuleSpecifierEnding": "minimal", | ||
"typescript.preferences.importModuleSpecifierEnding": "minimal" | ||
} |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,30 +1,10 @@ | ||
/* eslint-disable no-console */ | ||
import { Configuration, PinResults, PinsApi } from '@ipfs-shipyard/pinning-service-client' | ||
import type { ListrRenderer, ListrTask } from 'listr2' | ||
import { requestLog, responseLog } from '../../middleware/requestReponseLogger' | ||
import { Check } from '../Check' | ||
|
||
const checkEmptyBearerToken = (pair: ServiceAndTokenPair): ListrTask<any, typeof ListrRenderer> => ({ | ||
title: 'Returns 403 without bearer token', | ||
task: async (ctx, task) => { | ||
const config = new Configuration({ | ||
basePath: pair[0], | ||
accessToken: undefined // no bearer token | ||
}) | ||
|
||
const client = new PinsApi(config) | ||
await client.pinsGet({}).then((response: PinResults) => { | ||
console.log(requestLog.pop(), 'checkEmptyBearerToken') | ||
console.log(responseLog.pop(), 'checkEmptyBearerToken') | ||
throw new Error('') | ||
}).catch((response: any | Record<string, any>) => { | ||
if (response.status === 403) { | ||
task.output = `${task.title} -> Received 403` | ||
return | ||
} | ||
throw new Error(`${task.title} -> Received ${response.status as string}`) | ||
}) | ||
}, | ||
exitOnError: false | ||
const checkEmptyBearerToken = async (pair: ServiceAndTokenPair) => await Check({ | ||
pair: [pair[0], undefined], | ||
title: 'Return 403 for requests with no authentication token', | ||
runCheck: async (details) => details.response.status === 403, | ||
apiCall: async (client) => await client.pinsGet({}) | ||
}) | ||
|
||
export { checkEmptyBearerToken } |
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 |
---|---|---|
@@ -1,34 +1,10 @@ | ||
import { Configuration, PinResults, PinsApi } from '@ipfs-shipyard/pinning-service-client' | ||
import type { ListrRenderer, ListrTask } from 'listr2' | ||
import { requestLog, responseLog } from '../../middleware/requestReponseLogger' | ||
import { Check } from '../Check' | ||
|
||
const checkInvalidBearerToken = (pair: ServiceAndTokenPair): ListrTask<any, typeof ListrRenderer> => ({ | ||
title: 'Returns 403 for invalid bearer token', | ||
task: async (ctx, task) => { | ||
const config = new Configuration({ | ||
basePath: pair[0], | ||
accessToken: 'foobarabc123' // invalid bearer token | ||
}) | ||
|
||
const client = new PinsApi(config) | ||
await client.pinsGet({}).then((response: PinResults) => { | ||
throw new Error('') | ||
}).catch((response: any | Record<string, any>) => { | ||
if (response.status === 403) { | ||
task.output = `${task.title} -> Received 403` | ||
return | ||
} | ||
throw new Error(`${task.title} -> Received ${response.status as string} | ||
checkInvalidBearerToken | ||
Request: | ||
${JSON.stringify(requestLog.pop())} | ||
Response: | ||
${JSON.stringify(responseLog.pop())} | ||
`) | ||
}) | ||
}, | ||
exitOnError: false | ||
const checkInvalidBearerToken = async (pair: ServiceAndTokenPair) => await Check({ | ||
pair: [pair[0], 'purposefullyInvalid'], | ||
title: 'Return 403 for requests with an invalid authentication token', | ||
runCheck: async (details) => details.response.status === 403, | ||
apiCall: async (client) => await client.pinsGet({}) | ||
}) | ||
|
||
export { checkInvalidBearerToken } |
Oops, something went wrong.