-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /operations endpoint to list available operations #17
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ A Docker image can be built, then run by doing the following: | |
## API overview | ||
> For full documentation of the API, you can find the swagger page hosted at the root url. See [Installing](#Installing) to run the application and browse the docs. | ||
|
||
Currently the server just has one endpoint: `/bake`. This endpoint accepts a POST request with the following body: | ||
The most important endpoint is `/bake`. This endpoint accepts a POST request with the following body: | ||
|
||
|Parameter|Type|Description| | ||
|---|---|---| | ||
|
@@ -160,6 +160,52 @@ Response: | |
} | ||
``` | ||
|
||
There is also a `/operations` endpoint. This endpoint accepts a GET request and responds with a JSON object listing the available operations on this server. Each operation name is one attribute, and its value is the description of the arguments it can take. | ||
|
||
#### Example: operation list | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a section for |
||
Response: | ||
```javascript | ||
{ | ||
"FromBase64" : { | ||
"alphabet" : { | ||
"type" : "editableOption", | ||
"options" : [ | ||
{ | ||
"name" : "Standard (RFC 4648): A-Za-z0-9+/=", | ||
"value" : "A-Za-z0-9+/=" | ||
}, | ||
{ | ||
"name" : "URL safe (RFC 4648 §5): A-Za-z0-9-_", | ||
"value" : "A-Za-z0-9-_" | ||
}, | ||
[...] | ||
] | ||
}, | ||
"removeNon-alphabetChars" : { | ||
"type" : "boolean", | ||
"value" : true | ||
} | ||
}, | ||
"ToBase64" : { | ||
"alphabet" : { | ||
"type" : "editableOption", | ||
"options" : [ | ||
{ | ||
"name" : "Standard (RFC 4648): A-Za-z0-9+/=", | ||
"value" : "A-Za-z0-9+/=" | ||
}, | ||
{ | ||
"name" : "URL safe (RFC 4648 §5): A-Za-z0-9-_", | ||
"value" : "A-Za-z0-9-_" | ||
}, | ||
[...] | ||
] | ||
} | ||
}, | ||
[...] | ||
} | ||
``` | ||
|
||
## Licencing | ||
|
||
CyberChef-server is released under the [Apache 2.0 Licence](https://www.apache.org/licenses/LICENSE-2.0) and is covered by [Crown Copyright](https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/copyright-and-re-use/crown-copyright/). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Router } from "express"; | ||
const router = Router(); | ||
import { operations } from "cyberchef/src/node/index.mjs"; | ||
|
||
/** | ||
* operationsGet | ||
*/ | ||
router.get("/", async (req, res, next) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a bit of a nit: please could you make this function a |
||
const ret = {}; | ||
for (const op of operations) { | ||
if (op.opName) ret[op.opName] = op.args; | ||
} | ||
res.send(ret); | ||
}); | ||
|
||
export default router; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,62 @@ info: | |
|
||
|
||
paths: | ||
/operations: | ||
get: | ||
summary: List available operations | ||
description: > | ||
Retrieve a list of all available operations on this server. | ||
The return value is an object whose attributes are operation names, | ||
and each attribute value is the description of the arguments | ||
the argument takes. | ||
responses: | ||
'200': | ||
description: OK | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
example: > | ||
{ | ||
"FromBase64" : { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please can you define the example response in YAML rather than a string that looks like JSON please. there should be an example of this in |
||
"alphabet" : { | ||
"type" : "editableOption", | ||
"options" : [ | ||
{ | ||
"name" : "Standard (RFC 4648): A-Za-z0-9+/=", | ||
"value" : "A-Za-z0-9+/=" | ||
}, | ||
{ | ||
"name" : "URL safe (RFC 4648 §5): A-Za-z0-9-_", | ||
"value" : "A-Za-z0-9-_" | ||
}, | ||
[...] | ||
] | ||
}, | ||
"removeNon-alphabetChars" : { | ||
"type" : "boolean", | ||
"value" : true | ||
} | ||
}, | ||
"ToBase64" : { | ||
"alphabet" : { | ||
"type" : "editableOption", | ||
"options" : [ | ||
{ | ||
"name" : "Standard (RFC 4648): A-Za-z0-9+/=", | ||
"value" : "A-Za-z0-9+/=" | ||
}, | ||
{ | ||
"name" : "URL safe (RFC 4648 §5): A-Za-z0-9-_", | ||
"value" : "A-Za-z0-9-_" | ||
}, | ||
[...] | ||
] | ||
} | ||
}, | ||
[...] | ||
} | ||
|
||
/bake: | ||
post: | ||
summary: Bakes a recipe | ||
|
@@ -99,4 +155,4 @@ components: | |
width: 16 | ||
upperCaseHex: true | ||
includeFinalLength: false | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make this part of the README a list of endpoints with anchor tags to their respective parts of the documentation please?